Crazy Eddie's GUI System
0.8.7
|
Defines an 'event' which can be subscribed to by interested parties. More...
Classes | |
class | ScopedConnection |
Event::Connection wrapper that automatically disconnects the connection when the object is deleted (or goes out of scope). More... | |
Public Types | |
typedef RefCounted< BoundSlot > | Connection |
Connection object. This is a thin 'smart pointer' wrapper around the actual BoundSlot that represents the connection. You can use this object to inspect the current connection state and also to disconnect from the event. | |
typedef CEGUI::SubscriberSlot | Subscriber |
Subscriber object type. This is now just a typedef to SubscriberSlot, the use of the name Event::Subscriber is maintained for hostorical and compatability reasons. | |
typedef unsigned int | Group |
Type for a subscriber group. You can use the subscriber group to order calls to multiple subscribers. Groups are called in ascending order, with subscribers with no group called last. | |
Public Member Functions | |
Event (const String &name) | |
Constructs a new Event object with the specified name. | |
virtual | ~Event () |
Destructor for Event objects. Note that this is non-virtual and so you should not sub-class Event. | |
const String & | getName (void) const |
Return the name given to this Event object when it was created. More... | |
Connection | subscribe (const Subscriber &slot) |
Subscribes some function or object to the Event. More... | |
Connection | subscribe (Group group, const Subscriber &slot) |
Subscribes some function or object to the Event. More... | |
void | operator() (EventArgs &args) |
Fires the event. All event subscribers get called in the appropriate sequence. More... | |
Protected Types | |
typedef std::multimap< Group, Connection, std::less< Group > CEGUI_MULTIMAP_ALLOC(Group, Connection)> | SlotContainer |
Protected Member Functions | |
void | unsubscribe (const BoundSlot &slot) |
Disconnects and removes the given BoundSlot from the collection of bound slots attached to this Event, thus 'unsubscribing' it. More... | |
Event (const Event &) | |
Event & | operator= (const Event &) |
Protected Attributes | |
SlotContainer | d_slots |
Collection holding ref-counted bound slots. | |
const String | d_name |
Name of this event. | |
Friends | |
void | CEGUI::BoundSlot::disconnect () |
Defines an 'event' which can be subscribed to by interested parties.
An Event can be subscribed by a function, a member function, or a function object. Whichever option is taken, the function signature needs to be as follows:
|
inline |
void CEGUI::Event::operator() | ( | EventArgs & | args | ) |
Fires the event. All event subscribers get called in the appropriate sequence.
args | An object derived from EventArgs to be passed to each event subscriber. The 'handled' field will be set to true if any of the called subscribers return that they handled the event. |
Connection CEGUI::Event::subscribe | ( | const Subscriber & | slot | ) |
Subscribes some function or object to the Event.
subscriber | A function, static member function, or function object, with the signature void function_name(const EventArgs& args). To subscribe a member function you should explicitly create an Event::Subscriber as this parameter. |
Connection CEGUI::Event::subscribe | ( | Group | group, |
const Subscriber & | slot | ||
) |
Subscribes some function or object to the Event.
group | The Event group to subscribe to, subscription groups are called in ascending order, followed by subscriptions with no group. Note that calling order of connections to the same group is unspecified. |
subscriber | A function, static member function, or function object, with the signature void function_name(const EventArgs& args). To subscribe a member function you should explicitly create an Event::Subscriber as this parameter. |
|
protected |
Disconnects and removes the given BoundSlot from the collection of bound slots attached to this Event, thus 'unsubscribing' it.