1/* 2 * Copyright 2002-2015, 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} 28 29 30/*! 31 Increments the refcount and returns a pointer to this object. 32*/ 33BTranslator *BTranslator::Acquire() 34{ 35 if (atomic_add(&fRefCount, 1) > 0) 36 return this; 37 38 return NULL; 39} 40 41 42/*! 43 Decrements the refcount and returns a pointer to this object. 44 When the refcount hits zero, the object is destroyed. This is 45 so multiple objects can own the BTranslator and it won't get 46 deleted until all of them are done with it. 47 48 \return NULL, if the object was just deleted 49*/ 50BTranslator *BTranslator::Release() 51{ 52 int32 oldValue = atomic_add(&fRefCount, -1); 53 if (oldValue > 1) 54 return this; 55 56 if (fOwningRoster == NULL) { 57 delete this; 58 return NULL; 59 } 60 61 // If we have ever been part of a roster, notify the roster to delete us 62 // and unload our image in a thread-safe way 63 BMessage deleteRequest(B_DELETE_TRANSLATOR); 64 65 deleteRequest.AddPointer("ptr", this); 66 deleteRequest.AddInt32("id", fID); 67 68 BMessenger sender(fOwningRoster); 69 sender.SendMessage(&deleteRequest); 70 71 return NULL; 72} 73 74 75int32 76BTranslator::ReferenceCount() 77{ 78 return fRefCount; 79} 80 81 82/*! 83 This virtual function is for creating a configuration view 84 for the translator so the user can change its settings. 85 This method is optional. 86*/ 87status_t 88BTranslator::MakeConfigurationView(BMessage* ioExtension, 89 BView** outView, BRect* outExtent) 90{ 91 return B_ERROR; 92} 93 94 95/*! 96 Puts the current configuration for the translator into 97 ioExtension. This method is optional. 98*/ 99status_t 100BTranslator::GetConfigurationMessage(BMessage* ioExtension) 101{ 102 return B_ERROR; 103} 104 105 106status_t BTranslator::_Reserved_Translator_0(int32 n, void *p) { return B_ERROR; } 107status_t BTranslator::_Reserved_Translator_1(int32 n, void *p) { return B_ERROR; } 108status_t BTranslator::_Reserved_Translator_2(int32 n, void *p) { return B_ERROR; } 109status_t BTranslator::_Reserved_Translator_3(int32 n, void *p) { return B_ERROR; } 110status_t BTranslator::_Reserved_Translator_4(int32 n, void *p) { return B_ERROR; } 111status_t BTranslator::_Reserved_Translator_5(int32 n, void *p) { return B_ERROR; } 112status_t BTranslator::_Reserved_Translator_6(int32 n, void *p) { return B_ERROR; } 113status_t BTranslator::_Reserved_Translator_7(int32 n, void *p) { return B_ERROR; } 114