3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
35 * Copyright (C) 2001 NaN Technologies B.V.
36 * @author Maarten Gribnau
40 #ifndef _GHOST_EVENT_MANAGER_H_
41 #define _GHOST_EVENT_MANAGER_H_
44 #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
50 #include "GHOST_IEventConsumer.h"
54 * Manages an event stack and a list of event consumers.
55 * The stack works on a FIFO (First In First Out) basis.
56 * Events are pushed on the front of the stack and retrieved from the back.
57 * Ownership of the event is transferred to the event manager as soon as an event is pushed.
58 * Ownership of the event is transferred from the event manager as soon as an event is popped.
59 * Events can be dispatched to the event consumers.
61 class GHOST_EventManager
72 virtual ~GHOST_EventManager();
75 * Returns the number of events currently on the stack.
76 * @return The number of events on the stack.
78 virtual GHOST_TUns32 getNumEvents();
81 * Returns the number of events of a certain type currently on the stack.
82 * @param type The type of events to be counted.
83 * @return The number of events on the stack of this type.
85 virtual GHOST_TUns32 getNumEvents(GHOST_TEventType type);
88 * Return the event at the top of the stack without removal.
89 * Do not delete the event!
90 * @return The event at the top of the stack.
92 virtual GHOST_IEvent* peekEvent();
95 * Pushes an event on the stack.
96 * To dispatch it, call dispatchEvent() or dispatchEvents().
97 * Do not delete the event!
98 * @param event The event to push on the stack.
100 virtual GHOST_TSuccess pushEvent(GHOST_IEvent* event);
103 * Dispatches the given event directly, bypassing the event stack.
104 * @return Indication as to whether any of the consumers handled the event.
106 virtual bool dispatchEvent(GHOST_IEvent* event);
109 * Dispatches the event at the back of the stack.
110 * The event will be removed from the stack.
111 * @return Indication as to whether any of the consumers handled the event.
113 virtual bool dispatchEvent();
116 * Dispatches all the events on the stack.
117 * The event stack will be empty afterwards.
118 * @return Indication as to whether any of the consumers handled the events.
120 virtual bool dispatchEvents();
123 * Adds a consumer to the list of event consumers.
124 * @param consumer The consumer added to the list.
125 * @return Indication as to whether addition has succeeded.
127 virtual GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer);
130 * Removes a consumer from the list of event consumers.
131 * @param consumer The consumer removed from the list.
132 * @return Indication as to whether removal has succeeded.
134 virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer);
138 * Returns the event at the top of the stack and removes it.
139 * Delete the event after use!
140 * @return The event at the top of the stack.
142 virtual GHOST_IEvent* popEvent();
145 * Removes all events from the stack.
147 virtual void disposeEvents();
149 /** The event stack. */
150 std::deque<GHOST_IEvent*> m_events;
152 typedef std::vector<GHOST_IEventConsumer*> TConsumerVector;
153 /** The list with event consumers. */
154 TConsumerVector m_consumers;
157 #endif // _GHOST_EVENT_MANAGER_H_