NDEVR
API Documentation
VariableReference

An optimized class for storing a reference to a variable of some type up to 8 bytes in size without ownership or allocations on the stack. More...

Public Member Functions

 VariableReference (const VariableReference &reference)
 Copy constructor.
template<class t_type>
constexpr VariableReference (t_type &value)
 Constructs a VariableReference from a typed variable, storing a pointer to the variable and populating type metadata.
template<class t_object_type>
void fillInfoTable (const ObjectInfo< t_object_type > &, uint01 level)
 Recursively populates the type info table for the referenced variable, descending into Vector sub-types as needed.
template<class t_type>
t_type get () const
 Retrieves the referenced value converted to the requested type.
template<class t_type>
void get (t_type &value, uint04 level, uint04 index) const
 Retrieves the referenced value into an output variable, using the type hierarchy level and element index.
template<class t_type>
void getSingle (t_type &value, uint04 level, uint04 index) const
 Reads a single scalar value from the referenced memory by interpreting the raw pointer according to the stored type metadata at the given hierarchy level and index.
template<class t_type>
constexpr operator t_type () const
 Implicit conversion operator.
template<class t_type>
constexpr bool operator!= (const t_type &b) const
 Inequality operator.
template<class t_type>
constexpr VariableReferenceoperator= (const t_type &b)
 Assignment operator.
constexpr VariableReferenceoperator= (const VariableReference &)
 Copy assignment operator.
template<class t_type>
constexpr bool operator== (const t_type &b) const
 Equality operator.
template<class t_type>
constexpr void set (const t_type &value)
 Sets the referenced variable to the given value.

Detailed Description

An optimized class for storing a reference to a variable of some type up to 8 bytes in size without ownership or allocations on the stack.


Definition at line 118 of file VariableReference.h.

Constructor & Destructor Documentation

◆ VariableReference() [1/2]

template<class t_type>
VariableReference::VariableReference ( t_type & value)
inlineconstexpr

Constructs a VariableReference from a typed variable, storing a pointer to the variable and populating type metadata.

Parameters
[in]valueThe variable to reference.

Definition at line 150 of file VariableReference.h.

References fillInfoTable().

Referenced by VariableReference(), operator=(), and operator=().

◆ VariableReference() [2/2]

VariableReference::VariableReference ( const VariableReference & reference)
inline

Copy constructor.

Creates a VariableReference pointing to the same memory with identical type metadata.

Parameters
[in]referenceThe VariableReference to copy from.

Definition at line 174 of file VariableReference.h.

References VariableReference().

Member Function Documentation

◆ fillInfoTable()

template<class t_object_type>
void VariableReference::fillInfoTable ( const ObjectInfo< t_object_type > & ,
uint01 level )
inline

Recursively populates the type info table for the referenced variable, descending into Vector sub-types as needed.

Parameters
[in]levelThe current depth in the type hierarchy.

Definition at line 161 of file VariableReference.h.

References fillInfoTable(), and GetTypeInfo().

Referenced by VariableReference(), and fillInfoTable().

◆ get() [1/2]

template<class t_type>
t_type VariableReference::get ( ) const
inline

Retrieves the referenced value converted to the requested type.

Returns
The referenced value as the requested type.

Definition at line 242 of file VariableReference.h.

References get().

Referenced by get(), operator t_type(), operator!=(), and operator==().

◆ get() [2/2]

template<class t_type>
void VariableReference::get ( t_type & value,
uint04 level,
uint04 index ) const
inline

Retrieves the referenced value into an output variable, using the type hierarchy level and element index.

Parameters
[in]valueThe output variable to populate.
[in]levelThe depth in the type hierarchy to read from.
[in]indexThe element index within the current level.

Definition at line 255 of file VariableReference.h.

References getSingle().

◆ getSingle()

template<class t_type>
void VariableReference::getSingle ( t_type & value,
uint04 level,
uint04 index ) const
inline

Reads a single scalar value from the referenced memory by interpreting the raw pointer according to the stored type metadata at the given hierarchy level and index.

Parameters
[in]valueThe output variable to populate with the read value.
[in]levelThe depth in the type hierarchy to read from.
[in]indexThe element offset from the base pointer.

Definition at line 270 of file VariableReference.h.

References assign().

Referenced by get().

◆ operator t_type()

template<class t_type>
VariableReference::operator t_type ( ) const
inlineconstexpr

Implicit conversion operator.

Retrieves the referenced value as the requested type.

Returns
The referenced value converted to the requested type.

Definition at line 233 of file VariableReference.h.

References get().

◆ operator!=()

template<class t_type>
bool VariableReference::operator!= ( const t_type & b) const
inlineconstexpr

Inequality operator.

Compares the referenced value against the given value.

Parameters
[in]bThe value to compare against.
Returns
True if the referenced value does not equal b.

Definition at line 224 of file VariableReference.h.

References get().

◆ operator=() [1/2]

template<class t_type>
VariableReference & VariableReference::operator= ( const t_type & b)
inlineconstexpr

Assignment operator.

Sets the referenced variable to the given value.

Parameters
[in]bThe value to assign.
Returns
A reference to this VariableReference.

Definition at line 195 of file VariableReference.h.

References VariableReference().

◆ operator=() [2/2]

VariableReference & VariableReference::operator= ( const VariableReference & )
inlineconstexpr

Copy assignment operator.

Does not reassign the internal pointer.

Returns
A reference to this VariableReference.

Definition at line 204 of file VariableReference.h.

References VariableReference().

◆ operator==()

template<class t_type>
bool VariableReference::operator== ( const t_type & b) const
inlineconstexpr

Equality operator.

Compares the referenced value against the given value.

Parameters
[in]bThe value to compare against.
Returns
True if the referenced value equals b.

Definition at line 214 of file VariableReference.h.

References get().

◆ set()

template<class t_type>
void VariableReference::set ( const t_type & value)
inlineconstexpr

Sets the referenced variable to the given value.

Parameters
[in]valueThe value to assign to the referenced variable.

Definition at line 185 of file VariableReference.h.


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