Public Member Functions
GUI::EventSet Class Reference

Class that collects together a set of Event objects. More...

Inherited by GUI::GlobalEventSet, GUI::MouseCursor, GUI::Renderer, GUI::System, and GUI::Window.

List of all members.

Public Member Functions

void addEvent (string name)
 Add a new Event to the EventSet with the given name.
void removeEvent (string name)
 Removes the Event with the given name. All connections to the event are disconnected.
void removeAllEvents ()
 Remove all Event objects from the EventSet.
bool isEventPresent (string name)
 Checks to see if an Event with the given name is present in the EventSet.
EventConnection subscribeEvent (string name, string subscriber_name)
 Subscribes the named Event to a scripted funtion.
void fireEvent (string name, EventArgs args, string eventNamespace="")
 Fires the named event passing the given EventArgs object.
bool isMuted ()
 Return whether the EventSet is muted or not.
void setMutedState (bool setting)
 Set the mute state for this EventSet.

Qualified Iterators

Event Event
 Can be used to iterate over the events currently added to the EventSet.

Detailed Description

Class that collects together a set of Event objects.

The EventSet is a means for code to attach a handler function to some named event, and later, for that event to be fired and the subscribed handler(s) called.

Events are added to the set as they are first used; that is, the first time a handler is subscribed to an event for a given EventSet, an Event object is created and added to the EventSet.

Instead of throwing an exception when firing an event that does not actually exist in the set, we do nothing (if the Event does not exist, then it has no handlers subscribed, and therefore doing nothing is the correct course action).

Member Function Documentation

void GUI::EventSet::addEvent ( string  name)

Add a new Event to the EventSet with the given name.

Parameters:
nameString object containing the name to give the new Event. The name must be unique for the EventSet.
Returns:
Nothing
Exceptions:
AlreadyExistsExceptionThrown if an Event already exists named name.
void GUI::EventSet::removeEvent ( string  name)

Removes the Event with the given name. All connections to the event are disconnected.

Parameters:
nameString object containing the name of the Event to remove. If no such Event exists, nothing happens.
Returns:
Nothing.
void GUI::EventSet::removeAllEvents ( )

Remove all Event objects from the EventSet.

Returns:
Nothing
bool GUI::EventSet::isEventPresent ( string  name)

Checks to see if an Event with the given name is present in the EventSet.

Returns:
true if an Event named name was found, or false if the Event was not found
EventConnection GUI::EventSet::subscribeEvent ( string  name,
string  subscriber_name 
)

Subscribes the named Event to a scripted funtion.

Parameters:
nameString object containing the name of the Event to subscribe to.
subscriber_nameString object containing the name of the script funtion that is to be subscribed to the Event.
Returns:
Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
void GUI::EventSet::fireEvent ( string  name,
EventArgs  args,
string  eventNamespace = "" 
)

Fires the named event passing the given EventArgs object.

Parameters:
nameString object holding the name of the Event that is to be fired (triggered)
argsThe EventArgs (or derived) object that is to be bassed to each subscriber of the Event. Once all subscribers have been called the 'handled' field of the event is updated appropriately.
eventNamespaceString object describing the global event namespace prefix for this event.
Returns:
Nothing.

Reimplemented in GUI::GlobalEventSet.

bool GUI::EventSet::isMuted ( )

Return whether the EventSet is muted or not.

Returns:
  • true if the EventSet is muted. All requests to fire events will be ignored.
  • false if the EventSet is not muted. All requests to fire events are processed as normal.
void GUI::EventSet::setMutedState ( bool  setting)

Set the mute state for this EventSet.

Parameters:
setting
  • true if the EventSet is to be muted (no further event firing requests will be honoured until EventSet is unmuted).
  • false if the EventSet is not to be muted and all events should fired as requested.
Returns:
Nothing.

Member Data Documentation

Event GUI::EventSet::Event

Can be used to iterate over the events currently added to the EventSet.

Note:
Iterating over events in the EventSet is of questionable use these days, since available events are no longer added in one batch at creation time, but are added individually whenever an event is first subscribed.
for each Event e in window {
trace(e.getName());
}