1 /* 2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TRANSLATOR_H 6 #define _TRANSLATOR_H 7 8 9 #include <Archivable.h> 10 #include <TranslationDefs.h> 11 #include <TranslatorRoster.h> 12 13 14 class BTranslator : public BArchivable { 15 public: 16 BTranslator(); 17 18 BTranslator* Acquire(); 19 BTranslator* Release(); 20 21 int32 ReferenceCount(); 22 // returns the refcount, THIS IS NOT THREAD SAFE, ITS ONLY FOR "FUN" 23 24 virtual const char *TranslatorName() const = 0; 25 virtual const char *TranslatorInfo() const = 0; 26 virtual int32 TranslatorVersion() const = 0; 27 28 virtual const translation_format *InputFormats(int32 *out_count) 29 const = 0; 30 virtual const translation_format *OutputFormats(int32 *out_count) 31 const = 0; 32 virtual status_t Identify(BPositionIO *inSource, 33 const translation_format *inFormat, BMessage *ioExtension, 34 translator_info *outInfo, uint32 outType) = 0; 35 virtual status_t Translate(BPositionIO *inSource, 36 const translator_info *inInfo, BMessage *ioExtension, 37 uint32 outType, BPositionIO *outDestination) = 0; 38 virtual status_t MakeConfigurationView(BMessage *ioExtension, 39 BView **outView, BRect *outExtent); 40 virtual status_t GetConfigurationMessage(BMessage *ioExtension); 41 42 protected: 43 virtual ~BTranslator(); 44 // this is protected because the object is deleted by the 45 // Release() function instead of being deleted directly by 46 // the user 47 48 private: 49 friend class BTranslatorRoster::Private; 50 51 virtual status_t _Reserved_Translator_0(int32, void *); 52 virtual status_t _Reserved_Translator_1(int32, void *); 53 virtual status_t _Reserved_Translator_2(int32, void *); 54 virtual status_t _Reserved_Translator_3(int32, void *); 55 virtual status_t _Reserved_Translator_4(int32, void *); 56 virtual status_t _Reserved_Translator_5(int32, void *); 57 virtual status_t _Reserved_Translator_6(int32, void *); 58 virtual status_t _Reserved_Translator_7(int32, void *); 59 60 BTranslatorRoster::Private* fOwningRoster; 61 translator_id fID; 62 int32 fRefCount; 63 64 uint32 _reserved[7]; 65 }; 66 67 // The post-4.5 API suggests implementing this function in your translator 68 // add-on rather than the separate functions and variables of the previous 69 // API. You will be called for values of n starting at 0 and increasing; 70 // return 0 when you can't make another kind of translator (i.e. for n=1 71 // if you only implement one subclass of BTranslator). Ignore flags for now. 72 extern "C" _EXPORT BTranslator *make_nth_translator(int32 n, image_id you, 73 uint32 flags, ...); 74 75 #endif /* _TRANSLATOR_H */ 76