Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# Ogre::EventMulticaster Class Reference

This class implements efficient and thread-safe multi-cast event dispatching. More...

`#include <OgreEventMulticaster.h>`

Inheritance diagram for Ogre::EventMulticaster:

[legend]
List of all members.

## Public Methods

| EventMulticaster (EventListener *a, EventListener *b)
| Creates an event multicaster instance which chains listener-a with listener-b.
void | listSelected (ListSelectionEvent *e)
| Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.
void | actionPerformed (ActionEvent *e)
| Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.
void | scrollPerformed (ScrollEvent *e)
| Handles the scrollPerformed event by invoking the scrollPerformed methods on listener-a and listener-b.
void | keyPressed (KeyEvent *e)
| Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b.
void | keyReleased (KeyEvent *e)
| Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.
void | keyClicked (KeyEvent *e)
| Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b.
void | mouseClicked (MouseEvent *e)
| Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b.
void | mouseEntered (MouseEvent *e)
| Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b.
void | mouseExited (MouseEvent *e)
| Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b.
void | mouseMoved (MouseEvent *e)
| Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b.
void | mousePressed (MouseEvent *e)
| Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b.
void | mouseReleased (MouseEvent *e)
| Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b.
EventListener * | remove (EventListener *oldl, bool &deleteSelf)
| Removes a listener from this multicaster and returns the resulting multicast listener.
virtual bool | isMulticaster () const
| Returns whether or not the listener is a multicaster.
virtual void | mouseDragEntered (MouseEvent *e)
virtual void | mouseDragExited (MouseEvent *e)
virtual void | mouseDragDropped (MouseEvent *e)

## Static Public Methods

KeyListener * | add (KeyListener *a, KeyListener *b)
| Adds action-listener-a with action-listener-b and returns the resulting multicast listener.
MouseListener * | add (MouseListener *a, MouseListener *b)
ActionListener * | add (ActionListener *a, ActionListener *b)
MouseMotionListener * | add (MouseMotionListener *a, MouseMotionListener *b)
ListSelectionListener * | add (ListSelectionListener *a, ListSelectionListener *b)
ScrollListener * | add (ScrollListener *a, ScrollListener *b)
ActionListener * | remove (ActionListener *l, ActionListener *oldl)
| Removes the old action-listener from action-listener-l and returns the resulting multicast listener.
ScrollListener * | remove (ScrollListener *l, ScrollListener *oldl)
| Removes the old scroll-listener from scroll-listener-l and returns the resulting multicast listener.
ListSelectionListener * | remove (ListSelectionListener *l, ListSelectionListener *oldl)
| Removes the old listSlection-listener from action-listener-l and returns the resulting multicast listener.
KeyListener * | remove (KeyListener *l, KeyListener *oldl)
| Removes the old key-listener from key-listener-l and returns the resulting multicast listener.
MouseMotionListener * | remove (MouseMotionListener *l, MouseMotionListener *oldl)
| Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.
MouseListener * | remove (MouseListener *l, MouseListener *oldl)
| Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.

## Static Protected Methods

EventListener * | removeInternal (EventListener *l, EventListener *oldl)
| Returns the resulting multicast listener after removing the old listener from listener-l.
EventListener * | addInternal (EventListener *a, EventListener *b)
| Returns the resulting multicast listener from adding listener-a and listener-b together.
EventListener * | convertMultiToListener (EventMulticaster *m)
| Converts a EventMulticaster to the base parent class EventListener.
EventMulticaster * | convertListenerToMulti (EventListener *l)
| Converts a EventListener to the class EventMulticaster .

## Protected Attributes

EventListener * | mA
EventListener * | mB

## Detailed Description

This class implements efficient and thread-safe multi-cast event dispatching.

Remarks:
  It manages an immutable structure consisting of a binary chain of event listeners and will dispatch events to those listeners. Because the structure is immutable, it is safe to use this API to add/remove listeners during the process of an event dispatch operation.

Definition at line 81 of file OgreEventMulticaster.h.

## Constructor & Destructor Documentation

Ogre::EventMulticaster::EventMulticaster | ( | EventListener * | a,
|  | EventListener * | b
| ) |

Creates an event multicaster instance which chains listener-a with listener-b.

Input parameters `a` and `b` should not be `null`, though implementations may vary in choosing whether or not to throw `NullPointerException` in that case.

Parameters:

  a | listener-a
  b | listener-b

Definition at line 33 of file OgreEventMulticaster.cpp.

References mA, and mB.

Referenced by addInternal().

## Member Function Documentation

void Ogre::EventMulticaster::actionPerformed | ( | ActionEvent * | e | ) | `[virtual]`

Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.

Parameters:

  e | the action event

Implements Ogre::ActionListener.

Definition at line 79 of file OgreEventMulticaster.cpp.

ScrollListener * Ogre::EventMulticaster::add | ( | ScrollListener * | a,
|  | ScrollListener * | b
| ) | `[static]`

| Definition at line 56 of file OgreEventMulticaster.cpp. References addInternal().

ListSelectionListener * Ogre::EventMulticaster::add | ( | ListSelectionListener * | a,
|  | ListSelectionListener * | b
| ) | `[static]`

| Definition at line 61 of file OgreEventMulticaster.cpp. References addInternal().

MouseMotionListener * Ogre::EventMulticaster::add | ( | MouseMotionListener * | a,
|  | MouseMotionListener * | b
| ) | `[static]`

| Definition at line 46 of file OgreEventMulticaster.cpp. References addInternal().

ActionListener * Ogre::EventMulticaster::add | ( | ActionListener * | a,
|  | ActionListener * | b
| ) | `[static]`

| Definition at line 51 of file OgreEventMulticaster.cpp. References addInternal().

MouseListener * Ogre::EventMulticaster::add | ( | MouseListener * | a,
|  | MouseListener * | b
| ) | `[static]`

| Definition at line 38 of file OgreEventMulticaster.cpp. References addInternal().

KeyListener * Ogre::EventMulticaster::add | ( | KeyListener * | a,
|  | KeyListener * | b
| ) | `[static]`

Adds action-listener-a with action-listener-b and returns the resulting multicast listener.

Parameters:

  a | action-listener-a
  b | action-listener-b

Definition at line 42 of file OgreEventMulticaster.cpp.

References addInternal().

EventListener * Ogre::EventMulticaster::addInternal | ( | EventListener * | a,
|  | EventListener * | b
| ) | `[static, protected]`

Returns the resulting multicast listener from adding listener-a and listener-b together.

If listener-a is null, it returns listener-b; If listener-b is null, it returns listener-a If neither are null, then it creates and returns a new EventMulticaster instance which chains a with b.

Parameters:

  a | event listener-a
  b | event listener-b

Definition at line 66 of file OgreEventMulticaster.cpp.

References convertMultiToListener(), and EventMulticaster().

Referenced by add(), and remove().

EventMulticaster * Ogre::EventMulticaster::convertListenerToMulti | ( | EventListener * | l | ) | `[static, protected]`

Converts a EventListener to the class EventMulticaster .

Since multicaster has many parent listeners (Action,Mouse etc), it has multiple EventListeners, so choose 1 (Action arbitrary) to reach the EventListener. This method throws an exception if the listener isn't a multicaster.

Definition at line 233 of file OgreEventMulticaster.cpp.

References Except, and Ogre::EventListener::isMulticaster().

Referenced by removeInternal().

EventListener * Ogre::EventMulticaster::convertMultiToListener | ( | EventMulticaster * | m | ) | `[static, protected]`

| Converts a EventMulticaster to the base parent class EventListener. Since multicaster has many parent listeners (Action,Mouse etc), it has multiple EventListeners, so choose 1 (Action arbitrary) to reach the EventListener Definition at line 222 of file OgreEventMulticaster.cpp. Referenced by addInternal(), and remove().

bool Ogre::EventMulticaster::isMulticaster | ( |  | ) | const`[virtual]`

| Returns whether or not the listener is a multicaster. Reimplemented from Ogre::EventListener. Definition at line 216 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::keyClicked | ( | KeyEvent * | e | ) |

Handles the keyTyped event by invoking the keyTyped methods on listener-a and listener-b.

Parameters:

  e | the key event

Definition at line 97 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::keyPressed | ( | KeyEvent * | e | ) |

Handles the keyPressed event by invoking the keyPressed methods on listener-a and listener-b.

Parameters:

  e | the key event

Definition at line 126 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::keyReleased | ( | KeyEvent * | e | ) |

Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.

Parameters:

  e | the key event

Definition at line 132 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::listSelected | ( | ListSelectionEvent * | e | ) |

Handles the actionPerformed event by invoking the actionPerformed methods on listener-a and listener-b.

Parameters:

  e | the action event

Definition at line 73 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::mouseClicked | ( | MouseEvent * | e | ) | `[virtual]`

Handles the mouseClicked event by invoking the mouseClicked methods on listener-a and listener-b.

Parameters:

  e | the mouse event

Implements Ogre::MouseListener.

Definition at line 91 of file OgreEventMulticaster.cpp.

virtual void Ogre::MouseListener::mouseDragDropped | ( | MouseEvent * | e | ) | `[virtual, inherited]`

| Definition at line 104 of file OgreEventListeners.h. Referenced by Ogre::MouseTarget::processMouseEvent().

virtual void Ogre::MouseListener::mouseDragEntered | ( | MouseEvent * | e | ) | `[virtual, inherited]`

| Definition at line 102 of file OgreEventListeners.h. Referenced by Ogre::MouseTarget::processMouseEvent().

virtual void Ogre::MouseListener::mouseDragExited | ( | MouseEvent * | e | ) | `[virtual, inherited]`

| Definition at line 103 of file OgreEventListeners.h. Referenced by Ogre::MouseTarget::processMouseEvent().

void Ogre::EventMulticaster::mouseEntered | ( | MouseEvent * | e | ) | `[virtual]`

Handles the mouseEntered event by invoking the mouseEntered methods on listener-a and listener-b.

Parameters:

  e | the mouse event

Implements Ogre::MouseListener.

Definition at line 103 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::mouseExited | ( | MouseEvent * | e | ) | `[virtual]`

Handles the mouseExited event by invoking the mouseExited methods on listener-a and listener-b.

Parameters:

  e | the mouse event

Implements Ogre::MouseListener.

Definition at line 109 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::mouseMoved | ( | MouseEvent * | e | ) |

Handles the mouseMoved event by invoking the mouseMoved methods on listener-a and listener-b.

Parameters:

  e | the mouse event

void Ogre::EventMulticaster::mousePressed | ( | MouseEvent * | e | ) | `[virtual]`

Handles the mousePressed event by invoking the mousePressed methods on listener-a and listener-b.

Parameters:

  e | the mouse event

Implements Ogre::MouseListener.

Definition at line 115 of file OgreEventMulticaster.cpp.

void Ogre::EventMulticaster::mouseReleased | ( | MouseEvent * | e | ) | `[virtual]`

Handles the mouseReleased event by invoking the mouseReleased methods on listener-a and listener-b.

Parameters:

  e | the mouse event

Implements Ogre::MouseListener.

Definition at line 121 of file OgreEventMulticaster.cpp.

EventListener * Ogre::EventMulticaster::remove | ( | EventListener * | oldl,
|  | bool & | deleteSelf
| ) |

Removes a listener from this multicaster and returns the resulting multicast listener.

Parameters:

  oldl | the listener to be removed

Definition at line 168 of file OgreEventMulticaster.cpp.

References addInternal(), convertMultiToListener(), mA, mB, and removeInternal().

MouseListener * Ogre::EventMulticaster::remove | ( | MouseListener * | l,
|  | MouseListener * | oldl
| ) | `[static]`

Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.

Parameters:

  l | mouse-listener-l
  oldl | the mouse-listener being removed

Definition at line 154 of file OgreEventMulticaster.cpp.

References removeInternal().

MouseMotionListener * Ogre::EventMulticaster::remove | ( | MouseMotionListener * | l,
|  | MouseMotionListener * | oldl
| ) | `[static]`

Removes the old mouse-listener from mouse-listener-l and returns the resulting multicast listener.

Parameters:

  l | mouse-listener-l
  oldl | the mouse-listener being removed

Definition at line 163 of file OgreEventMulticaster.cpp.

References removeInternal().

KeyListener * Ogre::EventMulticaster::remove | ( | KeyListener * | l,
|  | KeyListener * | oldl
| ) | `[static]`

Removes the old key-listener from key-listener-l and returns the resulting multicast listener.

Parameters:

  l | key-listener-l
  oldl | the key-listener being removed

Definition at line 158 of file OgreEventMulticaster.cpp.

References removeInternal().

ListSelectionListener * Ogre::EventMulticaster::remove | ( | ListSelectionListener * | l,
|  | ListSelectionListener * | oldl
| ) | `[static]`

Removes the old listSlection-listener from action-listener-l and returns the resulting multicast listener.

Parameters:

  l | action-listener-l
  oldl | the action-listener being removed

Definition at line 138 of file OgreEventMulticaster.cpp.

References removeInternal().

ScrollListener * Ogre::EventMulticaster::remove | ( | ScrollListener * | l,
|  | ScrollListener * | oldl
| ) | `[static]`

Removes the old scroll-listener from scroll-listener-l and returns the resulting multicast listener.

Parameters:

  l | scroll-listener-l
  oldl | the scroll-listener being removed

Definition at line 149 of file OgreEventMulticaster.cpp.

References removeInternal().

ActionListener * Ogre::EventMulticaster::remove | ( | ActionListener * | l,
|  | ActionListener * | oldl
| ) | `[static]`

Removes the old action-listener from action-listener-l and returns the resulting multicast listener.

Parameters:

  l | action-listener-l
  oldl | the action-listener being removed

Definition at line 144 of file OgreEventMulticaster.cpp.

References removeInternal().

Referenced by removeInternal().

EventListener * Ogre::EventMulticaster::removeInternal | ( | EventListener * | l,
|  | EventListener * | oldl
| ) | `[static, protected]`

Returns the resulting multicast listener after removing the old listener from listener-l.

If listener-l equals the old listener OR listener-l is null, returns null. Else if listener-l is an instance of EventMulticaster, then it removes the old listener from it. Else, returns listener l.

Parameters:

  l | the listener being removed from
  oldl | the listener being removed

Definition at line 191 of file OgreEventMulticaster.cpp.

References convertListenerToMulti(), Ogre::EventListener::isMulticaster(), and remove().

Referenced by remove().

void Ogre::EventMulticaster::scrollPerformed | ( | ScrollEvent * | e | ) |

Handles the scrollPerformed event by invoking the scrollPerformed methods on listener-a and listener-b.

Parameters:

  e | the action event

Definition at line 85 of file OgreEventMulticaster.cpp.

## Member Data Documentation

EventListener* Ogre::EventMulticaster::mA`[protected]`

| Definition at line 269 of file OgreEventMulticaster.h. Referenced by EventMulticaster(), and remove().

EventListener* Ogre::EventMulticaster::mB`[protected]`

| Definition at line 270 of file OgreEventMulticaster.h. Referenced by EventMulticaster(), and remove().

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

- OgreEventMulticaster.h
- OgreEventMulticaster.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:50:55 2004