The Translation Kit Table of Contents | The Translation Kit Index |
Derived from: BArchivable
Declared in: be/translation/Translator.h
Library: libtranslation.so
BTranslator is an abstract superclass that you subclass to define your own proprietary translator objects, one translator per BTranslator subclass. You add instances of your BTranslator subclasses to a BTranslatorRoster through BTranslatorRoster::AddTranslator(). BTranslator objects that your app creates and adds to the Roster are not visible to other applications.
Note that the BTranslator destructor is protected; you never delete a BTranslator from outside the class. Insead, you Release() it. See Acquire() for details.
The primary BTranslator functions are similar to the functions and data that a translator add-on supplies. Most of the BTranslator functions take you to the Translator Add-ons descriptions.
|
The constructor must create and return a new instance of your BTranslator subclass. Note that the constructor doesn't Acquire() the object it returns.
|
Note that the destructor is protected; you can only delete a BTranslator object from within the implementation of the subclass. From outside the class, you call Release().
|
Acquire() and Release() increment and decrement the object's reference count. The count starts at 1 (i.e .the object is implicitly acquired when it's created); if the count falls to 0, the object is deleted.
When you add a BTranslator to a BTranslatorRoster, the BTranslator is automatically Acquire()'d. When the BTranslatorRoster is deleted, its BTranslators are Release()'d. Thus, when you instantiate a BTranslator and add it to a BTranslatorRoster, you and the Roster maintain joint ownership of the object. To give up ownership (such that the BTranslatorRoster will destroy the object when the Roster itself is destroyed), call Release() after adding the BTranslator to the Roster.
Acquire() and Release() both return a pointer to the BTranslator that was just acquired or released. If Release() caused the object to be deleted, it retruns NULL.
ReferenceCount(), which returns the current reference count value, is meant for debugging purposes only. It is not thread-safe! Don't predicate your code on the value it returns.
|
|
Hook function that asks the object to write its current state into the BMessage argument. See GetConfigMessage() [Translator Add-ons] for details.
|
|
Hook function called by the Translator Roster to ask the BTranslator if it knows how to convert inSource into the type described by outType. See Identify() [Translator Add-ons] for details.
|
|
These functions should be implemented to return arrays of translation_format structures that describe the formats that this object supports. If the functions aren't implemented, the object's Identify() function will be called each time an application requests a translation. Both functions should set count to the number of elements in the format array.
|
|
|
Hook function that lets the BTranslator supply a configuration view. See MakeConfig() [Translator Add-ons] for details.
|
|
Hook function that asks the BTranslator to translate data from inSource to format outType, writing the output to outDestination. See Translate() [Translator Add-ons] for details.
|
|
TranslatorInfo() returns a pointer to the translator's long name, e.g. "aiff translator by the Pie Man (pie@the.man)".
TranslatorName() returns a pointer to the translator's short name, e.g. "aiff translator". The short name should be appropriate for display in a menu.
TranslatorVersion() gives an "MM.mm" version number for the translator. For example, a TranslatorVersion() of 314 is interpreted as version 3.14.
The Translation Kit Table of Contents | The Translation Kit Index |
Copyright © 2000 Be, Inc. All rights reserved..