VCF::Delegate Class Reference
The
Delegate class is used to maintain a collection of event handlers and fire events to them.
More...
#include <vcf/FoundationKit/Delegate.h>
List of all members.
Detailed Description
The
Delegate class is used to maintain a collection of event handlers and fire events to them.
Delegate's have their += and -= operators overloaded as a convenienc methods for adding or removing event handlers.
A Delegate is not meant to be subclassed or derived from. It maintains a pointer to a vector of event handlers, and be default the pointer is null. A new vector will be created the first time a handler is added.
Constructor & Destructor Documentation
| VCF::Delegate::Delegate |
( |
|
) |
[inline] |
|
| VCF::Delegate::~Delegate |
( |
|
) |
[inline] |
|
| VCF::Delegate::Delegate |
( |
const Delegate & |
rhs |
) |
[inline] |
|
Member Function Documentation
| void VCF::Delegate::addHandler |
( |
EventHandler * |
handler |
) |
[inline] |
|
|
|
This adds a new event handler to the Delegate.
If this is the first time that a handler has been added to this Delegate the Delgate's vector of event handlers will be created. - Parameters:
-
| EventHandler | the new event handler to add. The event handler will only be added if it is not already in the collection of event handlers. |
|
| void VCF::Delegate::checkHandlers |
( |
|
) |
[inline, protected] |
|
| void VCF::Delegate::fireEvent |
( |
Event * |
event |
) |
[inline] |
|
|
|
This fires an event to all known event handlers in this delegate.
If an Event is marked as consumed (i.e. the Event's consume(true) is called) then the iteration of handlers will stop and the method will exit, otherwise each handler will have it's invoke() method called once, with the event passed in. - Parameters:
-
| Event | the event to pass to each event handler |
copy the handlers_ vector so that if a call is made to the delegates setFirstEventHandler, or removeAllHandlers, a crash does not occur due to the (possibly) changed state of the handlers_ vector. |
|
|
This allows you to retreive a copy of the handlers registered with this delegate.
- Parameters:
-
- Returns:
- bool returns true if the handlers were successfully copied over. Otherwise returns false. A delegate with no handlers will also return false.
|
| EventHandler* VCF::Delegate::getFirstEventHandler |
( |
|
) |
[inline] |
|
|
|
a shortcut for adding an event handler
|
|
|
a shortcut for removing an event handler
|
| void VCF::Delegate::removeAllHandlers |
( |
|
) |
[inline] |
|
| void VCF::Delegate::removeHandler |
( |
EventHandler * |
handler |
) |
[inline] |
|
|
|
This removes an event handler from the Delegate.
- Parameters:
-
|
| void VCF::Delegate::setFirstEventHandler |
( |
EventHandler * |
handler |
) |
[inline] |
|
Member Data Documentation
The documentation for this class was generated from the following file: