MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
GenericPointer< T > Class Template Reference

class containing a generic pointer More...

#include <genericobject.h>

Inheritance diagram for GenericPointer< T >:
[legend]
Collaboration diagram for GenericPointer< T >:
[legend]

Public Member Functions

 GenericPointer (T *const &t, MString oName, MLong size, MString function, MBool isArray, MBool isNewObject=true)
 
T * getObjectPointer ()
 
 ~GenericPointer ()
 
- Public Member Functions inherited from GenericObject
MStringgetName ()
 
MStringgetCallingFunction ()
 
MIntgetObjectId ()
 
MLonggetElementSize ()
 
virtual ~GenericObject ()
 
MBool operator< (GenericObject otherObject)
 

Public Attributes

MBool objectIsArray
 
- Public Attributes inherited from GenericObject
MString objectName
 
MString callingFunction
 
MInt objectId
 
MLong elementSize
 

Private Attributes

T * objectPointer
 

Additional Inherited Members

- Static Public Attributes inherited from GenericObject
static MInt objectCounter = 0
 Variables to initialize: More...
 

Detailed Description

template<typename T>
class GenericPointer< T >
Author
Lennart Schneiders
Date
08.12.2011

Definition at line 60 of file genericobject.h.

Constructor & Destructor Documentation

◆ GenericPointer()

template<typename T >
GenericPointer< T >::GenericPointer ( T *const &  t,
MString  oName,
MLong  size,
MString  function,
MBool  isArray,
MBool  isNewObject = true 
)

Definition at line 72 of file genericobject.h.

79 : objectPointer(t), objectIsArray(isArray) {
80 using namespace maia::alloc;
81 objectName = oName;
82#ifdef MAIA_EXTRA_DEBUG
83 callingFunction = function;
84#endif
85 elementSize = size;
86 if(isNewObject) {
89 } else
91 g_allocatedBytes += size;
92 g_maxAllocatedBytes = mMax(g_allocatedBytes, g_maxAllocatedBytes);
93}
MString callingFunction
Definition: genericobject.h:42
MString objectName
Definition: genericobject.h:39
static MInt objectCounter
Variables to initialize:
Definition: genericobject.h:45
constexpr T mMax(const T &x, const T &y)
Definition: functions.h:94
MLong g_allocatedBytes
MLong g_maxAllocatedBytes

◆ ~GenericPointer()

template<class T >
GenericPointer< T >::~GenericPointer

Definition at line 96 of file genericobject.h.

96 {
98#ifdef MAIA_EXTRA_DEBUG
99 m_log.precision(2);
100 m_log << "deleting object " << objectName << " (size: " << getMemorySize(elementSize)
101 << ", address: " << objectPointer << ", type: " << typeid(objectPointer).name()
102 << ", isArray: " << objectIsArray << ", called by " << callingFunction << ")...";
103 m_log.flush();
104#endif
105 if(objectPointer) {
106 if(objectIsArray)
107 delete[] objectPointer;
108 else
109 delete objectPointer;
110 objectPointer = nullptr;
111 }
112#ifdef MAIA_EXTRA_DEBUG
113 m_log << "ok" << std::endl;
114#endif
115}
MString getMemorySize(MLong noBytes)
Returns memory size in KB, MB or GB.
InfoOutFile m_log

Member Function Documentation

◆ getObjectPointer()

template<typename T >
T * GenericPointer< T >::getObjectPointer ( )
inline

Definition at line 67 of file genericobject.h.

67{ return objectPointer; }

Member Data Documentation

◆ objectIsArray

template<typename T >
MBool GenericPointer< T >::objectIsArray

Definition at line 65 of file genericobject.h.

◆ objectPointer

template<typename T >
T* GenericPointer< T >::objectPointer
private

Definition at line 62 of file genericobject.h.


The documentation for this class was generated from the following file: