Simbody  3.4 (development)
SimTK::Measure_< T >::Implementation Class Reference

This is the base Implementation class for all Measures whose value type is known. More...

#include <MeasureImplementation.h>

+ Inheritance diagram for SimTK::Measure_< T >::Implementation:

List of all members.

Public Member Functions

const T & getValue (const State &s, int derivOrder) const
void setDefaultValue (const T &defaultValue)
 Set a new default value for this Measure.
const T & getDefaultValue () const
 Return a reference to the value that this Measure will use to initialize its value-level state resource (state variable or cache entry) during the next call to realizeTopology().
void setIsPresumedValidAtDependsOnStage (bool presume)
bool getIsPresumedValidAtDependsOnStage () const

Protected Member Functions

 Implementation (const T &defaultValue, int numCacheEntries=1)
 Implementation (int numCacheEntries=1)
 Argument numCacheEntries should be one greater than the number of derivatives; that is, there is room for the value ("0th" derivative) also.
 Implementation (const Implementation &source)
 Copy constructor copies the number of cache entries from the source, but not the cache indices themselves as those must be allocated uniquely for the copy.
int size () const
 Return the number of elements in the data type of this Measure; for Vector measures this is determined by the size of the default value.
int getNumCacheEntries () const
 Return the number of cache entries allocated for the value and derivatives of this Measure.
const T & getCacheEntry (const State &s, int derivOrder) const
 Get a const reference to the value stored in one of this Measure's cache entries, indexed by the derivative order (with the value treated as the 0th derivative).
T & updCacheEntry (const State &s, int derivOrder) const
 Get a writable reference to the value stored in one of this Measure's cache entries, indexed by the derivative order (with the value treated as the 0th derivative).
bool isCacheValueRealized (const State &s, int derivOrder) const
 Determine whether a particular one of this Measure's cache entries has already been realized since the given state was modified.
void markCacheValueRealized (const State &s, int derivOrder) const
 Mark one of this Measure's cache entries up to date; call this after you have calculated a value or derivative and stored it in the corresponding cache entry.
void markCacheValueNotRealized (const State &s, int derivOrder) const
 Invalidate one of this Measure's cache entries.
virtual void realizeMeasureTopologyVirtual (State &) const
 Concrete measures can override this to allocate Topology-stage resources.
virtual void calcCachedValueVirtual (const State &, int derivOrder, T &value) const
 Concrete measures must override this if the state cache is used for precalculated values or derivatives.
virtual const T & getUncachedValueVirtual (const State &, int derivOrder) const
 This is only called when derivOrder >= the number of cache entries we have, but still <= the number of derivatives the Measure says it can deliver.
const T & getValueZero () const
 Return a reference to a zero of the same type and size as this Measure's value.

Detailed Description

template<class T>
class SimTK::Measure_< T >::Implementation

This is the base Implementation class for all Measures whose value type is known.

This class is still abstract but provides many services related to the values of the derived Measure and its derivatives, all of which require cache entries of type T.

The constructor needs to be told how many type-T cache entries to allocate.


Constructor & Destructor Documentation

template<class T>
SimTK::Measure_< T >::Implementation::Implementation ( const T &  defaultValue,
int  numCacheEntries = 1 
) [inline, explicit, protected]
template<class T>
SimTK::Measure_< T >::Implementation::Implementation ( int  numCacheEntries = 1) [inline, explicit, protected]

Argument numCacheEntries should be one greater than the number of derivatives; that is, there is room for the value ("0th" derivative) also.

The default is to allocate just room for the value.

template<class T>
SimTK::Measure_< T >::Implementation::Implementation ( const Implementation source) [inline, protected]

Copy constructor copies the number of cache entries from the source, but not the cache indices themselves as those must be allocated uniquely for the copy.

Reimplemented from SimTK::AbstractMeasure::Implementation.

Reimplemented in SimTK::Measure_< T >::Integrate::Implementation, SimTK::Measure_< T >::Result::Implementation, and SimTK::Measure_< T >::Variable::Implementation.


Member Function Documentation

template<class T>
const T& SimTK::Measure_< T >::Implementation::getValue ( const State s,
int  derivOrder 
) const [inline]
template<class T>
void SimTK::Measure_< T >::Implementation::setDefaultValue ( const T &  defaultValue) [inline]

Set a new default value for this Measure.

This is a topological change.

template<class T>
const T& SimTK::Measure_< T >::Implementation::getDefaultValue ( ) const [inline]

Return a reference to the value that this Measure will use to initialize its value-level state resource (state variable or cache entry) during the next call to realizeTopology().

template<class T>
void SimTK::Measure_< T >::Implementation::setIsPresumedValidAtDependsOnStage ( bool  presume) [inline]
template<class T>
bool SimTK::Measure_< T >::Implementation::getIsPresumedValidAtDependsOnStage ( ) const [inline]
template<class T>
int SimTK::Measure_< T >::Implementation::size ( ) const [inline, protected]

Return the number of elements in the data type of this Measure; for Vector measures this is determined by the size of the default value.

template<class T>
int SimTK::Measure_< T >::Implementation::getNumCacheEntries ( ) const [inline, protected]

Return the number of cache entries allocated for the value and derivatives of this Measure.

template<class T>
const T& SimTK::Measure_< T >::Implementation::getCacheEntry ( const State s,
int  derivOrder 
) const [inline, protected]

Get a const reference to the value stored in one of this Measure's cache entries, indexed by the derivative order (with the value treated as the 0th derivative).

template<class T>
T& SimTK::Measure_< T >::Implementation::updCacheEntry ( const State s,
int  derivOrder 
) const [inline, protected]

Get a writable reference to the value stored in one of this Measure's cache entries, indexed by the derivative order (with the value treated as the 0th derivative).

template<class T>
bool SimTK::Measure_< T >::Implementation::isCacheValueRealized ( const State s,
int  derivOrder 
) const [inline, protected]

Determine whether a particular one of this Measure's cache entries has already been realized since the given state was modified.

template<class T>
void SimTK::Measure_< T >::Implementation::markCacheValueRealized ( const State s,
int  derivOrder 
) const [inline, protected]

Mark one of this Measure's cache entries up to date; call this after you have calculated a value or derivative and stored it in the corresponding cache entry.

template<class T>
void SimTK::Measure_< T >::Implementation::markCacheValueNotRealized ( const State s,
int  derivOrder 
) const [inline, protected]

Invalidate one of this Measure's cache entries.

This is not normally necessary since the cache entries will be invalidated automatically when state variables they depend on change. However, this can be useful in some cases, particularly during debugging and testing.

template<class T>
virtual void SimTK::Measure_< T >::Implementation::calcCachedValueVirtual ( const State ,
int  derivOrder,
T &  value 
) const [inline, protected, virtual]
template<class T>
virtual const T& SimTK::Measure_< T >::Implementation::getUncachedValueVirtual ( const State ,
int  derivOrder 
) const [inline, protected, virtual]

This is only called when derivOrder >= the number of cache entries we have, but still <= the number of derivatives the Measure says it can deliver.

You don't need to override this if that condition can't occur. This is commonly used for functions whose derivatives above a certain order are zero.

Reimplemented in SimTK::Measure_< T >::Extreme::Implementation, SimTK::Measure_< T >::Differentiate::Implementation, SimTK::Measure_< T >::Integrate::Implementation, SimTK::Measure_< T >::Variable::Implementation, SimTK::Measure_< T >::Time::Implementation, and SimTK::Measure_< T >::Constant::Implementation.

template<class T>
const T& SimTK::Measure_< T >::Implementation::getValueZero ( ) const [inline, protected]

Return a reference to a zero of the same type and size as this Measure's value.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines