Drake
|
The Context is a container for all of the data necessary to uniquely determine the computations performed by a System. More...
#include <drake/systems/framework/context.h>
Public Member Functions | |
Context () | |
virtual | ~Context () |
const T & | get_time () const |
Returns the current time in seconds. More... | |
void | set_time (const T &time_sec) |
Set the current time in seconds. More... | |
void | SetInputPort (int index, std::unique_ptr< InputPort< T >> port) |
Connects the input port port to this Context at the given index . More... | |
void | ClearInputPorts () |
Removes all the input ports, and deregisters them from the output ports on which they depend. More... | |
void | SetNumInputPorts (int n) |
Clears the input ports and allocates n new input ports, not connected to anything. More... | |
int | get_num_input_ports () const |
const VectorInterface< T > * | get_vector_input (int index) const |
Returns the vector data of the input port at index . More... | |
const State< T > & | get_state () const |
State< T > * | get_mutable_state () |
Returns writable access to the State. More... | |
const Cache< T > & | get_cache () const |
Returns a const reference to the Cache, which is expected to contain precalculated values of interest. More... | |
Cache< T > * | get_mutable_cache () const |
Access to the cache is always read-write, and is permitted even on const references to the Context. More... | |
std::unique_ptr< Context< T > > | Clone () const |
Returns a deep copy of this Context. More... | |
Protected Member Functions | |
virtual Context< T > * | DoClone () const |
The Context implementation for Diagrams must override this method, since the state of a Diagram will not be a LeafStateVector. More... | |
The Context is a container for all of the data necessary to uniquely determine the computations performed by a System.
Specifically, a Context contains and owns the State, and also contains (but does not own) pointers to the Input, as well as the simulation time and the cache.
Context may be subclassed within the framework to support specialized kinds of Systems, such as Diagrams, but should not be subclassed by users.
T | The mathematical type of the context, which must be a valid Eigen scalar. |
|
inline |
|
inlinevirtual |
|
inline |
Removes all the input ports, and deregisters them from the output ports on which they depend.
|
inline |
Returns a deep copy of this Context.
The clone's input ports will hold deep copies of the data that appears on this context's port at the time the clone is created.
|
inlineprotectedvirtual |
The Context implementation for Diagrams must override this method, since the state of a Diagram will not be a LeafStateVector.
The caller owns the returned memory.
|
inline |
Returns a const reference to the Cache, which is expected to contain precalculated values of interest.
Use this only to access known-valid cache entries; use get_mutable_cache()
if computations may be needed.
|
inline |
Access to the cache is always read-write, and is permitted even on const references to the Context.
No invalidation of downstream dependents occurs until mutable access is requested for a particular cache entry.
|
inline |
Returns writable access to the State.
No cache invalidation occurs until mutable access is requested for particular blocks of state variables.
|
inline |
|
inline |
|
inline |
Returns the current time in seconds.
|
inline |
Returns the vector data of the input port at index
.
Returns nullptr if that port is not a vector-valued port, or if it is not connected. Throws std::out_of_range if that port does not exist.
|
inline |
Set the current time in seconds.
|
inline |
Connects the input port port
to this Context at the given index
.
Disconnects whatever input port was previously there, and deregisters it from the output port on which it depends.
|
inline |
Clears the input ports and allocates n
new input ports, not connected to anything.