libfilezilla
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
event_base Class Reference

Common base class for all events. More...

#include <event.hpp>

Inheritance diagram for event_base:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 event_base (event_base const &)
event_baseoperator= (event_base const &)
virtual void const * derived_type () const =0

Detailed Description

Common base class for all events.

If possible, use simple_event<> below instead of deriving from event_base directly.

Keep events as simple as possible. Avoid mutexes in your events.

Examples:
events.cpp, and timer_fizzbuzz.cpp.

Member Function Documentation

virtual void const* derived_type ( ) const [pure virtual]

The returned pointer must be unique for the derived type such that: event_base& a = ... event_base& b = ... assert((a.derived_type() == b.derived_type()) == (typeid(a) == typeid(b)));

Warning:
Using &typeid is tempting, but unspecifined (sic)
According to the C++ standard, the address of a static member function is unique for each type. Unfortunately this does not prevent optimizing compilers to pool identical functions.

Best solution is to have your derived type return the address of a static data member of it, as done in simple_event.

Implemented in final< UniqueType, Values >.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines