Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
NameValue< T > Class Template Reference

Detailed Description

template<typename T>
class drake::NameValue< T >

(Advanced) A basic implementation of the Name-Value Pair concept as used in the Serialize / Archive pattern.

NameValue stores a pointer to a const name and a pointer to a mutable value. Both pointers must remain valid throughout the lifetime of an object. NameValue objects are typically short-lived, existing only for a transient moment while an Archive is visiting some Serializable field.

For more information, refer to Drake's YAML Serialization and especially the Implementing Serialize section, or also the Boost Name-Value Pairs documentation for background.

#include <drake/common/name_value.h>

Public Types

typedef T value_type
 Type of the referenced value.

Public Member Functions

 NameValue (const char *name_in, T *value_in)
 (Advanced) Constructs a NameValue.
Does not allow copy, move, or assignment
 NameValue (const NameValue &)=delete
NameValueoperator= (const NameValue &)=delete
 NameValue (NameValue &&)=delete
NameValueoperator= (NameValue &&)=delete

Accessors to the raw pointers

const char * name () const
T * value () const

Member Typedef Documentation

◆ value_type

template<typename T>
typedef T value_type

Type of the referenced value.

Constructor & Destructor Documentation

◆ NameValue() [1/3]

template<typename T>
NameValue ( const NameValue< T > & )
delete

◆ NameValue() [2/3]

template<typename T>
NameValue ( NameValue< T > && )
delete

◆ NameValue() [3/3]

template<typename T>
NameValue ( const char * name_in,
T * value_in )

(Advanced) Constructs a NameValue.

Prefer DRAKE_NVP instead of this constructor. Both pointers are aliased and must remain valid for the lifetime of this object. Neither pointer can be nullptr.

Member Function Documentation

◆ name()

template<typename T>
const char * name ( ) const

◆ operator=() [1/2]

template<typename T>
NameValue & operator= ( const NameValue< T > & )
delete

◆ operator=() [2/2]

template<typename T>
NameValue & operator= ( NameValue< T > && )
delete

◆ value()

template<typename T>
T * value ( ) const

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