1 /* 2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Wilber 7 * Axel Dörfler, axeld@pinc-software.de 8 */ 9 #ifndef _FUNC_TRANSLATOR_H 10 #define _FUNC_TRANSLATOR_H 11 12 13 #include <Translator.h> 14 15 16 // Structure used to hold the collection of function pointers and 17 // public variables exported by function based translator add-ons. 18 struct translator_data { 19 const char* name; 20 const char* info; 21 int32 version; 22 const translation_format* input_formats; 23 const translation_format* output_formats; 24 25 status_t (*identify_hook)(BPositionIO* source, const translation_format* format, 26 BMessage* ioExtension, translator_info* outInfo, uint32 outType); 27 28 status_t (*translate_hook)(BPositionIO* source, const translator_info* info, 29 BMessage* ioExtension, uint32 outType, BPositionIO* destination); 30 31 status_t (*make_config_hook)(BMessage* ioExtension, BView** _view, BRect* _extent); 32 status_t (*get_config_message_hook)(BMessage* ioExtension); 33 }; 34 35 namespace BPrivate { 36 37 class BFuncTranslator : public BTranslator { 38 public: 39 BFuncTranslator(const translator_data& data); 40 41 virtual const char *TranslatorName() const; 42 virtual const char *TranslatorInfo() const; 43 virtual int32 TranslatorVersion() const; 44 45 virtual const translation_format *InputFormats(int32 *out_count) const; 46 virtual const translation_format *OutputFormats(int32 *out_count) const; 47 48 virtual status_t Identify(BPositionIO *inSource, 49 const translation_format *inFormat, BMessage *ioExtension, 50 translator_info *outInfo, uint32 outType); 51 virtual status_t Translate(BPositionIO *inSource, 52 const translator_info *inInfo, BMessage *ioExtension, uint32 outType, 53 BPositionIO * outDestination); 54 virtual status_t MakeConfigurationView(BMessage *ioExtension, 55 BView **outView, BRect *outExtent); 56 virtual status_t GetConfigurationMessage(BMessage *ioExtension); 57 58 protected: 59 virtual ~BFuncTranslator(); 60 // This object is deleted by calling Release(), 61 // it can not be deleted directly. See BTranslator in the Be Book 62 63 private: 64 translator_data fData; 65 }; 66 67 } // namespace BPrivate 68 69 #endif // _FUNC_TRANSLATOR_H 70