FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
engine.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
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 FIFE {
46 
47  class SoundManager;
48  class RenderBackend;
49  class IGUIManager;
50  class VFS;
51  class VFSSourceFactory;
52  class EventManager;
53  class TimeManager;
54  class Model;
55  class LogManager;
56  class Cursor;
57  class RendererBase;
58  class Image;
59  class ImageManager;
60  class SoundClipManager;
61  class OffRenderer;
62  class TargetRenderer;
63 
65  public:
67 
70  virtual void onScreenModeChanged(const ScreenMode& newmode) = 0;
71  };
72 
79  class Engine {
80  public:
83  Engine();
84 
87  virtual ~Engine();
88 
92 
95  const DeviceCaps& getDeviceCaps() const;
96 
104  void changeScreenMode(const ScreenMode& mode);
105 
108  void init();
109 
112  void destroy();
113 
117  void initializePumping();
118 
123  void finalizePumping();
124 
127  void pump();
128 
132 
136 
140 
141 
145  void setGuiManager(IGUIManager* guimanager) { m_guimanager = guimanager; }
146 
150 
154 
158 
162 
165  Model* getModel() const { return m_model; }
166 
169  LogManager* getLogManager() const { return m_logmanager; }
170 
173  VFS* getVFS() const { return m_vfs; }
174 
177  Cursor* getCursor() const { return m_cursor; }
178 
182 
186 
191 
196 
197  private:
205 
209 
212 
215 
217 
220  std::vector<RendererBase*> m_renderers;
221 
222  std::vector<IEngineChangeListener*> m_changelisteners;
223 
224 #ifdef USE_COCOA
225  objc_object *m_autoreleasePool;
226 #endif
227 
228  };
229 
230 }//FIFE
231 
232 #endif
EngineSettings m_settings
Definition: engine.h:213
void pump()
Runs one cycle for the engine.
Definition: engine.cpp:341
Abstract interface for all the renderbackends.
Definition: renderbackend.h:92
This class defines the engine settings on engine init.
ImageManager * m_imagemanager
Definition: engine.h:203
RenderBackend * getRenderBackend() const
Provides access point to the RenderBackend.
Definition: engine.h:161
TimeManager * getTimeManager() const
Provides access point to the TimeManager.
Definition: engine.h:139
void addChangeListener(IEngineChangeListener *listener)
Adds new change listener.
Definition: engine.cpp:366
ImageManager.
Definition: imagemanager.h:54
Model * getModel() const
Provides access point to the Model.
Definition: engine.h:165
Engine acts as a controller to the whole system Responsibilities of the engine are: ...
Definition: engine.h:79
RenderBackend * m_renderbackend
Definition: engine.h:198
IGUIManager * getGuiManager() const
Provides access point to the GUI Manager.
Definition: engine.h:149
void finalizePumping()
Finalizes the continuous processing of the engine Call this only once in your program, after you have called initializePumping + (pump() * N times)
Definition: engine.cpp:362
std::vector< IEngineChangeListener * > m_changelisteners
Definition: engine.h:222
Engine()
Constructor.
Definition: engine.cpp:92
void destroy()
Explicit destruction of engine.
Definition: engine.cpp:301
LogManager * getLogManager() const
Provides access point to the LogManager.
Definition: engine.h:169
virtual void onScreenModeChanged(const ScreenMode &newmode)=0
Screen mode has been changed.
bool m_destroyed
Definition: engine.h:211
TargetRenderer * m_targetrenderer
Definition: engine.h:219
SoundManager * m_soundmanager
Definition: engine.h:201
void initializePumping()
Initializes the continuous processing of the engine Call this only once in your program.
Definition: engine.cpp:337
Cursor * getCursor() const
Returns cursor used in the engine.
Definition: engine.h:177
DeviceCaps m_devcaps
Definition: engine.h:214
SoundClipManager.
void init()
Initializes the engine.
Definition: engine.cpp:151
EngineSettings & getSettings()
Gets settings class for engine.
Definition: engine.cpp:125
LogManager * m_logmanager
Definition: engine.h:208
const DeviceCaps & getDeviceCaps() const
Gets device capabilities.
Definition: engine.cpp:129
void removeChangeListener(IEngineChangeListener *listener)
Removes associated change listener.
Definition: engine.cpp:370
EventManager * m_eventmanager
Definition: engine.h:200
TimeManager * m_timemanager
Definition: engine.h:202
A model is a facade for everything in the model.
Definition: model.h:53
SoundClipManager * getSoundClipManager() const
Provides access point to the SoundClipManager.
Definition: engine.h:157
OffRenderer * m_offrenderer
Definition: engine.h:218
IGUIManager * m_guimanager
Definition: engine.h:199
EventManager * getEventManager() const
Provides access point to the EventManager.
Definition: engine.h:135
Cursor * m_cursor
Definition: engine.h:210
Event Manager manages all events related to FIFE.
Definition: eventmanager.h:66
Time Manager.
Definition: timemanager.h:50
virtual ~Engine()
Destructor.
Definition: engine.cpp:295
Cursor class manages mouse cursor handling.
Definition: cursor.h:84
std::vector< RendererBase * > m_renderers
Definition: engine.h:220
the main VFS (virtual file system) class
Definition: vfs.h:58
ScreenMode m_screenMode
Definition: engine.h:216
Logmanager takes care of log filtering and output direction.
Definition: logger.h:99
Model * m_model
Definition: engine.h:207
SoundClipManager * m_soundclipmanager
Definition: engine.h:204
ImageManager * getImageManager() const
Provides access point to the ImageManager.
Definition: engine.h:153
TargetRenderer * getTargetRenderer() const
Provides access point to the TargetRenderer.
Definition: engine.h:185
SoundManager * getSoundManager() const
Provides access point to the SoundManager.
Definition: engine.h:131
OffRenderer * getOffRenderer() const
Provides access point to the OffRenderer.
Definition: engine.h:181
virtual ~IEngineChangeListener()
Definition: engine.h:66
VFS * m_vfs
Definition: engine.h:206
void setGuiManager(IGUIManager *guimanager)
Sets the GUI Manager to use.
Definition: engine.h:145
VFS * getVFS() const
Provides access point to the VFS.
Definition: engine.h:173
void changeScreenMode(const ScreenMode &mode)
Changes the screen mode.
Definition: engine.cpp:133