Drake
Drake C++ Documentation
BusValue Class Referencefinal

Detailed Description

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).

See also
BusCreator, BusSelector

#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 AbstractValueFind (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 &)
 
BusValueoperator= (const BusValue &)
 
 BusValue (BusValue &&)
 
BusValueoperator= (BusValue &&)
 
Iterators

The iteration order is deterministic but unspecified.

Iterator begin () const
 
Iterator end () const
 

Member Typedef Documentation

◆ const_iterator

◆ value_type

using value_type = std::pair<const std::string_view, const AbstractValue&>

Constructor & Destructor Documentation

◆ BusValue() [1/3]

BusValue ( const BusValue )

◆ BusValue() [2/3]

BusValue ( BusValue &&  )

◆ BusValue() [3/3]

BusValue ( )

Constructs an empty BusValue.

◆ ~BusValue()

~BusValue ( )

Member Function Documentation

◆ begin()

Iterator begin ( ) const

◆ Clear()

void Clear ( )

Removes all signals from this.

Invalidates all iterators.

◆ end()

BusValue::Iterator end ( ) const

◆ Find()

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.

◆ operator=() [1/2]

BusValue& operator= ( BusValue &&  )

◆ operator=() [2/2]

BusValue& operator= ( const BusValue )

◆ Set()

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.

Warning
Within a group of BusValue objects that are expected to inter-operate (i.e., to be copied or assigned to each other), the type of the 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.

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