senf::ppi::EventImplementation< EventType > Class Template Reference

Event implementation base class. More...

#include <senf/PPI/Events.hh>

Inheritance diagram for senf::ppi::EventImplementation< EventType >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class EventType>
class senf::ppi::EventImplementation< EventType >

Event implementation base class.

EventImplementation provides the base-class for all Event implementations.

class SomeEvent : public EventImplementation<SomeEventArg>
{
public:
    SomeEvent() {}

private:
    virtual void v_enable() {
        // register cb() to be called when the event occurs
    }

    virtual void v_disable() {
        // unregister cb()
    }

    void cb() {
        // Build event argument
        SomeEventArg arg (...);
        // Call the event callback
        callback(arg);
    }
};

Every event needs to implement v_enable() and v_disable(). v_enable() should register some member (in the example cb() ) to be called whenever the event occurs, while v_disable() should unregister it.

The EventType argument to EventImplementation defines the type of argument passed to the user callback. It defaults to void. . This user callback is called from within the registered member (e.g. cb() ) by calling the inherited callback() member. This member takes an EventType reference as argument which will be forwarded to the user callback. If available, you should also provide the expected event time as a second argument.

Definition at line 178 of file Events.hh.


Public Types

typedef EventType  Event
typedef detail::EventArgType
< EventType >::type 
EventArg

Public Member Functions

module::Module module () const
  Module in which the event is registered.
EventManager manager () const
  EventManager of the event.

Protected Member Functions

  EventImplementation ()

Member Typedef Documentation

template<class EventType>
typedef EventType senf::ppi::EventImplementation< EventType >::
Event

Definition at line 183 of file Events.hh.

template<class EventType>
typedef detail::EventArgType<EventType>::type senf::ppi::EventImplementation< EventType >::
EventArg

Constructor & Destructor Documentation

template<class EventType >
senf::ppi::EventImplementation< EventType >::
EventImplementation ()

Definition at line 119 of file Events.cti.


Member Function Documentation

template<class EventType >
senf::ppi::EventManager & senf::ppi::EventImplementation< EventType >::
manager ()

EventManager of the event.

Definition at line 109 of file Events.cti.

template<class EventType >
senf::ppi::module::Module & senf::ppi::EventImplementation< EventType >::
module ()

Module in which the event is registered.

Definition at line 102 of file Events.cti.


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