DEADSOFTWARE

Update handling of multi-byte strings
[odcread.git] / typeregister.h
1 #ifndef _CLASSREGISTER_H_
2 #define _CLASSREGISTER_H_
4 #include <oberon.h>
5 #include <map>
6 #include <string>
8 namespace odc {
9 class Store;
10 class TypeProxyBase; // forward declaration
12 class TypeRegister {
13 static TypeRegister *s_instance;
15 std::map<std::string, TypeProxyBase *> d_map;
17 TypeRegister();
18 TypeRegister(const TypeRegister &other); // NI
19 TypeRegister &operator=(const TypeRegister &other); // NI
21 public:
22 static TypeRegister &getInstance();
24 void add(const std::string &name, TypeProxyBase *proxy);
25 const TypeProxyBase *get(const std::string &name);
26 };
28 class TypeProxyBase {
29 public:
30 TypeProxyBase(const std::string &name);
31 virtual const std::string &getName() const = 0;
32 virtual const std::string *getSuper() const = 0;
33 virtual Store *newInstance(INTEGER id) const = 0;
34 };
36 template <class T> class TypeProxy : public TypeProxyBase {
37 public:
38 TypeProxy(): TypeProxyBase(T::getType()) {}
39 virtual const std::string &getName() const {
40 return T::getType();
41 }
42 virtual const std::string *getSuper() const {
43 return T::getSuper();
44 }
45 virtual Store *newInstance(INTEGER id) const {
46 return new T(id);
47 }
48 };
49 }
51 #endif // _CLASSREGISTER_H_