ScummVM API documentation
kernel.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  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on Broken Sword 2.5 engine
24  *
25  * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26  *
27  * Licensed under GNU GPL v2
28  *
29  */
30 
31 /*
32  * BS_Kernel
33  * ---------
34  * This is the main class of the engine.
35  * This class creates and manages all other Engine elements: the sound engine, graphics engine ...
36  * It is not necessary to release all the items individually, this is performed by the Kernel class.
37  *
38  * Autor: Malte Thiesen
39  */
40 
41 #ifndef SWORD25_KERNEL_H
42 #define SWORD25_KERNEL_H
43 
44 #include "common/scummsys.h"
45 #include "common/random.h"
46 #include "common/stack.h"
47 #include "common/textconsole.h"
48 #include "common/util.h"
49 #include "engines/engine.h"
50 
51 #include "sword25/kernel/common.h"
52 #include "sword25/kernel/resmanager.h"
53 
54 namespace Sword25 {
55 
56 // Class definitions
57 class Service;
58 class Geometry;
59 class GraphicEngine;
60 class ScriptEngine;
61 class SoundEngine;
62 class InputEngine;
63 class PackageManager;
64 class MoviePlayer;
65 
72 class Kernel {
73 public:
74 
78  uint getMilliTicks();
79 
83  bool getInitSuccess() const {
84  return _initSuccess;
85  }
90  return _resourceManager;
91  }
97  int getRandomNumber(int min, int max);
105  SoundEngine *getSfx();
118 
122  MoviePlayer *getFMV();
123 
128  void sleep(uint msecs) const;
129 
133  static Kernel *getInstance() {
134  if (!_instance)
135  _instance = new Kernel();
136  return _instance;
137  }
138 
144  static void deleteInstance() {
145  if (_instance) {
146  delete _instance;
147  _instance = NULL;
148  }
149  }
150 
154  void crash() const {
155  error("Kernel::Crash");
156  }
157 
158 private:
159  // -----------------------------------------------------------------------------
160  // Constructor / destructor
161  // Private singleton methods
162  // -----------------------------------------------------------------------------
163 
164  Kernel();
165  virtual ~Kernel();
166 
167  // -----------------------------------------------------------------------------
168  // Singleton instance
169  // -----------------------------------------------------------------------------
170  static Kernel *_instance;
171 
172  bool _initSuccess; // Specifies whether the engine was set up correctly
173 
174  // Random number generator
175  // -----------------------
177 
178  // Resourcemanager
179  // ---------------
180  ResourceManager *_resourceManager;
181 
182  GraphicEngine *_gfx;
183  SoundEngine *_sfx;
184  InputEngine *_input;
185  PackageManager *_package;
186  ScriptEngine *_script;
187  Geometry *_geometry;
188  MoviePlayer *_fmv;
189 
190  bool registerScriptBindings();
191 };
192 
193 } // End of namespace Sword25
194 
195 #endif
void crash() const
Definition: kernel.h:154
Definition: geometry.h:41
Definition: packagemanager.h:71
uint getMilliTicks()
InputEngine * getInput()
Definition: random.h:44
Definition: soundengine.h:80
Definition: script.h:46
static void deleteInstance()
Definition: kernel.h:144
static Kernel * getInstance()
Definition: kernel.h:133
PackageManager * getPackage()
bool getInitSuccess() const
Definition: kernel.h:83
Definition: console.h:27
Definition: kernel.h:72
Definition: movieplayer.h:48
int getRandomNumber(int min, int max)
Definition: resmanager.h:48
MoviePlayer * getFMV()
SoundEngine * getSfx()
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
ResourceManager * getResourceManager()
Definition: kernel.h:89
void sleep(uint msecs) const
Class definitions.
Definition: inputengine.h:54
GraphicEngine * getGfx()
ScriptEngine * getScript()
Definition: graphicengine.h:83