Simbody  3.6
SimTK::Value< T > Class Template Reference

Concrete templatized class derived from AbstractValue, adding generic value type-specific functionality, with implicit conversion to the underlying type T. More...

+ Inheritance diagram for SimTK::Value< T >:

Public Member Functions

 Value ()
 Creates a Value<T> whose contained object of type T has been default constructed. More...
 
 Value (const T &value)
 Creates a Value<T> whose contained object is copy constructed from the given value. More...
 
 Value (const T &&value)
 Creates a Value<T> whose contained object is move constructed from the given value. More...
 
 ~Value ()=default
 
 Value (const Value &value)
 Copy constructor invokes the type T copy constructor to copy the contained value. More...
 
 Value (const Value &&value)
 Move constructor invokes the type T move constructor, if available, to move the given value into this Value<T> object. More...
 
Valueoperator= (const Value &value)
 The copy assignment here invokes type T copy assignment on the contained object, it does not invoke AbstractValue's copy assignment. More...
 
Valueoperator= (const Value &&value)
 The move assignment here invokes type T move assignment on the contained object, it does not invoke AbstractValue's move assignment. More...
 
Valueoperator= (const T &value)
 Assign a new value to the contained object, using the type T copy assignment operator. More...
 
Valueoperator= (const T &&value)
 Assign a new value to the contained object, using the type T move assignment operator, if available. More...
 
const T & get () const
 Return a const reference to the object of type T that is contained in this Value<T> object. More...
 
T & upd ()
 Return a writable reference to the object of type T that is contained in this Value object. More...
 
void set (const T &value)
 Assign the contained object to the given value by invoking the type T copy assignment operator. More...
 
void set (const T &&value)
 Assign the contained object to the given value by invoking the type T move assignment operator, if available. More...
 
 operator const T & () const
 Implicit conversion from a const reference to a Value<T> object to a const reference to the type T object it contains. More...
 
 operator T & ()
 Implicit conversion from a writable reference to a Value object to a writable reference to the type T object it contains. More...
 
Valueclone () const override
 Covariant implementation of the AbstractValue::clone() method. More...
 
bool isCompatible (const AbstractValue &value) const override
 Test whether a given AbstractValue is assignment-compatible with this Value object. More...
 
void compatibleAssign (const AbstractValue &value) override
 If the given AbstractValue is assignment-compatible, perform the assignment. More...
 
String getTypeName () const override
 Use NiceTypeName to produce a human-friendly representation of the type T. More...
 
String getValueAsString () const override
 (Not implemented yet) Produce a human-friendly representation of the contained value of type T. More...
 
- Public Member Functions inherited from SimTK::AbstractValue
AbstractValueoperator= (const AbstractValue &v)
 Invokes the compatibleAssign() method which will perform the assignment if the source object is compatible, or throw an exception otherwise. More...
 
template<typename T >
const T & getValue () const
 Retrieve the original (type-erased)thing as read-only. More...
 
template<typename T >
T & updValue ()
 Retrieve the original (type-erased)thing as read-write. More...
 
virtual ~AbstractValue ()
 

Static Public Member Functions

static bool isA (const AbstractValue &value)
 Return true if the given AbstractValue is an object of this type Value<T>. More...
 
static const Valuedowncast (const AbstractValue &value)
 Downcast a const reference to an AbstractValue to a const reference to this type Value<T>. More...
 
static ValueupdDowncast (AbstractValue &value)
 Downcast a writable reference to an AbstractValue to a writable reference to this type Value<T>. More...
 
static Valuedowncast (AbstractValue &value)
 Deprecated – use updDowncast() instead. More...
 

Additional Inherited Members

Detailed Description

template<class T>
class SimTK::Value< T >

Concrete templatized class derived from AbstractValue, adding generic value type-specific functionality, with implicit conversion to the underlying type T.

Constructor & Destructor Documentation

◆ Value() [1/5]

template<class T>
SimTK::Value< T >::Value ( )
inline

Creates a Value<T> whose contained object of type T has been default constructed.

◆ Value() [2/5]

template<class T>
SimTK::Value< T >::Value ( const T &  value)
inlineexplicit

Creates a Value<T> whose contained object is copy constructed from the given value.

◆ Value() [3/5]

template<class T>
SimTK::Value< T >::Value ( const T &&  value)
inlineexplicit

Creates a Value<T> whose contained object is move constructed from the given value.

If type T doesn't provide a move constructor then this is copy constructed.

◆ ~Value()

template<class T>
SimTK::Value< T >::~Value ( )
default

◆ Value() [4/5]

template<class T>
SimTK::Value< T >::Value ( const Value< T > &  value)
inline

Copy constructor invokes the type T copy constructor to copy the contained value.

◆ Value() [5/5]

template<class T>
SimTK::Value< T >::Value ( const Value< T > &&  value)
inline

Move constructor invokes the type T move constructor, if available, to move the given value into this Value<T> object.

Member Function Documentation

◆ operator=() [1/4]

template<class T>
Value& SimTK::Value< T >::operator= ( const Value< T > &  value)
inline

The copy assignment here invokes type T copy assignment on the contained object, it does not invoke AbstractValue's copy assignment.

◆ operator=() [2/4]

template<class T>
Value& SimTK::Value< T >::operator= ( const Value< T > &&  value)
inline

The move assignment here invokes type T move assignment on the contained object, it does not invoke AbstractValue's move assignment.

If type T doesn't provide move assignment then copy assignment is used instead.

◆ operator=() [3/4]

template<class T>
Value& SimTK::Value< T >::operator= ( const T &  value)
inline

Assign a new value to the contained object, using the type T copy assignment operator.

◆ operator=() [4/4]

template<class T>
Value& SimTK::Value< T >::operator= ( const T &&  value)
inline

Assign a new value to the contained object, using the type T move assignment operator, if available.

◆ get()

template<class T>
const T& SimTK::Value< T >::get ( ) const
inline

Return a const reference to the object of type T that is contained in this Value<T> object.

There is also an implicit conversion that performs the same function.

◆ upd()

template<class T>
T& SimTK::Value< T >::upd ( )
inline

Return a writable reference to the object of type T that is contained in this Value object.

There is also an implicit conversion that performs the same function.

See also
set()

◆ set() [1/2]

template<class T>
void SimTK::Value< T >::set ( const T &  value)
inline

Assign the contained object to the given value by invoking the type T copy assignment operator.

See also
upd()

◆ set() [2/2]

template<class T>
void SimTK::Value< T >::set ( const T &&  value)
inline

Assign the contained object to the given value by invoking the type T move assignment operator, if available.

◆ operator const T &()

template<class T>
SimTK::Value< T >::operator const T & ( ) const
inline

Implicit conversion from a const reference to a Value<T> object to a const reference to the type T object it contains.

This is identical to the get() method.

◆ operator T &()

template<class T>
SimTK::Value< T >::operator T& ( )
inline

Implicit conversion from a writable reference to a Value object to a writable reference to the type T object it contains.

This is identical to the upd() method.

◆ clone()

template<class T>
Value* SimTK::Value< T >::clone ( ) const
inlineoverridevirtual

Covariant implementation of the AbstractValue::clone() method.

(Covariant means that the return type has been changed to the derived type.)

Implements SimTK::AbstractValue.

◆ isCompatible()

template<class T>
bool SimTK::Value< T >::isCompatible ( const AbstractValue< T > &  value) const
inlineoverridevirtual

Test whether a given AbstractValue is assignment-compatible with this Value object.

Currently this only returns true if the source is exactly the same type as this.

Implements SimTK::AbstractValue.

◆ compatibleAssign()

template<class T>
void SimTK::Value< T >::compatibleAssign ( const AbstractValue< T > &  value)
inlineoverridevirtual

If the given AbstractValue is assignment-compatible, perform the assignment.

Otherwise, throw an exception (at least in a Debug build).

Implements SimTK::AbstractValue.

◆ getTypeName()

template<class T>
String SimTK::Value< T >::getTypeName ( ) const
inlineoverridevirtual

Use NiceTypeName to produce a human-friendly representation of the type T.

Implements SimTK::AbstractValue.

◆ getValueAsString()

template<class T>
String SimTK::Value< T >::getValueAsString ( ) const
inlineoverridevirtual

(Not implemented yet) Produce a human-friendly representation of the contained value of type T.

Currently just returns the type name.

Implements SimTK::AbstractValue.

◆ isA()

template<class T>
static bool SimTK::Value< T >::isA ( const AbstractValue< T > &  value)
inlinestatic

Return true if the given AbstractValue is an object of this type Value<T>.

◆ downcast() [1/2]

template<class T>
static const Value& SimTK::Value< T >::downcast ( const AbstractValue< T > &  value)
inlinestatic

Downcast a const reference to an AbstractValue to a const reference to this type Value<T>.

A std::bad_cast exception is thrown if the type is wrong, at least in Debug builds.

◆ updDowncast()

template<class T>
static Value& SimTK::Value< T >::updDowncast ( AbstractValue< T > &  value)
inlinestatic

Downcast a writable reference to an AbstractValue to a writable reference to this type Value<T>.

A std::bad_cast exception is thrown if the type is wrong, at least in Debug builds.

◆ downcast() [2/2]

template<class T>
static Value& SimTK::Value< T >::downcast ( AbstractValue< T > &  value)
inlinestatic

Deprecated – use updDowncast() instead.


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