Drake
Drake C++ Documentation
DiagramDiscreteValues< T > Class Template Referencefinal

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.

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

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...
 
int AppendGroup (std::unique_ptr< BasicVector< T >> datum)
 Adds an additional group that owns the given datum, which must be non-null. More...
 
virtual ~DiscreteValues ()
 
int num_groups () const
 
const std::vector< BasicVector< T > * > & get_data () const
 
template<typename U >
void SetFrom (const DiscreteValues< U > &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 VectorX< T > & value () const
 Returns a const reference to the underlying VectorX containing the values for the only group. More...
 
void set_value (const Eigen::Ref< const VectorX< T >> &value)
 Sets the vector to the given value for the only group. More...
 
Eigen::VectorBlock< VectorX< T > > get_mutable_value ()
 Returns the entire vector for the only group as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be called on the vector. More...
 
const BasicVector< T > & get_vector () const
 (Advanced) Returns a const reference to the BasicVector containing the values for the only group. More...
 
BasicVector< T > & get_mutable_vector ()
 (Advanced) Returns a mutable reference to the BasicVector containing the values for the only group. More...
 
Eigen::VectorBlock< const VectorX< T > > get_value () const
 (Don't use this in new code) Returns the entire vector as a const Eigen::VectorBlock for the only group. More...
 
const VectorX< T > & value (int index) const
 Returns a const reference to the underlying VectorX containing the values for the indicated group. More...
 
Eigen::VectorBlock< VectorX< T > > get_mutable_value (int index)
 Returns the entire vector for the indicated group as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be called on the vector. More...
 
void set_value (int index, const Eigen::Ref< const VectorX< T >> &value)
 Sets the vector to the given value for the indicated group. More...
 
const BasicVector< T > & get_vector (int index) const
 (Advanced) Returns a const reference to the BasicVector holding data for the indicated group. More...
 
BasicVector< T > & get_mutable_vector (int index)
 (Advanced) Returns a mutable reference to the BasicVector holding data for the indicated group. More...
 
Eigen::VectorBlock< const VectorX< T > > get_value (int index) const
 (Don't use this in new code) Returns the entire vector as a const Eigen::VectorBlock for the indicated group. More...
 
internal::SystemId get_system_id () const
 (Internal use only) Gets the id of the subsystem that created this object. More...
 
void set_system_id (internal::SystemId id)
 (Internal use only) Records the id of the subsystem that created this object. More...
 

Constructor & Destructor Documentation

◆ DiagramDiscreteValues() [1/4]

DiagramDiscreteValues ( const DiagramDiscreteValues< T > &  )
delete

◆ DiagramDiscreteValues() [2/4]

◆ DiagramDiscreteValues() [3/4]

DiagramDiscreteValues ( std::vector< DiscreteValues< T > * >  subdiscretes)
explicit

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() [4/4]

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

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

◆ ~DiagramDiscreteValues()

~DiagramDiscreteValues ( )
override

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

Member Function Documentation

◆ Clone()

std::unique_ptr<DiagramDiscreteValues> Clone ( ) const

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.

◆ get_mutable_subdiscrete()

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.

◆ get_subdiscrete()

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.

◆ num_subdiscretes()

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.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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