Translation subsystem

WebRunner Sample uses global translators in conjunction with the Data Translation framework to provide effortless conversion between third party data types and CommonPoint objects. This functionality enables you to upgrade to new data types without modifying existing program code. In addition, it alleviates the need for supporting your own data import and export code for multiple
file formats.


To extend data translators, you must provide one translator class to serve as a gateway between third party data and Taligent objects. To write this translator, you need to create a library that contains a derived class of TForeignDataTranslator. TGIFTranslator and TXBMTranslator both override
the CreateScrapItem and ExportData member functions to implement the translator protocol.

CreateScrapItem provides the interface for converting an abstract TForeignData object to a CommonPoint TScrapItem. Both sample translators achieve this by creating a stream from the TForeignData object and then parsing the incoming data. TGIFTranslator accomplishes this by using the built-in CommonPoint TGIFConverter. TXBMTranslator shows a full conversion from an incoming data stream to an X-Bitmap image.

In both cases, the incoming data is bundled into a scrap item and returned. The recipient of the scrap item can use CommonPoint's dynamic cast interface to extract the data it requires.

NOTE The ExportData member function translates from a local scrap item to an external data type. It is unsupported in this release.

Once you have written your translators, you can install them in the global translators with a text file that specifies the supported translators using
the command

    $TaligentBinaries/InstallTranslator
For the GIF translator, this file is called GIFTranslator.txt. You install it using
the command

    $TaligentBinaries/InstallTranslator GIFTranslator.txt
When you have installed the translators, they automatically become available to any program that uses a TImportForeignDataQuery with the appropriate type
of input.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker