FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
engine.h
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_ENGINE_H
23 #define FIFE_ENGINE_H
24 
25 // Standard C++ library includes
26 #include <map>
27 #include <string>
28 #include <vector>
29 
30 // Platform specific includes
31 #ifdef USE_COCOA
32 #include <objc/runtime.h>
33 #endif
34 
35 // 3rd party library includes
36 #include <SDL.h>
37 
38 // FIFE includes
39 // These includes are split up in two parts, separated by one empty line
40 // First block: files included from the FIFE root src directory
41 // Second block: files included from the same folder
42 #include "enginesettings.h"
43 #include "video/devicecaps.h"
44 
45 namespace gcn {
46  class Graphics;
47 }
48 
49 namespace FIFE {
50 
51  class SoundManager;
52  class RenderBackend;
53  class GUIManager;
54  class VFS;
55  class VFSSourceFactory;
56  class EventManager;
57  class TimeManager;
58  class ImagePool;
59  class AnimationPool;
60  class Model;
61  class LogManager;
62  class GuiFont;
63  class Cursor;
64  class SoundClipPool;
65  class RendererBase;
66  class Image;
67 
68 
69  class IEngineChangeListener {
70  public:
71  virtual ~IEngineChangeListener() {}
72 
75  virtual void onScreenModeChanged(const ScreenMode& newmode) = 0;
76  };
77 
84  class Engine {
85  public:
88  Engine();
89 
92  virtual ~Engine();
93 
97 
100  const DeviceCaps& getDeviceCaps() const;
101 
110  Image* changeScreenMode(const ScreenMode& mode);
111 
114  void init();
115 
118  void destroy();
119 
123  void initializePumping();
124 
129  void finalizePumping();
130 
133  void pump();
134 
137  SoundManager* getSoundManager() const { return m_soundmanager; }
138 
141  EventManager* getEventManager() const { return m_eventmanager; }
142 
145  TimeManager* getTimeManager() const { return m_timemanager; }
146 
149  GUIManager* getGuiManager() const { return m_guimanager; }
150 
153  ImagePool* getImagePool() const { return m_imagepool; }
154 
157  AnimationPool* getAnimationPool() const { return m_animpool; }
158 
161  SoundClipPool* getSoundClipPool() const { return m_soundclippool; }
162 
165  RenderBackend* getRenderBackend() const { return m_renderbackend; }
166 
169  Model* getModel() const { return m_model; }
170 
173  LogManager* getLogManager() const { return m_logmanager; }
174 
177  GuiFont* getDefaultFont() const { return m_defaultfont; }
178 
181  VFS* getVFS() const { return m_vfs; }
182 
185  Cursor* getCursor() const { return m_cursor; }
186 
190  void addChangeListener(IEngineChangeListener* listener);
191 
195  void removeChangeListener(IEngineChangeListener* listener);
196 
197  private:
198  void preInit();
199 
200  RenderBackend* m_renderbackend;
201  GUIManager* m_guimanager;
202  EventManager* m_eventmanager;
203  SoundManager* m_soundmanager;
204  TimeManager* m_timemanager;
205  ImagePool* m_imagepool;
206  AnimationPool* m_animpool;
207  SoundClipPool* m_soundclippool;
208  VFS* m_vfs;
209  Model* m_model;
210  gcn::Graphics* m_gui_graphics;
211  LogManager* m_logmanager;
212  GuiFont* m_defaultfont;
213  Cursor* m_cursor;
214  bool m_destroyed;
215 
216  EngineSettings m_settings;
217  DeviceCaps m_devcaps;
218 
219  ScreenMode m_screenMode;
220 
221  std::vector<RendererBase*> m_renderers;
222 
223  std::vector<IEngineChangeListener*> m_changelisteners;
224 
225 #ifdef USE_COCOA
226  objc_object *m_autoreleasePool;
227 #endif
228 
229  };
230 
231 }//FIFE
232 
233 #endif