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
16BTranslator::BTranslator()
17	:
18	fOwningRoster(NULL),
19	fID(0),
20	fRefCount(1)
21{
22}
23
24
25BTranslator::~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*/
35BTranslator *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*/
52BTranslator *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
63int32
64BTranslator::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*/
75status_t
76BTranslator::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*/
87status_t
88BTranslator::GetConfigurationMessage(BMessage* ioExtension)
89{
90	return B_ERROR;
91}
92
93
94status_t BTranslator::_Reserved_Translator_0(int32 n, void *p) { return B_ERROR; }
95status_t BTranslator::_Reserved_Translator_1(int32 n, void *p) { return B_ERROR; }
96status_t BTranslator::_Reserved_Translator_2(int32 n, void *p) { return B_ERROR; }
97status_t BTranslator::_Reserved_Translator_3(int32 n, void *p) { return B_ERROR; }
98status_t BTranslator::_Reserved_Translator_4(int32 n, void *p) { return B_ERROR; }
99status_t BTranslator::_Reserved_Translator_5(int32 n, void *p) { return B_ERROR; }
100status_t BTranslator::_Reserved_Translator_6(int32 n, void *p) { return B_ERROR; }
101status_t BTranslator::_Reserved_Translator_7(int32 n, void *p) { return B_ERROR; }
102