MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::EventPublisher Class Reference

This is the base class for any class that generates and publishes events to subscribers. More...

#include <eventpublisher.h>

+ Inheritance diagram for Mezzanine::EventPublisher:
+ Collaboration diagram for Mezzanine::EventPublisher:

Public Types

typedef
EventContainer::const_iterator 
ConstEventIterator
 Const Iterator type for Event instances stored by this class.
 
typedef std::map< String, Event * > EventContainer
 Basic container type for Event storage by this class.
 
typedef EventContainer::iterator EventIterator
 Iterator type for Event instances stored by this class.
 

Public Member Functions

 EventPublisher ()
 Class constructor.
 
virtual ~EventPublisher ()
 Class destructor.
 
EventGetEvent (const String &EventName) const
 Gets an event in this publisher. More...
 
EventGetEventExcept (const String &EventName) const
 Gets an event in this publisher.

Exceptions
Thisversion differs from the non-except version in that if it fails to find the event specified it will throw a "II_IDENTITY_NOT_FOUND_EXCEPTION".
More...
 
EventSubscriberSlotSubscribe (const String &EventName, EventSubscriber *Sub)
 Adds a subscriber to this event. More...
 
EventSubscriberSlotSubscribe (const String &EventName, FunctorSubscriberSlot::FunctorDefinition *Funct, Boolean CleanUpAfter)
 Subscribes a functor object to this event. More...
 
EventSubscriberSlotSubscribe (const String &EventName, CFunctionSubscriberSlot::SubscriberFunction *CFunct)
 Subscribes a C-style function to this event. More...
 
EventSubscriberSlotSubscribe (const String &EventName, Scripting::iScript *SubScript)
 Subscribes a script to this event. More...
 
void Unsubscribe (EventSubscriber *Subscriber)
 Unsubscribes a single subscriber all events in this publisher. More...
 
void Unsubscribe (FunctorSubscriberSlot::FunctorDefinition *Funct)
 Unsubscribes a single subscriber all events in this publisher. More...
 
void Unsubscribe (CFunctionSubscriberSlot::SubscriberFunction *CFunct)
 Unsubscribes a single subscriber from all events in this publisher. More...
 
void Unsubscribe (Scripting::iScript *SubScript)
 Unsubscribes a single subscriber from all events in this publisher. More...
 
void Unsubscribe (EventSubscriberSlot *SubSlot)
 Unsubscribes a single subscriber from all events in this publisher. More...
 
void Unsubscribe (const String &EventName, EventSubscriber *Subscriber)
 Unsubscribes a single subscriber from the named event. More...
 
void Unsubscribe (const String &EventName, FunctorSubscriberSlot::FunctorDefinition *Funct)
 Unsubscribes a single subscriber from the named event. More...
 
void Unsubscribe (const String &EventName, CFunctionSubscriberSlot::SubscriberFunction *CFunct)
 Unsubscribes a single subscriber from the named event. More...
 
void Unsubscribe (const String &EventName, Scripting::iScript *SubScript)
 Unsubscribes a single subscriber from the named event. More...
 
void Unsubscribe (const String &EventName, EventSubscriberSlot *SubSlot)
 Unsubscribes a single subscriber from the named event. More...
 
Whole UnsubscribeAll ()
 Unsubscribes all subscribers from all events in this publisher. More...
 
Whole UnsubscribeAll (const String &EventName)
 Unsubscribes all subscribers from the named Event. More...
 

Protected Member Functions

EventAddEvent (const String &EventName)
 Creates a new event this Publisher can fire. More...
 
void FireEvent (const EventArguments &Args)
 Fires an event. More...
 
void RemoveAllEvents ()
 Removes all events in this Publisher. More...
 
void RemoveEvent (const String &EventName)
 Removes an existing event in this Publisher. More...
 

Protected Attributes

EventContainer Events
 A container storing all the Events published by this class by name. More...
 

Detailed Description

This is the base class for any class that generates and publishes events to subscribers.

Definition at line 55 of file eventpublisher.h.

Member Function Documentation

Event * Mezzanine::EventPublisher::AddEvent ( const String EventName)
protected

Creates a new event this Publisher can fire.

Note
If the event already exists, this will return the created event instead.
Parameters
EventNameThe name to be given to the new event.
Returns
Returns a pointer to the created or existing event.

Definition at line 53 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::FireEvent ( const EventArguments Args)
protected

Fires an event.

Parameters
ArgsThe arguments/event specific data related to this event.

Definition at line 65 of file eventpublisher.cpp.

Event * Mezzanine::EventPublisher::GetEvent ( const String EventName) const

Gets an event in this publisher.

Parameters
EventNameThe name of the event to retrieve.
Returns
Returns a pointer to the requested event.

Definition at line 89 of file eventpublisher.cpp.

Event * Mezzanine::EventPublisher::GetEventExcept ( const String EventName) const

Gets an event in this publisher.

Exceptions
Thisversion differs from the non-except version in that if it fails to find the event specified it will throw a "II_IDENTITY_NOT_FOUND_EXCEPTION".

Parameters
EventNameThe name of the event to retrieve.
Returns
Returns a pointer to the requested event.

Definition at line 96 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::RemoveAllEvents ( )
protected

Removes all events in this Publisher.

Definition at line 77 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::RemoveEvent ( const String EventName)
protected

Removes an existing event in this Publisher.

Parameters
EventNameThe name of the event to be removed.

Definition at line 68 of file eventpublisher.cpp.

EventSubscriberSlot * Mezzanine::EventPublisher::Subscribe ( const String EventName,
EventSubscriber Sub 
)

Adds a subscriber to this event.

Parameters
EventNameThe name of the event to subscribe to.
SubThe custom event subscriber.
Returns
Returns a pointer to the created Subscriber slot for the provided subscriber.

Definition at line 110 of file eventpublisher.cpp.

EventSubscriberSlot * Mezzanine::EventPublisher::Subscribe ( const String EventName,
FunctorSubscriberSlot::FunctorDefinition Funct,
Boolean  CleanUpAfter 
)

Subscribes a functor object to this event.

Parameters
EventNameThe name of the event to subscribe to.
FunctThe functor to call when the event is fired.
CleanUpAfterWhether or not to delete the functor when this subscriber is no longer subscribed to any events.
Returns
Returns a pointer to the created Subscriber slot for the provided subscriber.

Definition at line 113 of file eventpublisher.cpp.

EventSubscriberSlot * Mezzanine::EventPublisher::Subscribe ( const String EventName,
CFunctionSubscriberSlot::SubscriberFunction CFunct 
)

Subscribes a C-style function to this event.

Parameters
EventNameThe name of the event to subscribe to.
CFunctThe C-style function to call when the event is fired.
Returns
Returns a pointer to the created Subscriber slot for the provided subscriber.

Definition at line 116 of file eventpublisher.cpp.

EventSubscriberSlot * Mezzanine::EventPublisher::Subscribe ( const String EventName,
Scripting::iScript SubScript 
)

Subscribes a script to this event.

Parameters
EventNameThe name of the event to subscribe to.
SubScriptThe subscribed script to execute when the event is fired.
Returns
Returns a pointer to the created Subscriber slot for the provided subscriber.

Definition at line 119 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( EventSubscriber Subscriber)

Unsubscribes a single subscriber all events in this publisher.

Parameters
SubscriberThe EventSubscriberSlot (and the subscriber it is holding) to be removed.

Definition at line 125 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( FunctorSubscriberSlot::FunctorDefinition Funct)

Unsubscribes a single subscriber all events in this publisher.

Parameters
FunctThe functor to be removed.

Definition at line 131 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( CFunctionSubscriberSlot::SubscriberFunction CFunct)

Unsubscribes a single subscriber from all events in this publisher.

Parameters
CFunctThe function to be removed.

Definition at line 137 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( Scripting::iScript SubScript)

Unsubscribes a single subscriber from all events in this publisher.

Parameters
SubScriptThe Script to be removed.

Definition at line 143 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( EventSubscriberSlot SubSlot)

Unsubscribes a single subscriber from all events in this publisher.

Parameters
SubSlotThe EventSubscriberSlot (and the subscriber it is holding) to be removed.

Definition at line 149 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
EventSubscriber Subscriber 
)

Unsubscribes a single subscriber from the named event.

Parameters
EventNameThe name of the event to unsubscribe from.
SubscriberThe EventSubscriberSlot (and the subscriber it is holding) to be removed.

Definition at line 163 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
FunctorSubscriberSlot::FunctorDefinition Funct 
)

Unsubscribes a single subscriber from the named event.

Parameters
EventNameThe name of the event to unsubscribe from.
FunctThe functor to be removed.

Definition at line 166 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
CFunctionSubscriberSlot::SubscriberFunction CFunct 
)

Unsubscribes a single subscriber from the named event.

Parameters
EventNameThe name of the event to unsubscribe from.
CFunctThe function to be removed.

Definition at line 169 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
Scripting::iScript SubScript 
)

Unsubscribes a single subscriber from the named event.

Parameters
EventNameThe name of the event to unsubscribe from.
SubScriptThe Script to be removed.

Definition at line 172 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
EventSubscriberSlot SubSlot 
)

Unsubscribes a single subscriber from the named event.

Parameters
EventNameThe name of the event to unsubscribe from.
SubSlotThe EventSubscriberSlot (and the subscriber it is holding) to be removed.

Definition at line 175 of file eventpublisher.cpp.

Whole Mezzanine::EventPublisher::UnsubscribeAll ( )

Unsubscribes all subscribers from all events in this publisher.

Returns
Returns the number of subscribers removed.

Definition at line 155 of file eventpublisher.cpp.

Whole Mezzanine::EventPublisher::UnsubscribeAll ( const String EventName)

Unsubscribes all subscribers from the named Event.

Parameters
EventNameThe name of the event to unsubscribe from.
Returns
Returns the number of subscribers removed.

Definition at line 178 of file eventpublisher.cpp.

Member Data Documentation

EventContainer Mezzanine::EventPublisher::Events
protected

A container storing all the Events published by this class by name.

Definition at line 67 of file eventpublisher.h.


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