GNode library (C++)
Loading...
Searching...
No Matches
gnode::Data< T > Class Template Reference

Template class for holding data of a specific type. More...

#include <data.hpp>

Inheritance diagram for gnode::Data< T >:
Collaboration diagram for gnode::Data< T >:

Public Member Functions

template<typename... Args>
 Data (Args &&...args)
 Constructs a Data object with the type name of T and initializes its value.
 
T * get_value_ref ()
 Retrieves a reference to the stored value.
 
voidget_value_ptr () const override
 Retrieves a pointer to the stored value.
 
- Public Member Functions inherited from gnode::BaseData
 BaseData (std::string type)
 Constructs a BaseData object with the specified type.
 
virtual ~BaseData ()=default
 Virtual destructor for BaseData.
 
bool is_same_type (const BaseData &data) const
 Checks if the type of this data matches the type of another BaseData object.
 
std::string get_type () const
 Retrieves the type of the data as a string.
 

Private Attributes

T value {}
 The value of type T stored in this object.
 

Detailed Description

template<typename T>
class gnode::Data< T >

Template class for holding data of a specific type.

The Data class template inherits from BaseData and provides a concrete implementation for storing and accessing data of type T. It allows retrieval of the stored value as a pointer.

Template Parameters
TThe type of data to be stored.

Constructor & Destructor Documentation

◆ Data()

template<typename T >
template<typename... Args>
gnode::Data< T >::Data ( Args &&...  args)
inlineexplicit

Constructs a Data object with the type name of T and initializes its value.

Template Parameters
ArgsTypes of the arguments passed to the T constructor.
Parameters
argsArguments forwarded to the constructor of T to initialize the value.

This constructor initializes the base class BaseData with the type name of T using typeid(T).name(). It then constructs this->value of type T using the forwarded arguments args.

Member Function Documentation

◆ get_value_ptr()

template<typename T >
void * gnode::Data< T >::get_value_ptr ( ) const
inlineoverridevirtual

Retrieves a pointer to the stored value.

Returns
A void pointer to the stored value.

Implements gnode::BaseData.

◆ get_value_ref()

template<typename T >
T * gnode::Data< T >::get_value_ref ( )
inline

Retrieves a reference to the stored value.

Returns
A pointer to the stored value.

Member Data Documentation

◆ value

template<typename T >
T gnode::Data< T >::value {}
private

The value of type T stored in this object.


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