A concrete class that holds all simultaneous homogeneous events for a Diagram.
For each subsystem in the corresponding Diagram, a derived EventCollection instance is maintained internally, thus effectively holding the same recursive tree structure as the corresponding Diagram.
This class uses an unusual paradigm for storing collections of events corresponding to subsystems of the diagram ("subevent collections"). The class owns some subevent collections and maintains pointers to other subevent collections. The technical reasoning is that the same data may need to be referenced by multiple collections; DiagramCompositeEventCollection maintains one collection for all publish events and another for the events from each subsystem, but maintains only a single copy of all of the event data.
End users should never need to use or know about this class. It is for internal use only.
#include <drake/systems/framework/event_collection.h>
Public Member Functions | |
DiagramEventCollection (int num_subsystems) | |
Note that this constructor only resizes the containers; it does not allocate any derived EventCollection instances. More... | |
void | AddEvent (EventType) final |
Throws if called, because no events should be added at the Diagram level. More... | |
int | num_subsystems () const |
Returns the number of constituent EventCollection objects that correspond to each subsystem in the Diagram. More... | |
void | set_and_own_subevent_collection (int index, std::unique_ptr< EventCollection< EventType >> subevent_collection) |
Transfers subevent_collection ownership to this and associates it with the subsystem identified by index . More... | |
void | set_subevent_collection (int index, EventCollection< EventType > *subevent_collection) |
Associate subevent_collection with subsystem identified by index . More... | |
const EventCollection< EventType > & | get_subevent_collection (int index) const |
Returns a const pointer to subsystem's EventCollection at index . More... | |
EventCollection< EventType > & | get_mutable_subevent_collection (int index) |
Returns a mutable pointer to subsystem's EventCollection at index . More... | |
void | Clear () final |
Clears all subevent collections. More... | |
bool | HasEvents () const final |
Returns true if and only if any of the subevent collections have any events. More... | |
Does not allow copy, move, or assignment | |
DiagramEventCollection (const DiagramEventCollection &)=delete | |
DiagramEventCollection & | operator= (const DiagramEventCollection &)=delete |
DiagramEventCollection (DiagramEventCollection &&)=delete | |
DiagramEventCollection & | operator= (DiagramEventCollection &&)=delete |
Public Member Functions inherited from EventCollection< EventType > | |
virtual | ~EventCollection () |
void | SetFrom (const EventCollection< EventType > &other) |
Clears all the events maintained by this then adds all of the events in other to this. More... | |
void | AddToEnd (const EventCollection< EventType > &other) |
Adds all of other 's events to the end of this . More... | |
EventCollection (const EventCollection &)=delete | |
EventCollection & | operator= (const EventCollection &)=delete |
EventCollection (EventCollection &&)=delete | |
EventCollection & | operator= (EventCollection &&)=delete |
Protected Member Functions | |
void | DoAddToEnd (const EventCollection< EventType > &other_collection) final |
Goes through each subevent collection of this and adds the corresponding one in other_collection to the subevent collection in this . More... | |
Protected Member Functions inherited from EventCollection< EventType > | |
EventCollection ()=default | |
Constructor only accessible by derived class. More... | |
|
delete |
|
delete |
|
explicit |
Note that this constructor only resizes the containers; it does not allocate any derived EventCollection instances.
num_subsystems | Number of subsystems in the corresponding Diagram. |
|
finalvirtual |
Throws if called, because no events should be added at the Diagram level.
Implements EventCollection< EventType >.
|
finalvirtual |
Clears all subevent collections.
Implements EventCollection< EventType >.
|
finalprotectedvirtual |
Goes through each subevent collection of this
and adds the corresponding one in other_collection
to the subevent collection in this
.
Aborts if this
does not have the same number of subevent collections as other_collection
. In addition, this method assumes that this
and other_collection
have the exact same topology (i.e. both are created for the same Diagram.)
std::exception | if other_collection is not an instance of DiagramEventCollection. |
Implements EventCollection< EventType >.
EventCollection<EventType>& get_mutable_subevent_collection | ( | int | index | ) |
Returns a mutable pointer to subsystem's EventCollection at index
.
const EventCollection<EventType>& get_subevent_collection | ( | int | index | ) | const |
Returns a const pointer to subsystem's EventCollection at index
.
Aborts if the 0-indexed index
is greater than or equal to the number of subsystems specified in this object's construction (see DiagramEventCollection(int)) or if index
is not in the range [0, num_subsystems() - 1].
|
finalvirtual |
Returns true
if and only if any of the subevent collections have any events.
Implements EventCollection< EventType >.
int num_subsystems | ( | ) | const |
Returns the number of constituent EventCollection objects that correspond to each subsystem in the Diagram.
|
delete |
|
delete |
void set_and_own_subevent_collection | ( | int | index, |
std::unique_ptr< EventCollection< EventType >> | subevent_collection | ||
) |
Transfers subevent_collection
ownership to this
and associates it with the subsystem identified by index
.
Aborts if index
is not in the range [0, num_subsystems() - 1] or if subevent_collection
is null.
void set_subevent_collection | ( | int | index, |
EventCollection< EventType > * | subevent_collection | ||
) |
Associate subevent_collection
with subsystem identified by index
.
Ownership of the object that subevent_collection
is maintained elsewhere, and its life span must be longer than this. Aborts if index
is not in the range [0, num_subsystems() - 1] or if subevent_collection
is null.