TypeHandlerRoster.h revision fce4895d
1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef TYPE_HANDLER_ROSTER_H
6#define TYPE_HANDLER_ROSTER_H
7
8
9#include <Locker.h>
10#include <ObjectList.h>
11
12
13class Type;
14class TypeHandler;
15class ValueNode;
16class ValueNodeChild;
17
18
19typedef BObjectList<TypeHandler> TypeHandlerList;
20
21
22class TypeHandlerRoster {
23public:
24								TypeHandlerRoster();
25								~TypeHandlerRoster();
26
27	static	TypeHandlerRoster*	Default();
28	static	status_t			CreateDefault();
29	static	void				DeleteDefault();
30
31			status_t			Init();
32			status_t			RegisterDefaultHandlers();
33
34			status_t			FindTypeHandler(ValueNodeChild* nodeChild,
35									Type* type, TypeHandler*& _handler);
36									// returns a reference
37			status_t			CreateValueNode(ValueNodeChild* nodeChild,
38									Type* type, ValueNode*& _node);
39									// returns a reference
40
41			bool				RegisterHandler(TypeHandler* handler);
42			void				UnregisterHandler(TypeHandler* handler);
43
44private:
45			BLocker				fLock;
46			TypeHandlerList		fTypeHandlers;
47	static	TypeHandlerRoster*	sDefaultInstance;
48};
49
50
51#endif	// TYPE_HANDLER_ROSTER_H
52