Drake
Context< T > Class Template Reference

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...
 

Detailed Description

template<typename T>
class drake::systems::Context< T >

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.

Template Parameters
TThe mathematical type of the context, which must be a valid Eigen scalar.

Constructor & Destructor Documentation

Context ( )
inline
virtual ~Context ( )
inlinevirtual

Member Function Documentation

void ClearInputPorts ( )
inline

Removes all the input ports, and deregisters them from the output ports on which they depend.

std::unique_ptr<Context<T> > Clone ( ) const
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.

virtual Context<T>* DoClone ( ) const
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.

const Cache<T>& get_cache ( ) const
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.

Cache<T>* get_mutable_cache ( ) const
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.

Here is the caller graph for this function:

State<T>* get_mutable_state ( )
inline

Returns writable access to the State.

No cache invalidation occurs until mutable access is requested for particular blocks of state variables.

Here is the caller graph for this function:

int get_num_input_ports ( ) const
inline

Here is the caller graph for this function:

const State<T>& get_state ( ) const
inline

Here is the caller graph for this function:

const T& get_time ( ) const
inline

Returns the current time in seconds.

const VectorInterface<T>* get_vector_input ( int  index) const
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.

Here is the caller graph for this function:

void set_time ( const T &  time_sec)
inline

Set the current time in seconds.

void SetInputPort ( int  index,
std::unique_ptr< InputPort< T >>  port 
)
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.

Here is the caller graph for this function:

void SetNumInputPorts ( int  n)
inline

Clears the input ports and allocates n new input ports, not connected to anything.

Here is the caller graph for this function:


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