28 #include "functions_type.h"
31 #include "CORE_Exception.h"
34 #include "CORE_Constants.h"
37 #include "CORE_Profiler.h"
41 #define MEMORY_STACK_ENABLED
43 #undef MEMORY_STACK_ENABLED
50 #ifdef MEMORY_STACK_ENABLED
51 #include "CORE_MemoryStack.h"
85 #ifdef MEMORY_STACK_ENABLED
86 static std::unique_ptr<CORE_MemoryStack<CORE_Object> > mMemoryStack;
91 std::weak_ptr<CORE_Object> mThis;
151 std::shared_ptr<T> setThis(std::unique_ptr<T,CORE_Object::Delete>& up) {
152 std::shared_ptr<T> sp=std::move(up);
164 return std::dynamic_pointer_cast<T>(mThis.lock());
173 return std::dynamic_pointer_cast<T>(mThis.lock());
192 #ifdef MEMORY_STACK_ENABLED
193 if (mMemoryStack.get()==
null) {
194 mMemoryStack=std::make_unique<CORE_MemoryStack<CORE_Object> >();
201 #ifdef MEMORY_STACK_ENABLED
202 if (mMemoryStack.get()!=
null) {
203 mMemoryStack.reset();
210 #ifdef MEMORY_STACK_ENABLED
211 return (mMemoryStack.get()!=
null);
220 #ifdef MEMORY_STACK_ENABLED
221 if (mMemoryStack.get()!=
null) {
222 return mMemoryStack->toString();
224 return "memory stack is disabled";
226 return "memory stack is disabled";
234 #ifdef MEMORY_STACK_ENABLED
235 if (mMemoryStack.get()!=
null) {
236 return mMemoryStack->getRegistredClassesNumber();
245 #ifdef MEMORY_STACK_ENABLED
249 return mMemoryStack.get();
291 return (
dynamic_cast<const T*
>(
this)!=NULL);
299 return typeid(*this).name();
315 return functions_type::pointerToString(
this);
322 std::stringstream cstr;
325 cstr<<functions_type::pointerToString(
this);
this class describes a class factory to generate classes
Definition: CORE_ClassFactory.h:24
CORE_MemoryStack is the class to register all the created classes to detect not destroyed classes.
Definition: CORE_MemoryStack.h:14
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
void operator()(const CORE_Object *p)
operator to delete the class
Definition: CORE_Object.h:117
abstract base class for most classes.
Definition: CORE_Object.h:65
virtual ~CORE_Object()
destroy the instance of object std
Definition: CORE_Object.cpp:19
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: CORE_Object.h:267
friend std::ostream & operator<<(std::ostream &out, const CORE_Object &obj)
print the class object
Definition: CORE_Object.h:130
tString getClassName() const
return the name of the class
Definition: CORE_Object.h:298
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
static void DisableMemoryStack()
disable the memory stack
Definition: CORE_Object.h:200
tString getPointerString() const
retrun the pointer of the class as a string
Definition: CORE_Object.h:314
static tBoolean IsMemoryStackEnabled()
return trur if the memory stack is enabled
Definition: CORE_Object.h:209
static tIndex GetRegisteredClassesNumber()
get the memory stack in string
Definition: CORE_Object.h:233
std::shared_ptr< const T > getConstSharedPointer() const
return a const shared pointer for this
Definition: CORE_Object.h:171
std::shared_ptr< T > getSharedPointer()
return the shared pointer for this
Definition: CORE_Object.h:162
static tString MemoryStackToString()
get the memory stack in string
Definition: CORE_Object.h:219
tBoolean isInstanceOf() const
test if the clas T is an instance of this class
Definition: CORE_Object.h:290
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:321
static void EnableMemoryStack()
enable the memory stack
Definition: CORE_Object.h:191
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:333
static tBoolean EnableMemoryStack(const tBoolean &isMemoryChecked)
enable the memory stack
Definition: CORE_Object.h:183
CORE_Object()
build an instance of the object
Definition: CORE_Object.cpp:9