1 #ifndef CORE_ClassFactory_H
2 #define CORE_ClassFactory_H
85 [&](
const auto& cf) {mem+=cf->getMemorySize();});
128 const std::map<tString,tString>& arguments)
const;
136 std::map<tString,tString> arguments;
149 const std::map<tString,tString>& arguments)
const {
150 return sp::dynamic_upointer_cast<T>(
NewInstance(name,arguments));
160 std::map<tString,tString> nullArguments;
161 return sp::dynamic_upointer_cast<T>(
NewInstance(name,nullArguments));
173 const std::map<tString,tString>& arguments)
const {
175 return up->setThis(up);
184 std::map<tString,tString> nullArguments;
186 return up->setThis(up);
194 std::map<tString,tString> nullArguments;
195 return NewSharedInstance<T>(nullArguments);
204 std::map<tString,tString> nullArguments;
206 return up->setThis(up);
215 if (up.get()==
null) {
219 return up->setThis(up);
227 return up->setThis(up);
236 std::stringstream ret;
238 std::vector<CORE_UniquePointer<CORE_ClassFactory> >::const_iterator iter=
mFactoryClasses.begin();
239 std::vector<CORE_UniquePointer<CORE_ClassFactory> >::const_iterator iterE=
mFactoryClasses.end();
240 while (iter!=iterE) {
242 ret<<
"\t"<<(*iter)->getIdentityString()<<
"\n";
this class describes a class factory to generate classes
Definition: CORE_ClassFactory.h:22
CORE_SharedPointer< T > NewSharedInstance(const std::map< tString, tString > &arguments) const
create a shared instance of a class with same type as T
Definition: CORE_ClassFactory.h:203
std::vector< CORE_UniquePointer< CORE_ClassFactory > > mFactoryClasses
Definition: CORE_ClassFactory.h:37
CORE_ClassFactory()
build a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:9
virtual CORE_UniquePointer< CORE_Object > NewInstance(const tString &name, const std::map< tString, tString > &arguments) const
create an unique instance of a class as a general CORE_Object
Definition: CORE_ClassFactory.cpp:16
CORE_UniquePointer< T > NewUniqueInstance(const tString &name, const std::map< tString, tString > &arguments) const
create an unique instance of a class T
Definition: CORE_ClassFactory.h:148
CORE_SharedPointer< T > NewSharedInstance(const tString &name, const std::map< tString, tString > &arguments) const
create a shared instance of a class
Definition: CORE_ClassFactory.h:172
virtual ~CORE_ClassFactory(void)
destroy a CORE_ClassFactory
Definition: CORE_ClassFactory.cpp:13
static CORE_SharedPointer< T > NewSharedInstance(CORE_UniquePointer< T > &up)
create a shared instance of an unique pointer
Definition: CORE_ClassFactory.h:214
CORE_SharedPointer< T > NewSharedInstance() const
create a shared instance of a class with same type as T with no argument
Definition: CORE_ClassFactory.h:193
virtual tMemSize getContentsMemorySize() const override
return the memory size in byte
Definition: CORE_ClassFactory.h:82
CORE_UniquePointer< T > NewUniqueInstance(const tString &name) const
create an unique instance of a class T with no arguments
Definition: CORE_ClassFactory.h:159
static CORE_UniquePointer< CORE_ClassFactory > New()
build a new instance of default class factory
Definition: CORE_ClassFactory.h:114
CORE_UniquePointer< CORE_Object > NewInstance(const tString &name) const
create an unique instance of a class as a general CORE_Object
Definition: CORE_ClassFactory.h:135
static CORE_SharedPointer< T > NewSharedInstance(CORE_UniquePointer< T > &&up)
create a shared instance of an unique pointer as a lvalue
Definition: CORE_ClassFactory.h:226
virtual tMemSize getMemorySize() const override
return the memory size of the class and the memory size of all its attributes/associations
Definition: CORE_ClassFactory.h:70
void clearClassFactories()
clear the class factories list
Definition: CORE_ClassFactory.h:103
virtual tString toString() const override
get the string representation of the class
Definition: CORE_ClassFactory.h:234
CORE_SharedPointer< T > NewSharedInstance(const tString &name) const
create a shared instance of a class with no argument
Definition: CORE_ClassFactory.h:183
void addClassFactory(CORE_UniquePointer< CORE_ClassFactory > child)
add to class factory
Definition: CORE_ClassFactory.h:95
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
abstract base class for most classes.
Definition: CORE_Object.h:48
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:302
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
typename std::shared_ptr< T > CORE_SharedPointer
Definition: sp.h:13
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166