palimpsest v3.0.0
Loading...
Searching...
No Matches
palimpsest::Value Class Reference

Internal wrapper around an object and its type information. More...

#include <Value.h>

Public Member Functions

 Value ()=default
 Default constructor. More...
 
 Value (const Value &other)
 Copy constructor. More...
 
Valueoperator= (const Value &other)
 Copy assignment operator. More...
 
 Value (Value &&)=default
 Default move constructor. More...
 
Valueoperator= (Value &&)=default
 Default move assignment operator. More...
 
 ~Value ()
 Destruct the object and free the internal buffer. More...
 
template<typename T >
void allocate ()
 Allocate the internal buffer. More...
 
void deserialize (mpack_node_t node)
 Update value from an MPack node. More...
 
void print (std::ostream &stream) const
 Print value to an output stream;. More...
 
void serialize (mpack::Writer &writer) const
 Serialize value to a MessagePack writer. More...
 
template<typename T , typename... ArgsT>
T & setup ()
 Allocate object and register internal functions. More...
 
template<typename T >
T & get_reference () const
 Cast value to its object's type after checking that it matches T. More...
 

Public Attributes

std::unique_ptr< uint8_t[]> buffer = nullptr
 Internal buffer that holds the actual object. More...
 
const char *(* type_name )()
 Function returning the name of the object's type. More...
 
bool(* same )(std::size_t)
 Function that checks if a given type matches the object's type. More...
 

Detailed Description

Internal wrapper around an object and its type information.

Note
Values are move-only.

Definition at line 38 of file Value.h.

Constructor & Destructor Documentation

◆ Value() [1/3]

palimpsest::Value::Value ( )
default

Default constructor.

◆ Value() [2/3]

palimpsest::Value::Value ( const Value other)
inline

Copy constructor.

Definition at line 44 of file Value.h.

◆ Value() [3/3]

palimpsest::Value::Value ( Value &&  )
default

Default move constructor.

◆ ~Value()

palimpsest::Value::~Value ( )
inline

Destruct the object and free the internal buffer.

Definition at line 74 of file Value.h.

Member Function Documentation

◆ allocate()

template<typename T >
void palimpsest::Value::allocate ( )
inline

Allocate the internal buffer.

Definition at line 82 of file Value.h.

◆ deserialize()

void palimpsest::Value::deserialize ( mpack_node_t  node)
inline

Update value from an MPack node.

Parameters
[in]nodeMPack tree node.
Exceptions
TypeErrorif the deserialized type does not match.

Definition at line 92 of file Value.h.

◆ get_reference()

template<typename T >
T & palimpsest::Value::get_reference ( ) const
inline

Cast value to its object's type after checking that it matches T.

Returns
Reference to the stored value with type T.
Exceptions
TypeErrorif the object's type does not match T.

Definition at line 155 of file Value.h.

◆ operator=() [1/2]

Value & palimpsest::Value::operator= ( const Value other)
inline

Copy assignment operator.

Definition at line 51 of file Value.h.

◆ operator=() [2/2]

Value & palimpsest::Value::operator= ( Value &&  )
default

Default move assignment operator.

◆ print()

void palimpsest::Value::print ( std::ostream &  stream) const
inline

Print value to an output stream;.

Parameters
[out]streamOutput stream to print to.

Definition at line 98 of file Value.h.

◆ serialize()

void palimpsest::Value::serialize ( mpack::Writer &  writer) const
inline

Serialize value to a MessagePack writer.

Parameters
[out]writerWriter to serialize to.

Definition at line 104 of file Value.h.

◆ setup()

template<typename T , typename... ArgsT>
T & palimpsest::Value::setup ( )
inline

Allocate object and register internal functions.

Returns
Reference to allocated object.

Definition at line 113 of file Value.h.

Member Data Documentation

◆ buffer

std::unique_ptr<uint8_t[]> palimpsest::Value::buffer = nullptr

Internal buffer that holds the actual object.

Definition at line 168 of file Value.h.

◆ same

bool(* palimpsest::Value::same) (std::size_t)

Function that checks if a given type matches the object's type.

Definition at line 174 of file Value.h.

◆ type_name

const char *(* palimpsest::Value::type_name) ()

Function returning the name of the object's type.

Definition at line 171 of file Value.h.


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