Drake
Drake C++ Documentation
DiagramEventCollection< EventType > Class Template Referencefinal

Detailed Description

template<typename EventType>
class drake::systems::DiagramEventCollection< EventType >

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
 
DiagramEventCollectionoperator= (const DiagramEventCollection &)=delete
 
 DiagramEventCollection (DiagramEventCollection &&)=delete
 
DiagramEventCollectionoperator= (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
 
EventCollectionoperator= (const EventCollection &)=delete
 
 EventCollection (EventCollection &&)=delete
 
EventCollectionoperator= (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...
 

Constructor & Destructor Documentation

◆ DiagramEventCollection() [1/3]

DiagramEventCollection ( const DiagramEventCollection< EventType > &  )
delete

◆ DiagramEventCollection() [2/3]

DiagramEventCollection ( DiagramEventCollection< EventType > &&  )
delete

◆ DiagramEventCollection() [3/3]

DiagramEventCollection ( int  num_subsystems)
explicit

Note that this constructor only resizes the containers; it does not allocate any derived EventCollection instances.

Parameters
num_subsystemsNumber of subsystems in the corresponding Diagram.

Member Function Documentation

◆ AddEvent()

void AddEvent ( EventType  )
finalvirtual

Throws if called, because no events should be added at the Diagram level.

Implements EventCollection< EventType >.

◆ Clear()

void Clear ( )
finalvirtual

Clears all subevent collections.

Implements EventCollection< EventType >.

◆ DoAddToEnd()

void DoAddToEnd ( const EventCollection< EventType > &  other_collection)
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.)

Exceptions
std::exceptionif other_collection is not an instance of DiagramEventCollection.

Implements EventCollection< EventType >.

◆ get_mutable_subevent_collection()

EventCollection<EventType>& get_mutable_subevent_collection ( int  index)

Returns a mutable pointer to subsystem's EventCollection at index.

◆ get_subevent_collection()

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

◆ HasEvents()

bool HasEvents ( ) const
finalvirtual

Returns true if and only if any of the subevent collections have any events.

Implements EventCollection< EventType >.

◆ num_subsystems()

int num_subsystems ( ) const

Returns the number of constituent EventCollection objects that correspond to each subsystem in the Diagram.

◆ operator=() [1/2]

DiagramEventCollection& operator= ( const DiagramEventCollection< EventType > &  )
delete

◆ operator=() [2/2]

DiagramEventCollection& operator= ( DiagramEventCollection< EventType > &&  )
delete

◆ set_and_own_subevent_collection()

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.

◆ set_subevent_collection()

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.


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