ScummVM API documentation
event_manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_EVENTMANAGER_H_INCLUDED
28 #define ICB_EVENTMANAGER_H_INCLUDED
29 
30 // Include files with relative paths
31 #include "engines/icb/common/px_string.h"
32 #include "engines/icb/p4.h"
33 #include "engines/icb/event_timer.h"
34 #include "engines/icb/event_list.h"
35 #include "engines/icb/session.h"
36 
37 namespace ICB {
38 
39 #define EVENT_MANAGER_LOG "event_manager_log.txt"
40 
41 // Maximum number of event timers active at one time.
42 #define EVENT_MANAGER_MAX_TIMERS 4
43 
44 // Keeps track of which object is interested in hearing about events from which other objects and stores
45 // events which have occurred until they can be handled.
47 public:
48  // Default constructor and destructor.
49  _event_manager() {}
50  ~_event_manager() {}
51 
52  // This initializes the whole object and must be called at the start of each session.
53  void Initialise();
54 
55  // This says whether a particular object has events pending.
56  bool8 HasEventPending(int32 nObjectID);
57 
58  // This checks if an object has the named event waiting for it.
59  bool8 CheckEventWaitingForObject(int32 nObjectID, const char *pcEventName);
60 
61  // This shuts down an object in the event manager.
62  void ShutDownEventProcessingForObject(int32 nObjectID);
63 
64  // This processes the event timers if there are any, posting events as required.
65  void CycleEventManager();
66 
67  // Determines whether or not the named object is registered for the named event.
68  bool8 IsObjectRegisteredForEvent(int32 nCallerID, const char *pcEventName);
69 
70  // These functions save and restore necessary parts of the event manager.
71  void Save(Common::WriteStream *stream) const;
72  void Restore(Common::SeekableReadStream *stream);
73 
74  // These functions will probably have direct script counterparts.
75  void RegisterForEvent(int32 nObjectID, const char *pcEventName);
76  void UnregisterForEvent(int32 nObjectID, const char *pcEventName);
77  void PostNamedEvent(const char *pcEventName, int32 nSenderID);
78  void PostNamedEventToObject(const char *pcEventName, int32 nTargetID, int32 nSenderID);
79  void PostRepeatingEvent(const char *pcEventName, uint32 nStart, uint32 nInterval, uint32 nEnd);
80  void ClearAllEventsForObject(int32 nObjectID);
81  bool8 DidObjectSendLastNamedEvent(int32 nCallerID, int32 nObjectID, const char *pcEventName) const;
82  int32 GetIDOfLastObjectToPostEvent(int32 nCallerID, const char *pcEventName) const;
83  void SetSuspendFlagForObject(int32 nObjectID, bool8 bState);
84 
85 private:
86  _event_list m_pEventLists[MAX_session_objects]; // List of objects and the events they are currently interested in.
87  _event_timer m_pEventTimers[EVENT_MANAGER_MAX_TIMERS]; // Housekeeping for future and repeating events.
88  uint8 m_nNumObjects; // Number of objects in the event manager.
89  bool8 m_pbActiveTimers[EVENT_MANAGER_MAX_TIMERS]; // Housekeeping for future and repeating events.
90  bool8 m_pbRunning[MAX_session_objects]; // Set true for currently-running objects, false if they have been shut down.
91  bool8 m_pbSuspended[MAX_session_objects]; // Allows objects to be suspended then reinstated.
92 
93  // Here I block the use of the default '='.
94  _event_manager(const _event_manager &) {}
95  void operator=(const _event_manager &) {}
96 };
97 
98 extern _event_manager *g_oEventManager; // Instantiated in global_objects.cpp.
99 
100 } // End of namespace ICB
101 
102 #endif // #if !defined( EVENTMANAGER_H_INCLUDED )
Definition: stream.h:77
Definition: actor.h:32
Definition: event_manager.h:46
Definition: stream.h:745
Definition: event_list.h:101
Definition: event_timer.h:41