maliput
|
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.
#include <src/maliput/drake/systems/framework/model_values.h>
Public Member Functions | |
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN (ModelValues) | |
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< AbstractValue > | CloneModel (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... | |
|
default |
void AddModel | ( | int | index, |
std::unique_ptr< AbstractValue > | model_value | ||
) |
Sets model_value
to be the model value for index
.
void AddVectorModel | ( | int | index, |
std::unique_ptr< BasicVector< T >> | model_vector | ||
) |
std::vector<std::unique_ptr<AbstractValue> > CloneAllModels | ( | ) | const |
Returns a vector of all the cloned model values. Some may be nullptr.
std::unique_ptr< AbstractValue > CloneModel | ( | int | index | ) | const |
Returns a clone of the model value at index
, which may be nullptr.
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.
std::exception | if the index has a model but the model's type does not match the given T |
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN | ( | ModelValues | ) |
int size | ( | ) | const |
Returns one greater than the largest index passed to AddModel or AddVectorModel.