Spinning Topp Logo BlackTopp Studios
inc
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...
 
Boole GetMuteEvents () const
 Gets whether or not event firings by this publisher will be suppressed. More...
 
void SetMuteEvents (const Boole Mute)
 Sets whether or not event firings by this publisher will be suppressed. More...
 
EventSubscriberSlotSubscribe (const String &EventName, EventSubscriber *Sub)
 Adds a subscriber to this event. More...
 
EventSubscriberSlotSubscribe (const String &EventName, FunctorEventSubscriber *Funct, Boole 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 (FunctorEventSubscriber *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, FunctorEventSubscriber *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 (EventArgumentsPtr 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...
 
Boole MuteEvents
 Stores whether or not events will actually be fired when requested. 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 54 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::FireEvent ( EventArgumentsPtr  Args)
protected

Fires an event.

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

Definition at line 66 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 100 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 107 of file eventpublisher.cpp.

Boole Mezzanine::EventPublisher::GetMuteEvents ( ) const

Gets whether or not event firings by this publisher will be suppressed.

Returns
Returns true if events are being supressed, false if this publisher is operating normally.

Definition at line 97 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::RemoveAllEvents ( )
protected

Removes all events in this Publisher.

Definition at line 82 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 73 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::SetMuteEvents ( const Boole  Mute)

Sets whether or not event firings by this publisher will be suppressed.

Parameters
MuteTrue to prevent events from firing, false for normal operation.

Definition at line 94 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 121 of file eventpublisher.cpp.

EventSubscriberSlot * Mezzanine::EventPublisher::Subscribe ( const String EventName,
FunctorEventSubscriber Funct,
Boole  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 124 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 127 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 130 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 136 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( FunctorEventSubscriber Funct)

Unsubscribes a single subscriber all events in this publisher.

Parameters
FunctThe functor to be removed.

Definition at line 142 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 148 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 154 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 160 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 174 of file eventpublisher.cpp.

void Mezzanine::EventPublisher::Unsubscribe ( const String EventName,
FunctorEventSubscriber 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 177 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 180 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 183 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 186 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 166 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 189 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.

Boole Mezzanine::EventPublisher::MuteEvents
protected

Stores whether or not events will actually be fired when requested.

Definition at line 70 of file eventpublisher.h.


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