OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | List of all members
OpenDDS::DCPS::EventBase Struct Referenceabstract

#include <EventDispatcher.h>

Inheritance diagram for OpenDDS::DCPS::EventBase:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::EventBase:
Collaboration graph
[legend]

Public Member Functions

virtual ~EventBase ()
 
virtual void handle_event ()=0
 Called when the event is dispatched by an EventDispatcher. More...
 
virtual void handle_error ()
 Only called when an exception is caught during handle_event. More...
 
virtual void handle_cancel ()
 
void operator() ()
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

EventBase is an abstract base class for events

EventBase is an abstract base class for events dispatched or scheduled by an EventDispatcher. Derived classes are required to implement handle_event which will be called when the event is dispatched by the event dispatcher

Definition at line 27 of file EventDispatcher.h.

Constructor & Destructor Documentation

◆ ~EventBase()

OpenDDS::DCPS::EventBase::~EventBase ( )
virtual

Definition at line 17 of file EventDispatcher.cpp.

18 {
19 }

Member Function Documentation

◆ handle_cancel()

void OpenDDS::DCPS::EventBase::handle_cancel ( )
virtual

Called when the dispatch or schedule of an event is canceled by an EventDispatcher, for example when immediate shutdown is requested

Reimplemented in OpenDDS::DCPS::PeriodicEvent, and OpenDDS::DCPS::SporadicEvent.

Definition at line 25 of file EventDispatcher.cpp.

Referenced by OpenDDS::DCPS::ServiceEventDispatcher::cancel(), and OpenDDS::DCPS::ServiceEventDispatcher::shutdown().

26 {
27 }

◆ handle_error()

void OpenDDS::DCPS::EventBase::handle_error ( void  )
virtual

Only called when an exception is caught during handle_event.

Definition at line 21 of file EventDispatcher.cpp.

Referenced by operator()().

22 {
23 }

◆ handle_event()

virtual void OpenDDS::DCPS::EventBase::handle_event ( )
pure virtual

◆ operator()()

void OpenDDS::DCPS::EventBase::operator() ( void  )

Definition at line 29 of file EventDispatcher.cpp.

References OpenDDS::DCPS::RcObject::_remove_ref(), handle_error(), and handle_event().

30 {
31  try {
32  handle_event();
33  } catch (...) {
34  handle_error();
35  }
36  // In order to avoid extra allocations for containers of RcHandle<EventBase>
37  // implementations of EventDispatcher will increase the reference count of
38  // all queued EventBase objects, and decrement them when they are dispatched
39  // or canceled.
40  // Since the EventDispatcher does not directly hold copies of the events,
41  // decrementing the reference count after a normal dispatch currently needs
42  // to happen here in the call to EventBase::operator()() after handle_event.
43  this->_remove_ref();
44 }
virtual void handle_error()
Only called when an exception is caught during handle_event.
virtual void _remove_ref()
Definition: RcObject.h:74
virtual void handle_event()=0
Called when the event is dispatched by an EventDispatcher.

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