Drake
Value< T > Class Template Reference

A container class for an arbitrary type T. More...

#include <drake/systems/framework/value.h>

Inheritance diagram for Value< T >:
[legend]
Collaboration diagram for Value< T >:
[legend]

Public Member Functions

 Value ()
 Constructs a Value<T> using T's default constructor, if available. More...
 
 Value (const T &v)
 Constructs a Value<T> by copying or cloning the given value v. More...
 
template<typename... Args>
 Value (Args &&...args)
 Constructs a Value<T> by forwarding the given args to T's constructor, if available. More...
 
 Value (std::unique_ptr< T > v)
 Constructs a Value<T> by copying or moving the given value v. More...
 
 ~Value () override
 
std::unique_ptr< AbstractValueClone () const override
 Returns a copy of this AbstractValue. More...
 
void SetFrom (const AbstractValue &other) override
 Copies or clones the value in other to this value. More...
 
void SetFromOrThrow (const AbstractValue &other) override
 Like SetFrom, but throws on mismatched types even in Release builds. More...
 
const T & get_value () const
 Returns a const reference to the stored value. More...
 
T & get_mutable_value ()
 Returns a mutable reference to the stored value. More...
 
void set_value (const T &v)
 Replaces the stored value with a new one. More...
 
Does not allow copy, move, or assignment
 Value (const Value &)=delete
 
Valueoperator= (const Value &)=delete
 
 Value (Value &&)=delete
 
Valueoperator= (Value &&)=delete
 
- Public Member Functions inherited from AbstractValue
 AbstractValue ()
 
virtual ~AbstractValue ()
 
template<typename T >
const T & GetValue () const
 Returns the value wrapped in this AbstractValue, which must be of exactly type T. More...
 
template<typename T >
const T & GetValueOrThrow () const
 Like GetValue, but throws on mismatched types even in Release builds. More...
 
template<typename T >
T & GetMutableValue ()
 Returns the value wrapped in this AbstractValue, which must be of exactly type T. More...
 
template<typename T >
T & GetMutableValueOrThrow ()
 Like GetMutableValue, but throws on mismatched types even in Release builds. More...
 
template<typename T >
void SetValue (const T &value_to_set)
 Sets the value wrapped in this AbstractValue, which must be of exactly type T. More...
 
template<typename T >
void SetValueOrThrow (const T &value_to_set)
 Like SetValue, but throws on mismatched types even in Release builds. More...
 
 AbstractValue (const AbstractValue &)=delete
 
AbstractValueoperator= (const AbstractValue &)=delete
 
 AbstractValue (AbstractValue &&)=delete
 
AbstractValueoperator= (AbstractValue &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractValue
template<typename T >
static std::unique_ptr< AbstractValueMake (const T &value)
 Returns an AbstractValue containing the given value. More...
 

Detailed Description

template<typename T>
class drake::systems::Value< T >

A container class for an arbitrary type T.

User-defined classes that require additional type-erased features should subclass Value<T>, taking care to define the copy constructors and override Clone().

Template Parameters
TMust be copy-constructible or cloneable.

Constructor & Destructor Documentation

Value ( const Value< T > &  )
delete
Value ( Value< T > &&  )
delete
Value ( )
inline

Constructs a Value<T> using T's default constructor, if available.

This is only available for T's that support default construction.

Value ( const T &  v)
inlineexplicit

Constructs a Value<T> by copying or cloning the given value v.

Value ( Args &&...  args)
explicit

Constructs a Value<T> by forwarding the given args to T's constructor, if available.

This is only available for non-primitive T's that are constructible from args.

Value ( std::unique_ptr< T >  v)
inlineexplicit

Constructs a Value<T> by copying or moving the given value v.

Precondition
v is non-null
~Value ( )
inlineoverride

Member Function Documentation

std::unique_ptr<AbstractValue> Clone ( ) const
inlineoverridevirtual

Returns a copy of this AbstractValue.

Implements AbstractValue.

T& get_mutable_value ( )
inline

Returns a mutable reference to the stored value.

const T& get_value ( ) const
inline

Returns a const reference to the stored value.

Here is the caller graph for this function:

Value& operator= ( Value< T > &&  )
delete
Value& operator= ( const Value< T > &  )
delete
void set_value ( const T &  v)
inline

Replaces the stored value with a new one.

void SetFrom ( const AbstractValue< T > &  other)
inlineoverridevirtual

Copies or clones the value in other to this value.

In Debug builds, if the types don't match, std::bad_cast will be thrown. In Release builds, this is not guaranteed.

Implements AbstractValue.

Here is the call graph for this function:

void SetFromOrThrow ( const AbstractValue< T > &  other)
inlineoverridevirtual

Like SetFrom, but throws on mismatched types even in Release builds.

Implements AbstractValue.

Here is the call graph for this function:


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