Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Attributes | List of all members
Mezzanine::Event Class Reference

This class represents a given event that can be subscribed to and/or fired. More...

#include <event.h>

+ Collaboration diagram for Mezzanine::Event:

Public Types

typedef SlotContainer::const_iterator ConstSlotIterator
 Const Iterator type for EventSubscriberSlot instances stored by this class.
 
typedef std::vector< EventSubscriberSlot * > SlotContainer
 Basic container type for EventSubscriberSlot storage by this class.
 
typedef SlotContainer::iterator SlotIterator
 Iterator type for EventSubscriberSlot instances stored by this class.
 
typedef std::pair< UInt8, EventSubscriberSlot * > SlotPair
 An std::pair type for working with stored EventSubscriberSlot instances.
 

Public Member Functions

 Event (const String &Name)
 Class constructor. More...
 
 ~Event ()
 Class destructor.
 
void _FireEvent (EventArgumentsPtr Args)
 Notifies all subscribers of this event that this event is firing. More...
 
const StringGetName () const
 Gets the name of this event. More...
 
EventSubscriberSlotSubscribe (EventSubscriber *Subscriber)
 Adds a subscriber to this event. More...
 
EventSubscriberSlotSubscribe (FunctorEventSubscriber *Funct, Boole CleanUpAfter)
 Subscribes a functor object to this event. More...
 
EventSubscriberSlotSubscribe (CFunctionSubscriberSlot::SubscriberFunction *CFunct)
 Subscribes a C-style function to this event. More...
 
EventSubscriberSlotSubscribe (Scripting::iScript *SubScript)
 Subscribes a script to this event. More...
 
SlotIterator SubscriberSlotBegin ()
 Gets an iterator to the first subscriber slot in this event. More...
 
ConstSlotIterator SubscriberSlotBegin () const
 Gets an iterator to the first subscriber slot in this event. More...
 
SlotIterator SubscriberSlotEnd ()
 Gets an iterator to one passed the last subscriber slot in this event. More...
 
ConstSlotIterator SubscriberSlotEnd () const
 Gets an iterator to one passed the last subscriber slot in this event. More...
 
void Unsubscribe (EventSubscriber *Subscriber)
 Unsubscribes a single subscriber from this event. More...
 
void Unsubscribe (FunctorEventSubscriber *Funct)
 Unsubscribes a single subscriber from this event. More...
 
void Unsubscribe (CFunctionSubscriberSlot::SubscriberFunction *CFunct)
 Unsubscribes a single subscriber from this event. More...
 
void Unsubscribe (Scripting::iScript *SubScript)
 Unsubscribes a single subscriber from this event. More...
 
void Unsubscribe (EventSubscriberSlot *SubSlot)
 Unsubscribes a single subscriber from this event. More...
 
Whole UnsubscribeAll ()
 Unsubscribes all subscribers from this Event. More...
 

Protected Attributes

const String EventName
 The name of this Event. More...
 
SlotContainer Slots
 A container storing all the EventSubscriberSlot instances to subscribers. More...
 

Detailed Description

This class represents a given event that can be subscribed to and/or fired.

Definition at line 52 of file event.h.

Constructor & Destructor Documentation

Mezzanine::Event::Event ( const String Name)

Class constructor.

Parameters
NameThe name to be given to this event.

Definition at line 50 of file event.cpp.

Member Function Documentation

void Mezzanine::Event::_FireEvent ( EventArgumentsPtr  Args)

Notifies all subscribers of this event that this event is firing.

Parameters
ArgsThe arguments and extra data related to this event.

Definition at line 232 of file event.cpp.

const String & Mezzanine::Event::GetName ( ) const

Gets the name of this event.

Returns
Returns a const string reference containing the name of this event.

Definition at line 60 of file event.cpp.

EventSubscriberSlot * Mezzanine::Event::Subscribe ( EventSubscriber Subscriber)

Adds a subscriber to this event.

Parameters
SubscriberThe custom event subscriber.
Returns
Returns a pointer to the created Subscriber slot for the provided subscriber.

Definition at line 66 of file event.cpp.

EventSubscriberSlot * Mezzanine::Event::Subscribe ( FunctorEventSubscriber Funct,
Boole  CleanUpAfter 
)

Subscribes a functor object to this event.

Parameters
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 83 of file event.cpp.

EventSubscriberSlot * Mezzanine::Event::Subscribe ( CFunctionSubscriberSlot::SubscriberFunction CFunct)

Subscribes a C-style function to this event.

Parameters
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 100 of file event.cpp.

EventSubscriberSlot * Mezzanine::Event::Subscribe ( Scripting::iScript SubScript)

Subscribes a script to this event.

Parameters
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 117 of file event.cpp.

Event::SlotIterator Mezzanine::Event::SubscriberSlotBegin ( )

Gets an iterator to the first subscriber slot in this event.

Returns
Returns an iterator to the first subscriber slot.

Definition at line 217 of file event.cpp.

Event::ConstSlotIterator Mezzanine::Event::SubscriberSlotBegin ( ) const

Gets an iterator to the first subscriber slot in this event.

Returns
Returns a const iterator to the first subscriber slot.

Definition at line 223 of file event.cpp.

Event::SlotIterator Mezzanine::Event::SubscriberSlotEnd ( )

Gets an iterator to one passed the last subscriber slot in this event.

Returns
Returns an iterator to one passed the last subscriber slot.

Definition at line 220 of file event.cpp.

Event::ConstSlotIterator Mezzanine::Event::SubscriberSlotEnd ( ) const

Gets an iterator to one passed the last subscriber slot in this event.

Returns
Returns a const iterator to one passed the last subscriber slot.

Definition at line 226 of file event.cpp.

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

Unsubscribes a single subscriber from this event.

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

Definition at line 137 of file event.cpp.

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

Unsubscribes a single subscriber from this event.

Parameters
FunctThe functor to be removed.

Definition at line 151 of file event.cpp.

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

Unsubscribes a single subscriber from this event.

Parameters
CFunctThe function to be removed.

Definition at line 165 of file event.cpp.

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

Unsubscribes a single subscriber from this event.

Parameters
SubScriptThe Script to be removed.

Definition at line 179 of file event.cpp.

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

Unsubscribes a single subscriber from this event.

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

Definition at line 193 of file event.cpp.

Whole Mezzanine::Event::UnsubscribeAll ( )

Unsubscribes all subscribers from this Event.

Returns
Returns the number of subscribers removed.

Definition at line 205 of file event.cpp.

Member Data Documentation

const String Mezzanine::Event::EventName
protected

The name of this Event.

Definition at line 66 of file event.h.

SlotContainer Mezzanine::Event::Slots
protected

A container storing all the EventSubscriberSlot instances to subscribers.

Definition at line 69 of file event.h.


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