Drake
DiagramDiscreteValues< T > Class Template Referencefinal

DiagramDiscreteValues is a DiscreteValues container comprised recursively of a sequence of child DiscreteValues objects. More...

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

Inheritance diagram for DiagramDiscreteValues< T >:
[legend]
Collaboration diagram for DiagramDiscreteValues< T >:
[legend]

Public Member Functions

 DiagramDiscreteValues (std::vector< DiscreteValues< T > * > subdiscretes)
 Constructs a DiagramDiscreteValues object that is composed of other DiscreteValues, which are not owned by this object and must outlive it. More...
 
 DiagramDiscreteValues (std::vector< std::unique_ptr< DiscreteValues< T >>> owned_subdiscretes)
 Constructs a DiagramDiscreteValues object that is composed (recursively) of other DiscreteValues objects, ownership of which is transferred here. More...
 
 ~DiagramDiscreteValues () override
 Destructor deletes any owned DiscreteValues objects but does nothing if the referenced DiscreteValues objects are unowned. More...
 
std::unique_ptr< DiagramDiscreteValuesClone () const
 Creates a deep copy of this DiagramDiscreteValues object, with the same substructure but with new, owned data. More...
 
int num_subdiscretes () const
 Returns the number of DiscreteValues objects referenced by this DiagramDiscreteValues object, necessarily the same as the number of subcontexts in the containing DiagramContext. More...
 
const DiscreteValues< T > & get_subdiscrete (SubsystemIndex index) const
 Returns a const reference to one of the referenced DiscreteValues objects which may or may not be owned locally. More...
 
DiscreteValues< T > & get_mutable_subdiscrete (SubsystemIndex index)
 Returns a mutable reference to one of the referenced DiscreteValues objects which may or may not be owned locally. More...
 
Does not allow copy, move, or assignment
 DiagramDiscreteValues (const DiagramDiscreteValues &)=delete
 
DiagramDiscreteValuesoperator= (const DiagramDiscreteValues &)=delete
 
 DiagramDiscreteValues (DiagramDiscreteValues &&)=delete
 
DiagramDiscreteValuesoperator= (DiagramDiscreteValues &&)=delete
 
- Public Member Functions inherited from DiscreteValues< T >
 DiscreteValues ()
 Constructs an empty DiscreteValues object containing no groups. More...
 
 DiscreteValues (const std::vector< BasicVector< T > * > &data)
 Constructs a DiscreteValues that does not own the underlying data. More...
 
 DiscreteValues (std::vector< std::unique_ptr< BasicVector< T >>> &&data)
 Constructs a DiscreteValues that owns the underlying data. More...
 
 DiscreteValues (std::unique_ptr< BasicVector< T >> datum)
 Constructs a one-group DiscreteValues object that owns a single datum vector which may not be null. More...
 
virtual ~DiscreteValues ()
 
int num_groups () const
 
const std::vector< BasicVector< T > * > & get_data () const
 
const BasicVector< T > & get_vector (int index) const
 Returns a const reference to the vector holding data for the indicated group. More...
 
BasicVector< T > & get_mutable_vector (int index)
 Returns a mutable reference to the vector holding data for the indicated group. More...
 
void CopyFrom (const DiscreteValues< T > &other)
 Writes the values from other into this DiscreteValues, possibly writing through to unowned data. More...
 
void SetFrom (const DiscreteValues< double > &other)
 Resets the values in this DiscreteValues from the values in other, possibly writing through to unowned data. More...
 
std::unique_ptr< DiscreteValues< T > > Clone () const
 Creates a deep copy of this object with the same substructure but with all data owned by the copy. More...
 
 DiscreteValues (const DiscreteValues &)=delete
 
DiscreteValuesoperator= (const DiscreteValues &)=delete
 
 DiscreteValues (DiscreteValues &&)=delete
 
DiscreteValuesoperator= (DiscreteValues &&)=delete
 
int size () const
 Returns the number of elements in the only DiscreteValues group. More...
 
T & operator[] (std::size_t idx)
 Returns a mutable reference to an element in the only group. More...
 
const T & operator[] (std::size_t idx) const
 Returns a const reference to an element in the only group. More...
 
const BasicVector< T > & get_vector () const
 Returns a const reference to the BasicVector containing the values for the only group. More...
 
BasicVector< T > & get_mutable_vector ()
 Returns a mutable reference to the BasicVector containing the values for the only group. More...
 

Detailed Description

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

DiagramDiscreteValues is a DiscreteValues container comprised recursively of a sequence of child DiscreteValues objects.

The API allows this to be treated as though it were a single DiscreteValues object whose groups are the concatenation of the groups in each child.

The child objects may be owned or not. When this is used to aggregate LeafSystem discrete values in a Diagram, the child objects are not owned. When this is cloned, deep copies are made that are owned here.

Constructor & Destructor Documentation

DiagramDiscreteValues ( const DiagramDiscreteValues< T > &  )
delete
DiagramDiscreteValues ( std::vector< DiscreteValues< T > * >  subdiscretes)
inlineexplicit

Constructs a DiagramDiscreteValues object that is composed of other DiscreteValues, which are not owned by this object and must outlive it.

The DiagramDiscreteValues vector xd = [xd₁ xd₂ ...] where each of the xdᵢ is an array of BasicVector objects. These will have the same ordering as the subdiscretes parameter, which should be the order of the Diagram itself. That is, the substates should be indexed by SubsystemIndex in the same order as the subsystems are.

DiagramDiscreteValues ( std::vector< std::unique_ptr< DiscreteValues< T >>>  owned_subdiscretes)
inlineexplicit

Constructs a DiagramDiscreteValues object that is composed (recursively) of other DiscreteValues objects, ownership of which is transferred here.

~DiagramDiscreteValues ( )
inlineoverride

Destructor deletes any owned DiscreteValues objects but does nothing if the referenced DiscreteValues objects are unowned.

Member Function Documentation

std::unique_ptr<DiagramDiscreteValues> Clone ( ) const
inline

Creates a deep copy of this DiagramDiscreteValues object, with the same substructure but with new, owned data.

Intentionally shadows the DiscreteValues::Clone() method but with a more-specific return type so you don't have to downcast.

Here is the call graph for this function:

DiscreteValues<T>& get_mutable_subdiscrete ( SubsystemIndex  index)
inline

Returns a mutable reference to one of the referenced DiscreteValues objects which may or may not be owned locally.

Here is the call graph for this function:

const DiscreteValues<T>& get_subdiscrete ( SubsystemIndex  index) const
inline

Returns a const reference to one of the referenced DiscreteValues objects which may or may not be owned locally.

Here is the call graph for this function:

Here is the caller graph for this function:

int num_subdiscretes ( ) const
inline

Returns the number of DiscreteValues objects referenced by this DiagramDiscreteValues object, necessarily the same as the number of subcontexts in the containing DiagramContext.

Here is the caller graph for this function:

DiagramDiscreteValues& operator= ( const DiagramDiscreteValues< T > &  )
delete
DiagramDiscreteValues& operator= ( DiagramDiscreteValues< T > &&  )
delete

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