Drake
Context3< T > Class Template Reference

The context is a container for all data necessary to uniquely determine the results of computations performed by a System. More...

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

Inheritance diagram for Context3< T >:
Collaboration diagram for Context3< T >:

Public Member Functions

 Context3 ()
 
 ~Context3 () override
 
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...
 
std::unique_ptr< Context3< T > > Clone () const
 Returns writable access to the State. More...
 
 Context3 (const Context3 &source)
 Copy constructor makes a deep copy of the source Context3, and also copies the current values of time and any connected input and parameter ports into standalone internal values so that the entire computation context is preserved. More...
 
- Public Member Functions inherited from AbstractContext3
virtual ~AbstractContext3 ()
 
std::unique_ptr< AbstractContext3Clone () const
 Returns a deep copy of this Context3. More...
 
void SetNumInputPorts (int num_ports)
 Allocate input port entries corresponding to a System3's InputPort3 objects. More...
 
void SetNumOutputPorts (int num_ports)
 Allocate output port entries corresponding to a System3's OutputPort3 objects. More...
 
DRAKESYSTEMFRAMEWORK_EXPORT void SetInputPort (const AbstractSystem3 &system, int port_num)
 Set the input entry for this port number appropriately, given the corresponding InputPort3 in system. More...
 
DRAKESYSTEMFRAMEWORK_EXPORT void SetOutputPort (const AbstractSystem3 &system, int port_num)
 Set the output entry for this port number appropriately, given the corresponding OutputPort3 in system. More...
 
int get_num_input_ports () const
 
int get_num_output_ports () const
 
int get_num_cache_entries () const
 
const CacheEntryget_input_entry (int port_num) const
 Return a const pointer to the cache entry that is providing the value for the given input port, if this port is connected. More...
 
CacheEntryget_mutable_input_entry (int port_num) const
 Return a mutable pointer to the cache entry that is providing the value for the given input port, if this port is connected. More...
 
const CacheEntryget_output_entry (int port_num) const
 
CacheEntryget_mutable_output_entry (int port_num) const
 
int AddSubcontext (std::unique_ptr< AbstractContext3 > subcontext)
 Add a subcontext as a child of this context. More...
 
int get_num_subcontexts () const
 Returns the current number of subcontexts contained in this context. More...
 
const AbstractContext3get_subcontext (int index) const
 Returns a const reference to one of the contained subcontexts, using the index reflecting the order in which it was added. More...
 
AbstractContext3get_mutable_subcontext (int index)
 Returns a mutable pointer to one of the contained subcontexts, using the index reflecting the order in which it was added. More...
 
const AbstractContext3get_parent_context () const
 Returns a const pointer to the parent context that owns this one, or nullptr if this is a root context. More...
 
AbstractContext3get_mutable_parent_context ()
 Returns a mutable pointer to the parent context that owns this one, or nullptr if this is a root context. More...
 
int get_subcontext_num () const
 If this context is a subcontext of a parent context, return the subcontext number by which that parent knows us. More...
 
const AbstractSystem3find_my_subsystem (const AbstractSystem3 &some_subsystem) const
 Get const access to this subcontext's subsystem given const access to any other subcontext's subsystem in the same system diagram. More...
 
AbstractSystem3find_my_mutable_subsystem (AbstractSystem3 *some_subsystem) const
 Get mutable access to this subcontext's subsystem given mutable access to any other subcontext's subsystem in the same system diagram. More...
 
const AbstractContext3get_root_context () const
 Find the root context of the tree of which this subcontext is a member. More...
 
AbstractContext3get_mutable_root_context ()
 Get a mutable pointer to the root context of the tree of which this subcontext is a member. More...
 

Protected Member Functions

Context3< T > * DoClone () const override
 The Context implementation for Diagrams must override this method, since the state of a Diagram will not be a LeafStateVector. More...
 
- Protected Member Functions inherited from AbstractContext3
 AbstractContext3 ()=default
 Create an empty AbstractContext3. More...
 
 AbstractContext3 (const AbstractContext3 &source)
 Copy the base class data members and preserve the input and parameter port values. More...
 

Detailed Description

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

The context is a container for all data necessary to uniquely determine the results of computations performed by a System.

Specifically, a Context3 contains

  • the current value of time
  • pointers to values for a set of InputPorts (and ParameterPorts)
  • values for the state variables
  • cache entries for computed OutputPort values
  • cache entries for time derivatives of continuous states
  • a cache entry for update values of discrete states

A Context3 is compatible with a particular System3, but is otherwise independent of any actual System object. That is, if you had two identical System3 objects you could use the same Context3 object for both; there are no pointers from Context3 to non-static System3 data or methods.

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

Constructor & Destructor Documentation

Context3 ( )
inline
~Context3 ( )
inlineoverride
Context3 ( const Context3< T > &  source)
inline

Copy constructor makes a deep copy of the source Context3, and also copies the current values of time and any connected input and parameter ports into standalone internal values so that the entire computation context is preserved.

Member Function Documentation

std::unique_ptr<Context3<T> > Clone ( ) const
inline

Returns writable access to the State.

No cache invalidation occurs until mutable access is requested for particular blocks of state variables. Returns a deep copy of this Context3. The clone's input ports will hold deep copies of the data that appears on this context's input ports at the time the clone is created. This is a non-virtual "covariant" replacement for the base class Clone() method with a more derived pointer type.

Context3<T>* DoClone ( ) const
inlineoverrideprotectedvirtual

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.

Implements AbstractContext3.

Here is the call graph for this function:

const T& get_time ( ) const
inline

Returns the current time in seconds.

void set_time ( const T &  time_sec)
inline

Set the current time in seconds.


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