Drake
LeafEventCollection< EventType > Class Template Reference

Detailed Description

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

A concrete class that holds all simultaneous homogeneous events for a LeafSystem.

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

 LeafEventCollection ()
 Constructor. More...
 
void Reserve (int capacity)
 Reserve storage for at least capacity events. More...
 
const std::vector< const EventType * > & get_events () const
 Returns a const reference to the vector of const pointers to all of the events. More...
 
void AddEvent (EventType event) final
 Add event to the existing collection. More...
 
bool HasEvents () const final
 Returns true if and only if this collection is nonempty. More...
 
void Clear () final
 Removes all events from this collection. More...
 
Does not allow copy, move, or assignment
 LeafEventCollection (const LeafEventCollection &)=delete
 
LeafEventCollectionoperator= (const LeafEventCollection &)=delete
 
 LeafEventCollection (LeafEventCollection &&)=delete
 
LeafEventCollectionoperator= (LeafEventCollection &&)=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
 

Static Public Member Functions

static std::unique_ptr< LeafEventCollection< EventType > > MakeForcedEventCollection ()
 Static method that generates a LeafEventCollection with exactly one event with no optional attribute, data or callback, and trigger type kForced. More...
 

Static Public Attributes

static constexpr int kDefaultCapacity = 32
 The default capacity of event storage allocation, expressed as a number of events. More...
 

Protected Member Functions

void DoAddToEnd (const EventCollection< EventType > &other_collection) final
 All events in other_collection are concatenated to this. More...
 
- Protected Member Functions inherited from EventCollection< EventType >
 EventCollection ()=default
 Constructor only accessible by derived class. More...
 

Constructor & Destructor Documentation

◆ LeafEventCollection() [1/3]

LeafEventCollection ( const LeafEventCollection< EventType > &  )
delete

◆ LeafEventCollection() [2/3]

LeafEventCollection ( LeafEventCollection< EventType > &&  )
delete

◆ LeafEventCollection() [3/3]

Constructor.

Member Function Documentation

◆ AddEvent()

void AddEvent ( EventType  event)
finalvirtual

Add event to the existing collection.

Implements EventCollection< EventType >.

◆ Clear()

void Clear ( )
finalvirtual

Removes all events from this collection.

Implements EventCollection< EventType >.

◆ DoAddToEnd()

void DoAddToEnd ( const EventCollection< EventType > &  other_collection)
finalprotectedvirtual

All events in other_collection are concatenated to this.

Here is an example. Suppose this collection stores the following events:

  EventType: {event1, event2, event3}

other_collection has:

  EventType: {event4}

After calling DoAddToEnd(other_collection), this stores:

  EventType: {event1, event2, event3, event4}
Exceptions
std::exceptionif other_collection is not an instance of LeafEventCollection.

Implements EventCollection< EventType >.

◆ get_events()

const std::vector<const EventType*>& get_events ( ) const

Returns a const reference to the vector of const pointers to all of the events.

◆ HasEvents()

bool HasEvents ( ) const
finalvirtual

Returns true if and only if this collection is nonempty.

Implements EventCollection< EventType >.

◆ MakeForcedEventCollection()

static std::unique_ptr<LeafEventCollection<EventType> > MakeForcedEventCollection ( )
static

Static method that generates a LeafEventCollection with exactly one event with no optional attribute, data or callback, and trigger type kForced.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ Reserve()

void Reserve ( int  capacity)

Reserve storage for at least capacity events.

At construction, there will be at least kDefaultCapacity; use this method to reserve more.

Member Data Documentation

◆ kDefaultCapacity

constexpr int kDefaultCapacity = 32
static

The default capacity of event storage allocation, expressed as a number of events.

Chosen to be large enough that most systems won't need to allocate during simulation advance steps.


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