26 #define MEMORY_STACK_ENABLED
28 #undef MEMORY_STACK_ENABLED
34 #ifdef MEMORY_STACK_ENABLED
66 #ifdef MEMORY_STACK_ENABLED
67 static std::unique_ptr<CORE_MemoryStack<CORE_Object> > mMemoryStack;
72 std::weak_ptr<CORE_Object>
mThis;
132 std::shared_ptr<T>
setThis(std::unique_ptr<T,CORE_Object::Delete>& up) {
133 std::shared_ptr<T>
sp=std::move(up);
145 return std::dynamic_pointer_cast<T>(
mThis.lock());
154 return std::dynamic_pointer_cast<T>(
mThis.lock());
173 #ifdef MEMORY_STACK_ENABLED
174 if (mMemoryStack.get()==
null) {
175 mMemoryStack=std::make_unique<CORE_MemoryStack<CORE_Object> >();
182 #ifdef MEMORY_STACK_ENABLED
183 if (mMemoryStack.get()!=
null) {
184 mMemoryStack.reset();
191 #ifdef MEMORY_STACK_ENABLED
192 return (mMemoryStack.get()!=
null);
201 #ifdef MEMORY_STACK_ENABLED
202 if (mMemoryStack.get()!=
null) {
203 return mMemoryStack->toString();
205 return "memory stack is disabled";
207 return "memory stack is disabled";
215 #ifdef MEMORY_STACK_ENABLED
216 if (mMemoryStack.get()!=
null) {
217 return mMemoryStack->getRegistredClassesNumber();
226 #ifdef MEMORY_STACK_ENABLED
230 return mMemoryStack.get();
272 return (
dynamic_cast<const T*
>(
this)!=NULL);
280 return typeid(*this).name();
303 std::stringstream cstr;
this class describes a class factory to generate classes
Definition: CORE_ClassFactory.h:22
CORE_MemoryStack is the class to register all the created classes to detect not destroyed classes.
Definition: CORE_MemoryStack.h:13
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
void operator()(const CORE_Object *p)
operator to delete the class
Definition: CORE_Object.h:98
abstract base class for most classes.
Definition: CORE_Object.h:48
virtual ~CORE_Object()
destroy the instance of object std
Definition: CORE_Object.cpp:18
std::shared_ptr< T > setThis(std::unique_ptr< T, CORE_Object::Delete > &up)
set the shared pointer from an unique pointer
Definition: CORE_Object.h:132
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: CORE_Object.h:248
std::weak_ptr< CORE_Object > mThis
Definition: CORE_Object.h:72
friend std::ostream & operator<<(std::ostream &out, const CORE_Object &obj)
print the class object
Definition: CORE_Object.h:111
tString getClassName() const
return the name of the class
Definition: CORE_Object.h:279
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
static void DisableMemoryStack()
disable the memory stack
Definition: CORE_Object.h:181
tString getPointerString() const
retrun the pointer of the class as a string
Definition: CORE_Object.h:295
static tBoolean IsMemoryStackEnabled()
return trur if the memory stack is enabled
Definition: CORE_Object.h:190
static tIndex GetRegisteredClassesNumber()
get the memory stack in string
Definition: CORE_Object.h:214
std::shared_ptr< const T > getConstSharedPointer() const
return a const shared pointer for this
Definition: CORE_Object.h:152
std::shared_ptr< T > getSharedPointer()
return the shared pointer for this
Definition: CORE_Object.h:143
static tString MemoryStackToString()
get the memory stack in string
Definition: CORE_Object.h:200
tBoolean isInstanceOf() const
test if the clas T is an instance of this class
Definition: CORE_Object.h:271
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:302
static void EnableMemoryStack()
enable the memory stack
Definition: CORE_Object.h:172
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:314
static tBoolean EnableMemoryStack(const tBoolean &isMemoryChecked)
enable the memory stack
Definition: CORE_Object.h:164
CORE_Object()
build an instance of the object
Definition: CORE_Object.cpp:8
tString pointerToString(const T *ptr)
return the pointer of the class as a string
Definition: functions.h:183
#define tIndex
Definition: types.h:157
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151