Devel Lib
Devel::CObjectData Class Reference

A class for representing and handling data of an arbitrary type. More...

#include <ObjectData.h>

Public Member Functions

 CObjectData ()=default
 Default constructor.
 
 CObjectData (const CObjectData &i_oObjectData)
 Copy constructor. More...
 
virtual ~CObjectData ()=default
 Default virtual destructor.
 
template<typename T = void>
T * construct ()
 Constructs an object of a specific type. More...
 
template<typename T = void>
std::shared_ptr< T > constructShared ()
 Constructs an object of a specific type. More...
 
template<typename T = void>
void deconstruct (T *i_tData)
 Deconstructs an object of a specific type. More...
 
Constructor constructor () const
 Getter for m_fnClassConstructor. More...
 
ConstructorShared constructorShared () const
 Getter for m_fnClassConstructorShared. More...
 
Deconstructor deconstructor () const
 Getter for m_fnClassDeconstructor. More...
 
size_t size () const
 Getter for m_nClassSize. More...
 
bool hasVirtual () const
 Getter for m_fHasVirtual. More...
 

Static Public Member Functions

template<typename T >
static CObjectData get ()
 Static function for creating CObjectData for a specific type. More...
 

Detailed Description

A class for representing and handling data of an arbitrary type.

This class encapsulates generic objects by providing constructors, destructors, and meta data extraction functionalities for an arbitrary type.

Example

This class must be used with the template type being the type you are working with.

class CExampleClass {};
Devel::CObjectData data = Devel::CObjectData::get<CExampleClass>(); // Creating CObjectData for CExampleClass
// Create an instance of CExampleClass using construct function
CExampleClass* example = data.construct<CExampleClass>();
// Create a shared_ptr instance of CExampleClass using constructShared function
std::shared_ptr<CExampleClass> sharedExample = data.constructShared<CExampleClass>();
// Destroy the instance of CExampleClass using deconstruct function
data.deconstruct<CExampleClass>(example);
// You can also get meta data
size_t classSize = data.size();
bool hasVirtualDestructor = data.hasVirtual();
A class for representing and handling data of an arbitrary type.
Definition: ObjectData.h:37
bool hasVirtual() const
Getter for m_fHasVirtual.
Definition: ObjectData.h:159
size_t size() const
Getter for m_nClassSize.
Definition: ObjectData.h:152
std::shared_ptr< T > constructShared()
Constructs an object of a specific type.
Definition: ObjectData.h:111
void deconstruct(T *i_tData)
Deconstructs an object of a specific type.
Definition: ObjectData.h:121
T * construct()
Constructs an object of a specific type.
Definition: ObjectData.h:102

Constructor & Destructor Documentation

◆ CObjectData()

Devel::CObjectData::CObjectData ( const CObjectData i_oObjectData)
inline

Copy constructor.

Parameters
i_oObjectData- Object to copy from.

Member Function Documentation

◆ construct()

template<typename T = void>
T* Devel::CObjectData::construct ( )
inline

Constructs an object of a specific type.

Template Parameters
T- The type of object to construct.
Returns
A raw pointer to the constructed object.

◆ constructor()

Constructor Devel::CObjectData::constructor ( ) const
inline

Getter for m_fnClassConstructor.

Returns
The constructor function of the class.

◆ constructorShared()

ConstructorShared Devel::CObjectData::constructorShared ( ) const
inline

Getter for m_fnClassConstructorShared.

Returns
The shared constructor function of the class.

◆ constructShared()

template<typename T = void>
std::shared_ptr<T> Devel::CObjectData::constructShared ( )
inline

Constructs an object of a specific type.

Template Parameters
T- The type of object to construct.
Returns
A shared pointer to the constructed object.

◆ deconstruct()

template<typename T = void>
void Devel::CObjectData::deconstruct ( T *  i_tData)
inline

Deconstructs an object of a specific type.

Template Parameters
T- The type of the object to deconstruct.
Parameters
i_tData- Pointer to the object to deconstruct.

◆ deconstructor()

Deconstructor Devel::CObjectData::deconstructor ( ) const
inline

Getter for m_fnClassDeconstructor.

Returns
The deconstructor function of the class.

◆ get()

template<typename T >
static CObjectData Devel::CObjectData::get ( )
inlinestatic

Static function for creating CObjectData for a specific type.

Template Parameters
T- The type for which the CObjectData is to be created.
Returns
CObjectData instance corresponding to the given type.

◆ hasVirtual()

bool Devel::CObjectData::hasVirtual ( ) const
inline

Getter for m_fHasVirtual.

Returns
Whether the class has virtual functions.

◆ size()

size_t Devel::CObjectData::size ( ) const
inline

Getter for m_nClassSize.

Returns
The size of the class.

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