34 #include <Pt/Allocator.h>
88 virtual const std::type_info&
onTypeInfo()
const = 0;
93 template <
typename EventT>
96 void* mem = allocator.
allocate(
sizeof(EventT) );
97 EventT* pev =
new (mem) EventT(ev);
103 template <
typename EventT>
111 template <
typename T>
112 class BasicEvent :
public Event
118 virtual const std::type_info& onTypeInfo()
const
119 {
return typeid(T); }
121 virtual Event& onClone(Allocator& allocator)
const
123 void* pEvent = allocator.allocate(
sizeof(T));
124 return *(
new (pEvent)T(*static_cast<const T*>(
this)));
127 virtual void onDestroy(Allocator& allocator)
130 allocator.deallocate(
this,
sizeof(T));
virtual void * allocate(std::size_t size)
Allocates size bytes of memory.
Definition: Allocator.h:96
virtual const std::type_info & onTypeInfo() const =0
Returns the type info for this class of events.
Base class for all event types.
Definition: Event.h:49
virtual ~Event()
Destructor.
Definition: Event.h:54
Event()
Constructor.
Definition: Event.h:75
virtual Event & onClone(Allocator &allocator) const =0
Clones this event using an allocator.
virtual void onDestroy(Allocator &allocator)=0
Destroys this event using an allocator.
static Event & copyConstruct(const EventT &ev, Allocator &allocator)
Copies an event using an allocator.
Definition: Event.h:94
void destroy(Allocator &allocator)
Destroys this event using an allocator.
Definition: Event.h:64
static void destruct(EventT &ev, Allocator &allocator)
Destructs an event using an allocator.
Definition: Event.h:104
virtual void deallocate(void *p, std::size_t)
Deallocates memory of size bytes.
Definition: Allocator.h:103
Allocator interface.
Definition: Allocator.h:81
const std::type_info & typeInfo() const
Returns the type info for this class of events.
Definition: Event.h:69
Event & clone(Allocator &allocator) const
Clones this event using an allocator.
Definition: Event.h:59