Drake
PublishEvent< T > Class Template Referencefinal

Detailed Description

template<typename T>
class drake::systems::PublishEvent< T >

This class represents a publish event.

It has an optional callback function (two forms are supported) to do custom handling of this event.

See also
System::Publish for more details.
LeafSystem for more convenient interfaces to publish events via the Declare*PublishEvent() methods.

#include <drake/systems/framework/event.h>

Public Types

Publish Callbacks

Two callback signatures are supported.

See Event Callbacks for a complete discussion. Both callback types receive a const reference to the context and this publish event. They differ in whether a const reference to the owning system is also provided.

typedef std::function< void(const Context< T > &, const PublishEvent< T > &)> PublishCallback
 Callback without system reference. More...
 
typedef std::function< void(const System< T > &, const Context< T > &, const PublishEvent< T > &)> SystemCallback
 Callback with const system reference. More...
 
- Public Types inherited from Event< T >
using TriggerType = systems::TriggerType
 

Public Member Functions

bool is_discrete_update () const override
 Returns true if this is a DiscreteUpdateEvent. More...
 
 PublishEvent ()
 Makes a PublishEvent with no trigger type, no event data, and no specified callback function. More...
 
 PublishEvent (const PublishCallback &callback)
 Makes a PublishEvent with no trigger type, no event data, and the specified callback function. More...
 
 PublishEvent (const SystemCallback &system_callback)
 Makes a PublishEvent with no trigger type, no event data, and the specified system callback function. More...
 
void handle (const System< T > &system, const Context< T > &context) const
 Calls the optional callback or system callback function, if one exists, with system, context, and this. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 PublishEvent (const PublishEvent &)=default
 
PublishEventoperator= (const PublishEvent &)=default
 
 PublishEvent (PublishEvent &&)=default
 
PublishEventoperator= (PublishEvent &&)=default
 
- Public Member Functions inherited from Event< T >
std::unique_ptr< EventClone () const
 Clones this instance. More...
 
TriggerType get_trigger_type () const
 Returns the trigger type. More...
 
bool has_event_data () const
 Returns true if this event has associated data. More...
 
const EventDataget_event_data () const
 Returns a const pointer to the event data. More...
 
EventDataget_mutable_event_data ()
 Returns a mutable pointer to the event data. More...
 
void AddToComposite (TriggerType trigger_type, CompositeEventCollection< T > *events) const
 Adds a clone of this event to the event collection events, with the given trigger type. More...
 
void AddToComposite (CompositeEventCollection< T > *events) const
 Provides an alternate signature for adding an Event that already has the correct trigger type set. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Event< T >
 Event (const Event &)=default
 
Eventoperator= (const Event &)=default
 
 Event (Event &&)=default
 
Eventoperator= (Event &&)=default
 

Member Typedef Documentation

◆ PublishCallback

typedef std::function<void(const Context<T>&, const PublishEvent<T>&)> PublishCallback

Callback without system reference.

◆ SystemCallback

typedef std::function<void(const System<T>&, const Context<T>&, const PublishEvent<T>&)> SystemCallback

Callback with const system reference.

Constructor & Destructor Documentation

◆ PublishEvent() [1/5]

PublishEvent ( const PublishEvent< T > &  )
default

◆ PublishEvent() [2/5]

PublishEvent ( PublishEvent< T > &&  )
default

◆ PublishEvent() [3/5]

Makes a PublishEvent with no trigger type, no event data, and no specified callback function.

◆ PublishEvent() [4/5]

PublishEvent ( const PublishCallback callback)
explicit

Makes a PublishEvent with no trigger type, no event data, and the specified callback function.

◆ PublishEvent() [5/5]

PublishEvent ( const SystemCallback system_callback)
explicit

Makes a PublishEvent with no trigger type, no event data, and the specified system callback function.

Member Function Documentation

◆ handle()

void handle ( const System< T > &  system,
const Context< T > &  context 
) const

Calls the optional callback or system callback function, if one exists, with system, context, and this.

◆ is_discrete_update()

bool is_discrete_update ( ) const
overridevirtual

Returns true if this is a DiscreteUpdateEvent.

Implements Event< T >.

◆ operator=() [1/2]

PublishEvent& operator= ( const PublishEvent< T > &  )
default

◆ operator=() [2/2]

PublishEvent& operator= ( PublishEvent< T > &&  )
default

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