BasicEvent< T > Class Template Reference

#include <Pt/Event.h>

Event base that clones, destroys and identifies a derived type T. More...

Inherits Event.

Public Member Functions

Eventclone (Allocator &allocator) const
 Clones this event using an allocator.
void destroy (Allocator &allocator)
 Destroys this event using an allocator.
const std::type_info & typeInfo () const
 Returns the type info for this class of events.

Static Public Member Functions

template<typename EventT>
static EventcopyConstruct (const EventT &ev, Allocator &allocator)
 Copies an event using an allocator.
template<typename EventT>
static void destruct (EventT &ev, Allocator &allocator)
 Destructs an event using an allocator.

Protected Member Functions

virtual const std::type_info & onTypeInfo () const
 Returns the type info for this class of events.
virtual EventonClone (Allocator &allocator) const
 Clones this event using an allocator.
virtual void onDestroy (Allocator &allocator)
 Destroys this event using an allocator.

Detailed Description

template<typename T>
class Pt::BasicEvent< T >

Derive as class MyEvent : public BasicEvent<MyEvent>. T is the derived type. onTypeInfo() returns typeid(T). onClone() allocates sizeof(T) from the allocator and copy-constructs T. onDestroy() runs the BasicEvent destructor and returns that storage to the allocator.

The derived class must be copy-constructible. It does not override the three hooks unless it needs a different allocation size or copy. Construction of BasicEvent is protected, so it is only a base.