BusValue is a value type used on input ports and output ports to group labeled signals into a single port.
Each signal is referred to by a unique name and stored using an AbstractValue.
In some cases the signal names are used only for human-readable logging or debugging, so can be anything. In other cases, the systems using the signals will require the signals to use specific names per some convention (e.g., for a BusSelector the signal names must match the output port names).
#include <drake/systems/framework/bus_value.h>
Classes | |
class | Iterator |
Provides a forward_iterator over BusValue signals. More... | |
Public Types | |
Container-like type aliases | |
using | const_iterator = Iterator |
using | value_type = std::pair< const std::string_view, const AbstractValue & > |
Public Member Functions | |
BusValue () | |
Constructs an empty BusValue. More... | |
~BusValue () | |
const AbstractValue * | Find (std::string_view name) const |
Gets one signal value. More... | |
void | Clear () |
Removes all signals from this. More... | |
void | Set (std::string_view name, const AbstractValue &value) |
Sets one signal value. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
BusValue (const BusValue &) | |
BusValue & | operator= (const BusValue &) |
BusValue (BusValue &&) | |
BusValue & | operator= (BusValue &&) |
Iterators | |
The iteration order is deterministic but unspecified. | |
Iterator | begin () const |
Iterator | end () const |
using const_iterator = Iterator |
using value_type = std::pair<const std::string_view, const AbstractValue&> |
BusValue | ( | ) |
Constructs an empty BusValue.
~BusValue | ( | ) |
Iterator begin | ( | ) | const |
void Clear | ( | ) |
Removes all signals from this.
Invalidates all iterators.
BusValue::Iterator end | ( | ) | const |
const AbstractValue* Find | ( | std::string_view | name | ) | const |
Gets one signal value.
Returns nullptr if not found. Does not invalidate any iterators, but the return value is invalidated by a call to any non-const method on this.
void Set | ( | std::string_view | name, |
const AbstractValue & | value | ||
) |
Sets one signal value.
Invalidates all iterators. The name
can be any string without restriction, although we encourage valid UTF-8.
value
for a given name
is expected to be consistent (i.e., homogenous) across the entire group of objects. After setting a name
to some value the first time, every subsequent call to Set on the same BusValue object for that same name
must provide a value of the same type, even if the object has since been cleared or copied onto another object. The only way to reset the hysteresis for the "presumed type" of a name is to construct a new BusValue object. Failure to keep the types consistent may result in an exception at runtime. However, we might relax this restriction in the future, so don't count on it for error handling.