Drake
ModelValues Class Reference

Represents models for a sequence of AbstractValues (usually a sequence of either input or output ports). More...

#include <systems/framework/model_values.h>

## Public Member Functions

ModelValues ()=default

int size () const
Returns one greater than the largest index passed to AddModel or AddVectorModel. More...

void AddModel (int index, std::unique_ptr< AbstractValue > model_value)
Sets model_value to be the model value for index. More...

template<typename T >
void AddVectorModel (int index, std::unique_ptr< BasicVector< T >> model_vector)
Wraps model_vector in a Value and sets that to be the model value for index. More...

std::unique_ptr< AbstractValueCloneModel (int index) const
Returns a clone of the model value at index, which may be nullptr. More...

std::vector< std::unique_ptr< AbstractValue > > CloneAllModels () const
Returns a vector of all the cloned model values. Some may be nullptr. More...

template<typename T >
std::unique_ptr< BasicVector< T > > CloneVectorModel (int index) const
Returns a clone of the vector within the model value at index, which may be nullptr. More...

Does not allow copy, move, or assignment
ModelValues (const ModelValues &)=delete

ModelValuesoperator= (const ModelValues &)=delete

ModelValues (ModelValues &&)=delete

ModelValuesoperator= (ModelValues &&)=delete

## Detailed Description

Represents models for a sequence of AbstractValues (usually a sequence of either input or output ports).

The models are the "prototype" design pattern (https://en.wikipedia.org/wiki/Prototype_pattern). When creating elements in new Context, these models' values are cloned to establish the subtype and default values of the, e.g. input port.

Conceptually, the ModelValues form an infinite sequence. The value at a given index is allowed to be absent, in which case the CloneModel method will return nullptr. Adding new values must be monotonic; new values must use strictly larger indices; the model value for a given index cannot be reset.

## Constructor & Destructor Documentation

 ModelValues ( const ModelValues & )
delete
 ModelValues ( ModelValues && )
delete
 ModelValues ( )
default

## Member Function Documentation

 void AddModel ( int index, std::unique_ptr< AbstractValue > model_value )

Sets model_value to be the model value for index.

Precondition
index >= size()

Here is the call graph for this function:

Here is the caller graph for this function:

 void AddVectorModel ( int index, std::unique_ptr< BasicVector< T >> model_vector )

Wraps model_vector in a Value and sets that to be the model value for index.

Precondition
index >= size()

Here is the call graph for this function:

 std::vector > CloneAllModels ( ) const
inline

Returns a vector of all the cloned model values. Some may be nullptr.

Here is the call graph for this function:

 std::unique_ptr< AbstractValue > CloneModel ( int index ) const

Returns a clone of the model value at index, which may be nullptr.

Here is the call graph for this function:

Here is the caller graph for this function:

 std::unique_ptr< BasicVector< T > > CloneVectorModel ( int index ) const

Returns a clone of the vector within the model value at index, which may be nullptr.

Exceptions
 exception if the index has a model but the model's type does not match the given T

Here is the call graph for this function:

Here is the caller graph for this function:

 ModelValues& operator= ( ModelValues && )
delete
 ModelValues& operator= ( const ModelValues & )
delete
 int size ( ) const

Returns one greater than the largest index passed to AddModel or AddVectorModel.

Here is the caller graph for this function:

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