xref: /haiku/headers/os/translation/Translator.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2002-2009, 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 
23 	virtual	const char*			TranslatorName() const = 0;
24 	virtual const char*			TranslatorInfo() const = 0;
25 	virtual int32				TranslatorVersion() const = 0;
26 
27 	virtual const translation_format* InputFormats(int32* _count) const = 0;
28 	virtual const translation_format* OutputFormats(int32* _count) const = 0;
29 
30 	virtual status_t			Identify(BPositionIO* source,
31 									const translation_format* format,
32 									BMessage* extension, translator_info* info,
33 									uint32 outType) = 0;
34 	virtual status_t			Translate(BPositionIO* source,
35 									const translator_info* info,
36 									BMessage* extension, uint32 outType,
37 									BPositionIO* destination) = 0;
38 	virtual status_t			MakeConfigurationView(BMessage* extension,
39 									BView** _view, BRect* _extent);
40 	virtual status_t			GetConfigurationMessage(BMessage* extension);
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 
68 // The post-4.5 API suggests implementing this function in your translator
69 // add-on rather than the separate functions and variables of the previous
70 // API. You will be called for values of n starting at 0 and increasing;
71 // return 0 when you can't make another kind of translator (i.e. for n = 1
72 // if you only implement one subclass of BTranslator). Ignore flags for now.
73 extern "C" BTranslator* make_nth_translator(int32 n, image_id you,
74 	uint32 flags, ...);
75 
76 
77 #endif	// _TRANSLATOR_H
78