1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2018, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6#ifndef TYPE_HANDLER_ROSTER_H 7#define TYPE_HANDLER_ROSTER_H 8 9 10#include <Locker.h> 11#include <ObjectList.h> 12 13 14class Type; 15class TypeHandler; 16class ValueNode; 17class ValueNodeChild; 18 19 20typedef BObjectList<TypeHandler> TypeHandlerList; 21 22 23class TypeHandlerRoster { 24public: 25 TypeHandlerRoster(); 26 ~TypeHandlerRoster(); 27 28 static TypeHandlerRoster* Default(); 29 static status_t CreateDefault(); 30 static void DeleteDefault(); 31 32 status_t Init(); 33 status_t RegisterDefaultHandlers(); 34 35 int32 CountTypeHandlers(Type* type); 36 status_t FindBestTypeHandler(ValueNodeChild* nodeChild, 37 Type* type, TypeHandler*& _handler); 38 // returns a reference 39 status_t FindTypeHandlers(ValueNodeChild* nodeChild, 40 Type* type, TypeHandlerList*& _handlers); 41 // returns list of references 42 status_t CreateValueNode(ValueNodeChild* nodeChild, 43 Type* type, TypeHandler* handler, 44 ValueNode*& _node); 45 // handler can be null if automatic 46 // search is desired. 47 // returns a reference 48 49 bool RegisterHandler(TypeHandler* handler); 50 void UnregisterHandler(TypeHandler* handler); 51 52private: 53 BLocker fLock; 54 TypeHandlerList fTypeHandlers; 55 static TypeHandlerRoster* sDefaultInstance; 56}; 57 58 59#endif // TYPE_HANDLER_ROSTER_H 60