Simbody  3.7
SimTK::AbstractValue Class Referenceabstract

Abstract base class representing an arbitrary value of unknown type. More...

+ Inheritance diagram for SimTK::AbstractValue:

Public Member Functions

virtual AbstractValueclone () const =0
 Create a deep copy of this object. More...
 
virtual String getTypeName () const =0
 Return a human-readable form of the object type that is stored in the concrete derived class underlying this AbstractValue. More...
 
virtual String getValueAsString () const =0
 Return a human-readable representation of the value stored in this AbstractValue object. More...
 
virtual bool isCompatible (const AbstractValue &other) const =0
 Check whether the other object contains a value that is assignment- compatible with this one. More...
 
virtual void compatibleAssign (const AbstractValue &source)=0
 If the source contains a compatible value, assign a copy of that value into this object. More...
 
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 ()
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &o, const AbstractValue &v)
 Write a human-readable representation of an AbstractValue to an output stream, using the getValueAsString() member function. More...
 

Detailed Description

Abstract base class representing an arbitrary value of unknown type.

This provides an ability to manipulate "values" abstractly without knowing the specific type of that value. This is useful, for example, for discrete state variables and Measures, where much of what we need to do with them is independent of their types.

Constructor & Destructor Documentation

◆ ~AbstractValue()

virtual SimTK::AbstractValue::~AbstractValue ( )
inlinevirtual

Member Function Documentation

◆ clone()

virtual AbstractValue* SimTK::AbstractValue::clone ( ) const
pure virtual

Create a deep copy of this object.

Implemented in SimTK::Value< T >.

◆ getTypeName()

virtual String SimTK::AbstractValue::getTypeName ( ) const
pure virtual

Return a human-readable form of the object type that is stored in the concrete derived class underlying this AbstractValue.

Implemented in SimTK::Value< T >.

◆ getValueAsString()

virtual String SimTK::AbstractValue::getValueAsString ( ) const
pure virtual

Return a human-readable representation of the value stored in this AbstractValue object.

Implemented in SimTK::Value< T >.

◆ isCompatible()

virtual bool SimTK::AbstractValue::isCompatible ( const AbstractValue other) const
pure virtual

Check whether the other object contains a value that is assignment- compatible with this one.

If so you can perform the assignment with the assignment operator or with compatibleAssign().

Implemented in SimTK::Value< T >.

◆ compatibleAssign()

virtual void SimTK::AbstractValue::compatibleAssign ( const AbstractValue source)
pure virtual

If the source contains a compatible value, assign a copy of that value into this object.

Otherwise an exception is thrown.

Implemented in SimTK::Value< T >.

◆ operator=()

AbstractValue& SimTK::AbstractValue::operator= ( const AbstractValue v)
inline

Invokes the compatibleAssign() method which will perform the assignment if the source object is compatible, or throw an exception otherwise.

◆ getValue()

template<typename T >
const T& SimTK::AbstractValue::getValue ( ) const
inline

Retrieve the original (type-erased)thing as read-only.

The template argument must be exactly the non-reference type of the stored thing.

◆ updValue()

template<typename T >
T& SimTK::AbstractValue::updValue ( )
inline

Retrieve the original (type-erased)thing as read-write.

The template argument must be exactly the non-reference type of the stored thing

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  o,
const AbstractValue v 
)
related

Write a human-readable representation of an AbstractValue to an output stream, using the getValueAsString() member function.


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