Drake
CacheEntry Class Reference

Each cache entry contains: More...

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

Inheritance diagram for CacheEntry:
Collaboration diagram for CacheEntry:

Public Types

using Calculator = std::function< void(const class AbstractSystem3 &, const class AbstractContext3 &, AbstractValue *)>
 This is the type of a function that unconditionally computes this cache entry's value with respect to the contents of a given Context. More...
 

Public Member Functions

 CacheEntry ()
 Create an empty cache entry that is not yet committed to a particular kind of abstract value. More...
 
 CacheEntry (const AbstractValue &value)
 Create a cache entry initialized to a copy of the given value. More...
 
 CacheEntry (std::unique_ptr< AbstractValue > value) noexcept
 Create a cache entry that takes over ownership of the given value. More...
 
 CacheEntry (const CacheEntry &source)
 Copy constructor makes a new cache entry that has a copy of the value from source, but is marked "not current" regardless of whether source is current. More...
 
 CacheEntry (CacheEntry &&source) noexcept
 Move constructor moves the value and preserves the is_current status of the source in the destination. More...
 
void set_calculator (const Calculator &calculator)
 Set the function to be used when we need to recompute this cache entry's value. More...
 
const Calculatorget_calculator () const
 Set the function to be used when we need to recompute this cache entry's value. More...
 
void ResetAbstractValue (std::unique_ptr< AbstractValue > value)
 Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with the supplied one. More...
 
void ResetAbstractValue (const AbstractValue &value)
 Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with a copy of the supplied one. More...
 
void RealizeCacheEntry (const AbstractSystem3 &system, const AbstractContext3 &context)
 
bool is_current () const
 Return the value of the is_current flag for this cache entry. More...
 
void set_is_current (bool is_current)
 Mark this entry as current or not; up to caller to do this right. More...
 
const AbstractValueget_abstract_value () const
 Return a const reference to the AbstractValue contained in this cache entry, regardless of whether it is current. More...
 
AbstractValueget_mutable_abstract_value ()
 Return a mutable pointer to the AbstractValue contained in this cache entry, regardless of whether it is current. More...
 
template<class Type >
const Type & get_value () const
 Return a const reference to the value contained in this cache entry, which must be of type Type. More...
 
template<class Type >
Type * get_mutable_value ()
 Return a mutable pointer to the value contained in this cache entry, which must be of type Type. More...
 
template<typename T >
const VectorInterface< T > & get_vector_value () const
 
template<typename T >
const VectorInterface< T > * get_mutable_vector_value () const
 
void Invalidate () override
 Invalidate this cache entry and notify any downstream listeners. More...
 
- Public Member Functions inherited from ValueListenerInterface
virtual ~ValueListenerInterface ()
 

Detailed Description

Each cache entry contains:

  • An AbstractValue containing the actual result.
  • An Evaluator function that knows how to compute the result when given a System and a compatible Context.
  • A bool indicating whether the result is up to date with respect to its prerequisites in the same Context.
  • A list of dependents ("listeners") that need to be notified when the cache entry is marked invalid.

A cache entry is both a prerequisite for its downstream value listeners, and a value listener registered with its upstream prerequisites.

Member Typedef Documentation

using Calculator = std::function<void(const class AbstractSystem3&, const class AbstractContext3&, AbstractValue*)>

This is the type of a function that unconditionally computes this cache entry's value with respect to the contents of a given Context.

Constructor & Destructor Documentation

CacheEntry ( )
inline

Create an empty cache entry that is not yet committed to a particular kind of abstract value.

CacheEntry ( const AbstractValue value)
inlineexplicit

Create a cache entry initialized to a copy of the given value.

CacheEntry ( std::unique_ptr< AbstractValue value)
inlineexplicitnoexcept

Create a cache entry that takes over ownership of the given value.

CacheEntry ( const CacheEntry source)
inline

Copy constructor makes a new cache entry that has a copy of the value from source, but is marked "not current" regardless of whether source is current.

CacheEntry ( CacheEntry &&  source)
inlinenoexcept

Move constructor moves the value and preserves the is_current status of the source in the destination.

The source is left empty and not current.

Member Function Documentation

const AbstractValue& get_abstract_value ( ) const
inline

Return a const reference to the AbstractValue contained in this cache entry, regardless of whether it is current.

Here is the caller graph for this function:

const Calculator& get_calculator ( ) const
inline

Set the function to be used when we need to recompute this cache entry's value.

Here is the caller graph for this function:

AbstractValue* get_mutable_abstract_value ( )
inline

Return a mutable pointer to the AbstractValue contained in this cache entry, regardless of whether it is current.

The value is returned regardless* of whether it is current.

Here is the caller graph for this function:

Type* get_mutable_value ( )
inline

Return a mutable pointer to the value contained in this cache entry, which must be of type Type.

The value is returned regardless of whether it is current. No invalidation or notification occurs.

Exceptions
std::logic_errorThe value did not have type Type.

Here is the call graph for this function:

const VectorInterface<T>* get_mutable_vector_value ( ) const
inline

Here is the call graph for this function:

const Type& get_value ( ) const
inline

Return a const reference to the value contained in this cache entry, which must be of type Type.

The value is returned regardless of whether it is current.

Exceptions
std::logic_errorThe value did not have type Type.

Here is the call graph for this function:

const VectorInterface<T>& get_vector_value ( ) const
inline

Here is the call graph for this function:

void Invalidate ( )
inlineoverridevirtual

Invalidate this cache entry and notify any downstream listeners.

The value version number is incremented.

Implements ValueListenerInterface.

Here is the call graph for this function:

bool is_current ( ) const
inline

Return the value of the is_current flag for this cache entry.

Here is the caller graph for this function:

void RealizeCacheEntry ( const AbstractSystem3 system,
const AbstractContext3 context 
)
inline

Here is the call graph for this function:

Here is the caller graph for this function:

void ResetAbstractValue ( std::unique_ptr< AbstractValue value)
inline

Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with the supplied one.

The CacheEntry takes ownership of the AbstractValue object.

Here is the call graph for this function:

Here is the caller graph for this function:

void ResetAbstractValue ( const AbstractValue value)
inline

Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with a copy of the supplied one.

Here is the call graph for this function:

void set_calculator ( const Calculator calculator)
inline

Set the function to be used when we need to recompute this cache entry's value.

Here is the caller graph for this function:

void set_is_current ( bool  is_current)
inline

Mark this entry as current or not; up to caller to do this right.

Here is the call graph for this function:

Here is the caller graph for this function:


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