29 #ifndef CREGISTEREDDYNAMICTYPES_HPP_
30 #define CREGISTEREDDYNAMICTYPES_HPP_
32 #include <sutil/CMappedList.hpp>
33 #include <sutil/CSingleton.hpp>
80 template <
typename Idx>
94 private CSingleton<CMappedPointerList<Idx,CDynamicTypeBase<Idx>,true> >
107 if(NULL == mapped_type)
120 if(NULL == mapped_type)
123 std::cerr<<
"\nCRegisteredDynamicTypes::getObjectForType() Error :"
124 <<
" The passed type has not been registered.";
129 if(NULL != ret_object)
132 std::cerr<<
"\nCRegisteredDynamicTypes::getObjectForType() Error :"
133 <<
" The passed void* pointer is not NULL.";
139 if(NULL == *mapped_type)
142 std::cerr<<
"\nCRegisteredDynamicTypes::getObjectForType() Error :"
143 <<
" The typemap is corrupted. A type creator object pointer is NULL.";
149 ret_object = (*mapped_type)->createObject();
150 if(NULL == ret_object)
153 std::cerr<<
"\nCRegisteredDynamicTypes::getObjectForType() Error :"
154 <<
" The type object's createObject() function did not work.";
175 std::cerr<<
"\nCRegisteredDynamicTypes::registerType() Warning :"
176 <<
" The passed type is already registered.";
185 std::cerr<<
"\nCRegisteredDynamicTypes::registerType() Error :"
186 <<
" Failed to create type in the type mapped list.";
207 template <
typename Idx>
208 class CDynamicTypeBase
241 template <
typename Idx,
typename Type>
257 Type* obj =
new Type();
258 return reinterpret_cast<void*
>(obj);
269 std::cerr<<
"\nCDynamicType::registerType() Warning :"
270 <<
" This object's type has already been registered.";
276 CDynamicType<Idx,Type>* obj =
new CDynamicType<Idx,Type>(
277 CDynamicTypeBase<Idx>::type_name_);
278 flag = CDynamicTypeBase<Idx>::registerMyType(obj);
282 std::cerr<<
"\nCDynamicType::registerType() Error :"
283 <<
" This object's type could not be registered.";
Definition: CRegisteredDynamicTypes.hpp:42
virtual void * createObject()=0
CRegisteredDynamicTypes()
Definition: CRegisteredDynamicTypes.hpp:242
CDynamicTypeBase(const Idx &arg_type_name)
Definition: CRegisteredDynamicTypes.hpp:212
Definition: CRegisteredDynamicTypes.hpp:81
CDynamicTypeBase & operator=(const CDynamicTypeBase &)
Definition: CSingleton.hpp:47
virtual void * createObject()
Definition: CRegisteredDynamicTypes.hpp:255
Idx type_name_
Definition: CRegisteredDynamicTypes.hpp:228
virtual ~CDynamicType()
Definition: CRegisteredDynamicTypes.hpp:251
virtual T * at(const std::size_t arg_idx)
Definition: CMappedList.hpp:832
static bool registerType(const Idx &arg_type_name, CDynamicTypeBase< Idx > *arg_type_object)
Definition: CRegisteredDynamicTypes.hpp:169
static CMappedPointerList< Idx, CDynamicTypeBase< Idx >, true > * getData()
static bool resetDynamicTypes()
Definition: CRegisteredDynamicTypes.hpp:163
CDynamicType & operator=(const CDynamicType &)
static bool typeRegistered(const Idx &arg_type_name)
Definition: CRegisteredDynamicTypes.hpp:103
virtual ~CDynamicTypeBase()
Definition: CRegisteredDynamicTypes.hpp:215
virtual T * create(const Idx &arg_idx, const bool insert_at_start=true)
Definition: CMappedList.hpp:714
static bool getObjectForType(const Idx &arg_type_name, void *&ret_object)
Definition: CRegisteredDynamicTypes.hpp:115
CDynamicType(const Idx &arg_type_name)
Definition: CRegisteredDynamicTypes.hpp:246
CRegisteredDynamicTypes & operator=(const CRegisteredDynamicTypes &)