C++ main module for gpm 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 
17 
18 class CORE_ClassFactory : public CORE_Object{ // class
19 
20  // THIS Shared pointer definition
21  SP_OBJECT(CORE_ClassFactory);
22 
23 
24  // ASSOCIATION
25 
28 
29 
30  // ATTRIBUTES
31 
32 private:
33 
34 
35  // ASSOCIATIONS
36 
37 
38  // METHODS
39 
40 
41 protected:
42  // CONSTRUCTORS
46 
47 
48 
49 
50  // DESTRUCTORS
54  virtual ~CORE_ClassFactory(void);
55 
56 
57 
58 
59 
60 public:
61  // NEW
62  inline static SP::CORE_ClassFactory New() {
63  SP::CORE_ClassFactory p(new CORE_ClassFactory(),
65  p->setThis(p);
66  return p;
67  }
68 
69  // SET
70 
73  inline void clearClasses() {
74  mRegisteredClasses.clear();
75  mRegisteredConstClasses.clear();
76  };
77 
80  inline void addClass(const tString& key,SP::CORE_Object c) {
81  mRegisteredClasses.put(key,c);
82  };
85  inline void addConstClass(const tString& key,SPC::CORE_Object c) {
86  mRegisteredConstClasses.put(key,c);
87  };
88 
89 
90 
91  // GET
94  inline SP::CORE_Object getClass(const tString& key) {
95  return mRegisteredClasses[key];
96  };
99  inline SPC::CORE_Object getConstClass(const tString& key) {
100  return mRegisteredConstClasses[key];
101  };
102 
103  // OTHERS
106  virtual SP::CORE_Object NewInstance(const tString& name,
107  const SVC::CORE_Object& newParameters) const;
108 
111  virtual SP::CORE_Object NewInstance(const tString& name) const {
112  SVC::CORE_Object args;
113  return NewInstance(name,args);
114  };
115 
116 
117 
118 };
119 
120 #endif
void addClass(const tString &key, SP::CORE_Object c)
add registered class
Definition: CORE_ClassFactory.h:80
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
SPC::CORE_Object getConstClass(const tString &key)
get the registered class with key
Definition: CORE_ClassFactory.h:99
SP::CORE_Object getClass(const tString &key)
get the registered class with key
Definition: CORE_ClassFactory.h:94
virtual SP::CORE_Object NewInstance(const tString &name) const
create an instance of a class
Definition: CORE_ClassFactory.h:111
CORE_ClassFactory()
build a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:6
DEFINE_SPTR(CORE_ClassFactory)
void addConstClass(const tString &key, SPC::CORE_Object c)
add registered class
Definition: CORE_ClassFactory.h:85
void clear()
clear the map
Definition: CORE_SharedPointersVMap.h:253
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:36
virtual ~CORE_ClassFactory(void)
destroy a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:10
void clearClasses()
clear registered classes
Definition: CORE_ClassFactory.h:73
this class describes a class factory to generate classes for User Interface Software ...
Definition: CORE_ClassFactory.h:18
static SP::CORE_ClassFactory New()
Definition: CORE_ClassFactory.h:62
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:106