xref: /haiku/src/kits/translation/Translator.cpp (revision 2600324b57fa31cdea1627d584d314f2a579c4a8)
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 
10 
11 #include "TranslatorRosterPrivate.h"
12 
13 #include <Translator.h>
14 
15 
16 BTranslator::BTranslator()
17 	:
18 	fOwningRoster(NULL),
19 	fID(0),
20 	fRefCount(1)
21 {
22 }
23 
24 
25 BTranslator::~BTranslator()
26 {
27 	if (fOwningRoster != NULL)
28 		fOwningRoster->TranslatorDeleted(fID);
29 }
30 
31 
32 /*!
33 	Increments the refcount and returns a pointer to this object.
34 */
35 BTranslator *BTranslator::Acquire()
36 {
37 	if (atomic_add(&fRefCount, 1) > 0)
38 		return this;
39 
40 	return NULL;
41 }
42 
43 
44 /*!
45 	Decrements the refcount and returns a pointer to this object.
46 	When the refcount hits zero, the object is destroyed. This is
47 	so multiple objects can own the BTranslator and it won't get
48 	deleted until all of them are done with it.
49 
50 	\return NULL, if the object was just deleted
51 */
52 BTranslator *BTranslator::Release()
53 {
54 	int32 oldValue = atomic_add(&fRefCount, -1);
55 	if (oldValue > 0)
56 		return this;
57 
58 	delete this;
59 	return NULL;
60 }
61 
62 
63 int32
64 BTranslator::ReferenceCount()
65 {
66 	return fRefCount;
67 }
68 
69 
70 /*!
71 	This virtual function is for creating a configuration view
72 	for the translator so the user can change its settings.
73 	This method is optional.
74 */
75 status_t
76 BTranslator::MakeConfigurationView(BMessage* ioExtension,
77 	BView** outView, BRect* outExtent)
78 {
79 	return B_ERROR;
80 }
81 
82 
83 /*!
84 	Puts the current configuration for the translator into
85 	ioExtension. This method is optional.
86 */
87 status_t
88 BTranslator::GetConfigurationMessage(BMessage* ioExtension)
89 {
90 	return B_ERROR;
91 }
92 
93 
94 status_t BTranslator::_Reserved_Translator_0(int32 n, void *p) { return B_ERROR; }
95 status_t BTranslator::_Reserved_Translator_1(int32 n, void *p) { return B_ERROR; }
96 status_t BTranslator::_Reserved_Translator_2(int32 n, void *p) { return B_ERROR; }
97 status_t BTranslator::_Reserved_Translator_3(int32 n, void *p) { return B_ERROR; }
98 status_t BTranslator::_Reserved_Translator_4(int32 n, void *p) { return B_ERROR; }
99 status_t BTranslator::_Reserved_Translator_5(int32 n, void *p) { return B_ERROR; }
100 status_t BTranslator::_Reserved_Translator_6(int32 n, void *p) { return B_ERROR; }
101 status_t BTranslator::_Reserved_Translator_7(int32 n, void *p) { return B_ERROR; }
102