45 explicit CacheEntry(std::unique_ptr<AbstractValue> value) noexcept
46 : value_(std::move(value)) {}
58 : value_(
std::move(source.value_)), is_current_(source.is_current_) {
59 source.set_is_current(
false);
65 calculate_ = calculator;
76 value_ = std::move(value);
118 template <
class Type>
121 return abstract_value.
GetValue<Type>();
128 template <
class Type>
134 template <
typename T>
140 template <
typename T>
157 std::unique_ptr<AbstractValue> value_;
165 bool is_current_{
false};
171 long long version_{0};
VectorInterface is a pure abstract interface that real-valued signals between Systems must satisfy...
Definition: vector_interface.h:25
const Type & get_value() const
Return a const reference to the value contained in this cache entry, which must be of type Type...
Definition: cache3.h:119
AbstractValue * get_mutable_abstract_value()
Return a mutable pointer to the AbstractValue contained in this cache entry, regardless of whether it...
Definition: cache3.h:110
An abstract superclass for the Context3 objects for dynamical systems, encapsulating functionality th...
Definition: context3.h:87
CacheEntry(CacheEntry &&source) noexcept
Move constructor moves the value and preserves the is_current status of the source in the destination...
Definition: cache3.h:57
const Calculator & get_calculator() const
Set the function to be used when we need to recompute this cache entry's value.
Definition: cache3.h:70
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.
Definition: cache3.h:51
Definition: constants.h:3
virtual std::unique_ptr< AbstractValue > Clone() const =0
Returns a copy of this AbstractValue.
const AbstractValue & get_abstract_value() const
Return a const reference to the AbstractValue contained in this cache entry, regardless of whether it...
Definition: cache3.h:105
void Invalidate() override
Invalidate this cache entry and notify any downstream listeners.
Definition: cache3.h:150
A ValueListenerList object maintains a list of value listeners that have registered to receive notifi...
Definition: value_listener3.h:34
const VectorInterface< T > * get_mutable_vector_value() const
Definition: cache3.h:141
ValueListenerInterface is an interface that dependent computations must implement so that they can re...
Definition: value_listener3.h:19
void NotifyListeners()
Notify all dependents of this value that the value has changed.
Definition: value_listener3.h:56
void RealizeCacheEntry(const AbstractSystem3 &system, const AbstractContext3 &context)
Definition: cache3.h:86
void set_is_current(bool is_current)
Mark this entry as current or not; up to caller to do this right.
Definition: cache3.h:101
CacheEntry()
Create an empty cache entry that is not yet committed to a particular kind of abstract value...
Definition: cache3.h:39
void ResetAbstractValue(const AbstractValue &value)
Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with a co...
Definition: cache3.h:82
const T & GetValue() const
Returns the value wrapped in this AbstractValue, which must be of exactly type T. ...
Definition: value.h:35
const VectorInterface< T > & get_vector_value() const
Definition: cache3.h:135
bool is_current() const
Return the value of the is_current flag for this cache entry.
Definition: cache3.h:98
An abstract superclass for dynamical systems, encapsulating functionality that is independent of the ...
Definition: system3.h:68
T * GetMutableValue()
Returns the value wrapped in this AbstractValue, which must be of exactly type T. ...
Definition: value.h:46
This concrete class provides object semantics to an abstract VectorInterface by implementing a copy c...
Definition: vector_interface.h:70
A fully type-erased container class.
Definition: value.h:22
const VectorInterface< T > & get_vector() const
Returns a const reference to the VectorInterface object owned by this VectorObject, if any.
Definition: vector_interface.h:108
VectorInterface< T > * get_mutable_vector()
Returns a mutable pointer to the VectorInterface object owned by this VectorObject, if any.
Definition: vector_interface.h:118
std::function< void(const class AbstractSystem3 &, const class AbstractContext3 &, AbstractValue *)> Calculator
This is the type of a function that unconditionally computes this cache entry's value with respect to...
Definition: cache3.h:35
void ResetAbstractValue(std::unique_ptr< AbstractValue > value)
Set the AbstractValue type stored in this CacheEntry by replacing the existing one (if any) with the ...
Definition: cache3.h:75
CacheEntry(std::unique_ptr< AbstractValue > value) noexcept
Create a cache entry that takes over ownership of the given value.
Definition: cache3.h:45
Type * get_mutable_value()
Return a mutable pointer to the value contained in this cache entry, which must be of type Type...
Definition: cache3.h:129
CacheEntry(const AbstractValue &value)
Create a cache entry initialized to a copy of the given value.
Definition: cache3.h:42
Each cache entry contains:
Definition: cache3.h:29
void set_calculator(const Calculator &calculator)
Set the function to be used when we need to recompute this cache entry's value.
Definition: cache3.h:64