C++ main module for emicrom Package  1.0
CORE_ClassFactory.h
Go to the documentation of this file.
1 #ifndef CORE_ClassFactory_H
2 #define CORE_ClassFactory_H
3 
4 
5 #include "CORE_Object.h"
6 #include "CORE_ListPointers.h"
8 
9 
10 
18 class CORE_ClassFactory : public CORE_Object{ // class
19 
20  // THIS Shared pointer definition
22 
23 
24  // ASSOCIATION
25 
28 
29  SV::CORE_ClassFactory mClassFactories;
30 
31  // ATTRIBUTES
32 
33 private:
34 
35 
36  // ASSOCIATIONS
37 
38 
39  // METHODS
40 
41 
42 protected:
43  // CONSTRUCTORS
47 
48 
49 
50 
51  // DESTRUCTORS
55  virtual ~CORE_ClassFactory(void);
56 
57 
58 
59 
60 
61 public:
62  // NEW
66  inline static SP::CORE_ClassFactory New() {
67  SP::CORE_ClassFactory p(new CORE_ClassFactory(),
69  p->setThis(p);
70  return p;
71  }
72 
73  // SET
74 
77  inline void clearClasses() {
78  mRegisteredClasses.clear();
79  mRegisteredConstClasses.clear();
80  };
81 
86  inline void addClass(const tString& key,SP::CORE_Object c) {
87  mRegisteredClasses.put(key,c);
88  };
93  inline void addConstClass(const tString& key,SPC::CORE_Object c) {
94  mRegisteredConstClasses.put(key,c);
95  };
96 
100  inline void addClassFactory(SP::CORE_ClassFactory cf) {
101  mClassFactories.add(cf);
102  }
103 
107  mClassFactories.clear();
108  }
109 
110 
111  // GET
117  inline SP::CORE_Object getClass(const tString& key) {
118  return mRegisteredClasses[key];
119  };
125  inline SPC::CORE_Object getConstClass(const tString& key) {
126  return mRegisteredConstClasses[key];
127  };
128 
129  // OTHERS
136  virtual SP::CORE_Object NewInstance(const tString& name,
137  const SVC::CORE_Object& newParameters) const;
143  virtual SP::CORE_Object NewInstance(const tString& name) const {
144  SVC::CORE_Object args;
145  return NewInstance(name,args);
146  };
147 
148 
149 
150 };
151 
152 #endif
SV::CORE_ClassFactory mClassFactories
Definition: CORE_ClassFactory.h:29
void addClass(const tString &key, SP::CORE_Object c)
add registered class
Definition: CORE_ClassFactory.h:86
SPC::CORE_Object getConstClass(const tString &key)
get the read only registered class with key
Definition: CORE_ClassFactory.h:125
SP::CORE_Object getClass(const tString &key)
get the written registered class with key
Definition: CORE_ClassFactory.h:117
virtual SP::CORE_Object NewInstance(const tString &name) const
create an instance of a class
Definition: CORE_ClassFactory.h:143
void addClassFactory(SP::CORE_ClassFactory cf)
add to class factory
Definition: CORE_ClassFactory.h:100
CORE_SharedPointersVMap< tString, CORE_Object > mRegisteredClasses
Definition: CORE_ClassFactory.h:26
CORE_ClassFactory()
build a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:6
void clearClassFactories()
clear class factories
Definition: CORE_ClassFactory.h:106
DEFINE_SPTR(CORE_ClassFactory)
DEFINE_SVPTR(CORE_ClassFactory)
virtual SP::CORE_Object NewInstance(const tString &name, const SVC::CORE_Object &newParameters) const
create an instance of a class
Definition: CORE_ClassFactory.cpp:15
void addConstClass(const tString &key, SPC::CORE_Object c)
add an unwritten registered class
Definition: CORE_ClassFactory.h:93
CORE_SharedPointersVMap< tString, const CORE_Object > mRegisteredConstClasses
Definition: CORE_ClassFactory.h:27
void clear()
clear the map
Definition: CORE_SharedPointersVMap.h:258
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
virtual ~CORE_ClassFactory(void)
destroy a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:10
void clearClasses()
clear registered classes
Definition: CORE_ClassFactory.h:77
SP_OBJECT(CORE_ClassFactory)
this class describes a class factory to generate classes for User Interface Software ...
Definition: CORE_ClassFactory.h:18
static SP::CORE_ClassFactory New()
create a shared pointer to the class factory
Definition: CORE_ClassFactory.h:66
tBoolean put(const Key &k, const boost::shared_ptr< Value > &v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:192
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141