MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
entresol.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _entresol_h
41 #define _entresol_h
42 
43 /**
44  @mainpage Mezzanine
45  The Mezzanine Engine isn't really an engine. It is glue holding other code and libraries together. It is a series of other open source libraries (sometimes
46  less user friendly, and almost always more sophisticated) that are held together in a single API that will be stable after its 1.0 release. Others have
47  attempted to do things like this before. Usually simple mistakes are made along the way that have huge negative impacts later in the design. A common mistake
48  code is to copy and paste from open source projects with no plans for maintainability. This means that those projects get all the features and bugs
49  from when they copied, without updates, new features and bugfixes since they started integrating the code. We too have copy and pasted, however we are
50  keeping it up to date, and have a plan for upgrading each component we have brought in.
51 
52  There is no simple way to guarantee access to the most up to date libraries, this means there will meaningful work on integration. Many Linux distributions try
53  to keep the most up to date shared libraries around. What happens when they don't ship what you need, ship something broken or an older library. What about
54  Windows and Mac OS X which make no attempt to keep these kinds of software up to date. What if you do manage to get the software keep it up to date. After that you
55  still have to work on confusing compiler and linker options. IDEs like QT Creator, Code::Blocks or Visual Studio aren't going to set that up for you. The
56  Mezzanine Engine project depends on a dozen or more libaries, so would your project if it had high performance 3d graphics, easy to use 3d physics integrated
57  with the graphics and 3d positional audio ready to run on Windows, Linux and Mac OS X. We are figuring it out once, getting it right ( if we aren't, tell us and
58  we will fix it ), so it doesn't need to be done again and again, for each game.
59 
60  This is still in heavy development and is not in usable condition for all systems. Currently the synchronization of 3d graphics and physics works great. Some of
61  the more advanced features of both physics and graphics to do not yet work. There are a number of other features that are in varied states of development. XML,
62  User Interface, Lua Scripting, 3d Audio, Multithreading, Resource management...
63 
64  If we do our jobs right this will save time and effort making, updating and porting games between a variety of platforms. If you link only
65  against this library, not a single line of your standard compliant C++ code should need to change between platforms. At this early stage we are proving the
66  concept with "Catch!" our first sample game. It Currently runs on Linux, Windows and Mac OS X with an Identical
67  codebase. When we are done with "Catch!" We want it to have one codebase (with no messy \#IFDEFs in game code for compatibility), and downloadable in the Iphone
68  app store, in the Android Marketplace, on the PS3, Wii, downloadable on Steam, and in a variety of linux repositories.
69 
70  @section doxygen This Documention
71  This documentation is automatically extracted from the source code of the Mezzanine. It is intended as a reference to describe the Mezzanine API. We hope that
72  people with moderate or advanced C++ experience will be able to use this to increase their knowledge and get the most out of the Mezzanine. This is not a
73  tutorial and is not likely to helpful to novice C++ developers. For more information please see the following:
74  - An automatically generated list of issues with this documentation - http://mezzanineapi.github.io/DoxygenWarnings.txt
75  - The BlackTopp Studios Inc. website - http://www.blacktoppstudios.com/
76  - The Mezzanine Github page - https://github.com/BlackToppStudios/Mezzanine
77 
78  If you want to know more about Doxygen please see: http://www.stack.nl/~dimitri/doxygen/
79 
80  @section enginestructure Engine Structure
81  The engine is laid out in a variety of classes of a few generalized roles.
82 
83  Some classes are focal points for functionality and internally unify a number of components to do what they do. These managers sometimes conceal a large amount
84  of complexity and try to present a concise API. Managers ( Mezzanine::ManagerBase instances ) generally have a rigid place in the structure of the
85  running program. This is where are the logic that says how something is done exists, for example "how does something get drawn on the screen?" or
86  "how do you detect if two objects are colliding?". Managers are owned either by the Mezzanine::Entresol or a Mezzanine::World
87  depending on their roles and technical limitations.
88 
89  The Mezzanine::Threading::FrameScheduler is responsible for running the work each task requires. Most managers mantain one or more of
90  Mezzanine::Threading::iWorkUnit implementations/instances to do work each frame. The FrameScheduler performs some heuristics and manages when and where
91  the workunits will be run. Generally these are created early in the lifetime of a game and destroyed near the end.
92 
93  Other classes are more similar to data, things like the @ref Mezzanine::Vector3 and the @ref Mezzanine::Quaternion. You can create these things whenever you like
94  and generally have good support for integrating into a various parts of the system. In these classes there is a good deal of math and conversion routines. These
95  are commonly passed around by more sophisticated classes for a variety of reasons. Some of these are small enough to pass around value and some are not.
96 
97  There are some classes that are somewhere between data and singular large-scale aggregration of functionality in managers. The functionality is carefully controlled
98  and most commonly created, deleted and otherwised managed through managers. Many of these classes like the @ref Mezzanine::Light or @ref Mezzanine::ActorRigid are
99  present inside the game simulation as well as having a presence as in the simulation visible to the user.
100 
101  Some classes are that really are just convient places to put functions, things like the @ref Mezzanine::ActorRigidDeSerializer and the @ref Mezzanine::StringTool are good
102  examples of these logical grouping of functions.
103 
104  @subsection managers Managers
105 
106  The canonical source for the list of managers is the ManagerBase::ManagerType enum.
107 
108  A manager is simply a logical grouping of functionality. A number of them exist covering all the major functionality that a game using the the Mezzanine engine would
109  need in most situations.
110 
111  All Managers inherit from ManagerBase. Before the switch to the all support the basic callback and priority functionality because of this.
112 
113  // Entresol Managers // Namespaces
114  MT_AudioManager = 1, // Audio
115  MT_AnimationManager, // Graphics
116  MT_CollisionShapeManager, // Physics
117  MT_GraphicsManager, // Graphics
118  MT_EventManager, // Mezzanine
119  MT_InputManager, // Input-
120  MT_LogManager, // Mezzanine
121  MT_MaterialManager, // Graphics
122  MT_MeshManager, // Graphics
123  MT_NetworkManager, // Network
124  MT_ResourceManager, // Resource
125  MT_ScriptingManager, // Scripting
126  MT_UIManager, // UI
127 
128  // World Managers // Namespaces
129  MT_ActorManager = 100, // Mezzanine
130  MT_AreaEffectManager, // Mezzanine
131  MT_CameraManager, // Graphics
132  MT_PagingManager, // Paging
133  MT_PhysicsManager, // Physics
134  MT_SceneManager, // Graphics
135  MT_SoundScapeManager, // Audio
136  MT_TerrainManager, // Mezzanine
137  MT_VehicleManager, // Mezzanine
138 
139  @subsubsection managerlist A list of Managers in the Mezzanine
140  - @ref Mezzanine::ActorManager - Store and allows retrieval of Actors, when an actor is in this it is part of the game simulaiton
141  - @ref Mezzanine::AudioManager - Play, stop and otherwise work with sound and music.
142  - @ref Mezzanine::CameraManager - Add/remove Multiple camera's from the world
143  - @ref Mezzanine::CollisionShapeManager - Store/create/delete shapes that can be used for physics and collision detection
144  - @ref Mezzanine::EventManager - Get messages and events from the operating system (and user, but that will change)
145  - @ref Mezzanine::GraphicsManager - Adjust Resolution, refresh rate, color depth and thing like that.
146  - @ref Mezzanine::MeshManager - Manage Meshes that can be rendered to the the screen.
147  - @ref Mezzanine::NetworkManager - Manages the transmission and retreival of network traffic.
148  - @ref Mezzanine::PhysicsManager - Control settings that have to do with the physics simulation.
149  - @ref Mezzanine::ResourceManager - Loads Files and locate them in an efficient way.
150  - @ref Mezzanine::SceneManager - Control Lighting, skyboxes, particle effects etc...
151  - @ref Mezzanine::TimerManager - Create and delete a variety of timers.
152  - @ref Mezzanine::TerrainManager - Work with terrain components like height maps.
153  - @ref Mezzanine::UIManager - Create and manage buttons, scrollbars and other widgets.
154 
155  @subsubsection The World, A manager of managers
156  A thorough description needs to go here
157 
158  @subpage mainloop1 "Main Loop Flow"
159 
160  @ref Mezzanine::World "World - It integrates everything"
161 
162  @ref Mezzanine::EventManager "Events - Handling messages, event and interupts from the outisde"
163 
164  @subpage actorcontainer1 "Actor Container - Keeping track of our in game objects"
165 
166  @section Types Data Types
167 
168  @subsection CompoundTypes Compound Data Type
169 
170  @ref Mezzanine::ColourValue
171 
172  @ref Mezzanine::MetaCode "Mezzanine::MetaCode - A unit of user input"
173 
174  @ref Mezzanine::Plane
175 
176  @ref Mezzanine::Quaternion
177 
178  @ref Mezzanine::Ray
179 
180  @ref Mezzanine::Transform
181 
182  @ref Mezzanine::Vector2
183 
184  @ref Mezzanine::Vector3
185 
186  @subsection SimpleDataTypes Simple Data Types
187 
188  @ref Mezzanine::Character
189 
190  @ref Mezzanine::Integer
191 
192  @ref Mezzanine::Real
193 
194  @ref Mezzanine::String
195 
196  @ref Mezzanine::Whole
197 
198  @par There are also a variety of enumerations. Aspect Ratio...
199  @todo Fill out the Simple Data Types with all the enumerations.
200 
201  @section Sophisticated Sophisticated Systems
202 
203  @ref Mezzanine::ActorBase "Actors - Items in the world"
204 
205  @ref Mezzanine::EventBase
206 
207  @ref Mezzanine::GraphicsManager
208 
209  @ref XMLManual
210 
211  @ref LuaManual
212 
213  @ref Serialization
214 
215  @ref ThreadingManual
216 
217  @section Licensing Licensing Information
218 
219  @ref GPLLicense "Mezzanine GNU Public License 3"
220 
221  @ref OriginalpugixmlLicense "XML MIT License"
222 
223 
224 
225  @page GPLLicense Mezzanine GNU Public License 3
226  Here is a simple summary of the license terms. It is included at the top of every
227  source and header file in the engine:
228  \n \n
229  @verbatim
230  © Copyright 2010 - 2011 BlackTopp Studios Inc.
231  This file is part of The Mezzanine Engine.
232 
233  The Mezzanine Engine is free software: you can redistribute it and/or modify
234  it under the terms of the GNU General Public License as published by
235  the Free Software Foundation, either version 3 of the License, or
236  (at your option) any later version.
237 
238  The Mezzanine Engine is distributed in the hope that it will be useful,
239  but WITHOUT ANY WARRANTY; without even the implied warranty of
240  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
241  GNU General Public License for more details.
242 
243  You should have received a copy of the GNU General Public License
244  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
245 
246  The original authors have included a copy of the license specified above in the
247  'Docs' folder. See 'gpl.txt'
248 
249  We welcome the use of the Mezzanine engine to anyone, including companies who wish to
250  Build professional software and charge for their product.
251 
252  However there are some practical restrictions, so if your project involves
253  any of the following you should contact us and we will try to work something
254  out:
255  - DRM or Copy Protection of any kind(except Copyrights)
256  - Software Patents You Do Not Wish to Freely License
257  - Any Kind of Linking to Non-GPL licensed Works
258  - Are Currently In Violation of Another Copyright Holder's GPL License
259  - If You want to change our code and not add a few hundred MB of stuff to
260  your distribution
261 
262  These and other limitations could cause serious legal problems if you ignore
263  them, so it is best to simply contact us or the Free Software Foundation, if
264  you have any questions.
265 
266  Joseph Toppi - toppij@gmail.com
267  John Blackwood - makoenergy02@gmail.com
268  @endverbatim
269  \n \n
270  Here is the contents of gpl.txt that comes in the docs/ folder of with every
271  complete repository of the engine:
272  \n \n
273  @verbinclude gpl.txt
274 */
275 
276 //And now for actual source code!
277 #include "stringtool.h"
278 #include "crossplatform.h"
279 #include "eventbase.h"
280 #include "exception.h"
281 #include "enumerations.h"
282 #include "datatypes.h"
283 #include "vector3.h"
284 #include "managerbase.h"
285 #include "singleton.h"
286 
288 
289 namespace Mezzanine
290 {
291  // Forward declarations
292  class ActorManager;
293  class AreaEffectManager;
294  class DebrisManager;
295  class EventManager;
296  class ResourceManager;
297  class NetworkManager;
298  class ManagerFactory;
299  namespace Audio
300  {
301  class AudioManager;
302  class SoundScapeManager;
303  }
304  namespace Graphics
305  {
306  class GraphicsManager;
307  class MeshManager;
308  class SceneManager;
309  class CameraManager;
310  }
311  namespace Input
312  {
313  class InputManager;
314  }
315  namespace Physics
316  {
317  class PhysicsManager;
318  class CollisionShapeManager;
319  class ManagerConstructionInfo;
320  }
321  namespace UI
322  {
323  class UIManager;
324  }
325 }
326 
327 //Other forward declarations
328 //forward Declarations so that we do not need #include "SDL.h"
329 class SDL_Surface;
330 
331 //forward Declarations so that we do not need #include <Ogre.h>
332 namespace Ogre
333 {
334  class Root;
335  class RenderSystem;
336  class RenderWindow;
337  class ResourceGroupManager;
338  class SceneManager;
339  class Camera;
340  class Viewport;
341 
342  class ParticleFXPlugin;
343 }
344 
345 ///////////////////////////////////////////////////////////////////////////////
346 /// @namespace Mezzanine
347 /// @brief The bulk of the engine components go in this namspace
348 /// @details This is where imporant classes like World, GraphicsManager, and
349 /// The eventmanager reside. For more detailed usage information please refer
350 /// to individual class documentation or the @ref index main page.
351 ///////////////////////////////////////
352 namespace Mezzanine
353 {
354  ///////////////////////////////////////////////////////////////////////////////
355  /// @class Entresol
356  /// @headerfile entresol.h
357  /// @brief This is the main entry point for the entire library.
358  /// @details The entresol coordinates and integrates all the underlying subsystems,
359  /// Currently Ogre3d is used for 3d Graphics, Bullet is used for physics, and
360  /// SDL is used for user input and window management. Games will need a
361  /// container for all the playing pieces. It makes sense to tie all of this
362  /// functionality into one core object.
363  ///////////////////////////////////////
364  class MEZZ_LIB Entresol : public Singleton<Entresol>
365  {
366  public:
367  typedef std::map<String,ManagerFactory*> ManagerFactoryMap;
368  typedef ManagerFactoryMap::iterator ManagerFactoryIterator;
369  typedef ManagerFactoryMap::const_iterator ConstManagerFactoryIterator;
370  private:
371  /// @internal
372  /// @brief The core structure responsible for our multi-threaded main loop.
373  Threading::FrameScheduler WorkScheduler;
374 
375  //Used by the constructors
376  /// @internal
377  /// @brief This is called by most of the constructors so that the is one unified place to have all the settings made.
378  /// @param PhysicsInfo All the info needed to initialize the physics subsystem.
379  /// @param SceneType This is the type of Scene Manager to be created.
380  /// @param EngineDataPath The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources.
381  /// @param LogFileName This is the place that log messages get sent to. This is relative to the working directory of the application/game.
382  /// @param ManagerToBeAdded This is a vector of manager pointers that will be used instead of creating the default ones
383  void Construct( const Physics::ManagerConstructionInfo& PhysicsInfo,
384  const String& SceneType,
385  const String& EngineDataPath,
386  const String& LogFileName,
387  const std::vector <ManagerBase*>& ManagerToBeAdded );
388 
389  /// @internal
390  /// @brief Used to intialize from XML
391  /// @param EngineDataPath The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources.
392  /// @param ArchType Should This be looking for raw or zip or whatever kind of files.
393  /// @param InitializerFile The Mezzanine MXI file to use to initialize the engine.
394  void ConstructFromXML( const String& EngineDataPath,
395  const ArchiveType ArchType,
396  const String& InitializerFile );
397 
398  /// @brief Perform a series of checks that could change on certain system or from certain codechanges to alert us to any problems early.
399  void SanityChecks();
400 
401  bool VerifyManagerInitializations();
402 
403  /// @internal
404  /// @brief This is a map containing all the registered manager factories.
405  ManagerFactoryMap ManagerFactories;
406  /// @internal
407  /// @brief This is a listing of the priority and the Manager, and a pointer to the manager.
408  std::list< ManagerBase* > ManagerList;
409 
410  /// @internal
411  /// @brief Used to track Ogre specific details for the statically linked Particle plugin
412  Ogre::ParticleFXPlugin* SubSystemParticleFXPlugin;
413 
414  //Used to break the mainloop
415  Int32 ManualLoopBreak;
416 
417  /// @internal
418  /// @brief Responsible for asynchronously flushing the logs to disk (or wherever they sync to).
419  Threading::LogAggregator* Aggregator;
420 
421  /// @internal
422  /// @brief Create and direct streams used for logging that are not part of the FrameScheduler
423  /// @details This sets the name of the Ogre log file (so must be called after the SetupOgre
424  /// function is called). This will be changed in the future to change/set the framescheduler
425  /// log, in the meantime its only interaction with the framescheduler is adding a
426  /// LogAggregator WorkUnit.
427  /// @param LogFileName The name of the file to log to. Some Subsystems will use this in addition to some other descriptor
428  void SetupLogging(const String& LogFileName);
429  /// @internal
430  /// @brief Closes log files/streams and removes any WorkUnits from Scheduling dedicated to logging.
431  void DestroyLogging();
432 
433  /// @internal
434  /// @brief If not already created create an instance of Ogre.
435  void SetupOgre();
436  /// @internal
437  /// @brief Do any teardown required for Ogre, then destroy Ogre.
438  void DestroyOgre();
439 
440  public:
441  ///////////////////////////////////////////////////////////////////////////////
442  // Creation and Deletion methods
443 
444  /// @brief Initializer file constructor.
445  /// @details This function expects an ".mxi" (Mezzanine XML Initializer) file.
446  /// If the file provided is not one of this type this function will throw an exception. @n @n
447  /// When initializing factories in the XML file this constructor does not initialize any additional manager factories, so if they are called this will throw an exception.
448  /// @param EngineDataPath The directory where engine specific data resides. This is where it will search for the specified initializer file.
449  /// @param ArchType The type of archive at the path provided.
450  /// @param InitializerFile The file that describes how to initialize Mezzanine.
451  Entresol(const String& EngineDataPath, const ArchiveType ArchType, const String& InitializerFile = "Mezzanine.mxi");
452  /// @brief Factory and initializer file constructor.
453  /// @details This function expects an ".mxi" (Mezzanine XML Initializer) file.
454  /// If the file provided is not one of this type this function will throw an exception. @n @n
455  /// Also default factories are already added and thus do not need to be included in the Factory vector.
456  /// @param CustomFactories A vector containing the additional factories to be registered before initializing the engine.
457  /// @param EngineDataPath The directory where engine specific data resides. This is where it will search for the specified initializer file.
458  /// @param ArchType The type of archive at the path provided.
459  /// @param InitializerFile The file that describes how to initialize Mezzanine.
460  Entresol(std::vector<ManagerFactory*>& CustomFactories, const String& EngineDataPath, const ArchiveType ArchType, const String& InitializerFile = "Mezzanine.mxi");
461  /// @brief Descriptive constructor With Manager Pointers
462  /// @details This constructor allows for an easier way to define the boundaries for items moving about inside the world.
463  /// @param PhysicsInfo All the info needed to initialize the physics subsystem.
464  /// @param SceneType A cue to the scenemanager as to how rendering should occur.
465  /// @param EngineDataPath The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially other low level resources.
466  /// @param LogFileName This is the place that log messages get sent to.
467  Entresol( const Physics::ManagerConstructionInfo& PhysicsInfo,
468  const String& SceneType,
469  const String& EngineDataPath,
470  const String& LogFileName = "Mezzanine.log" );
471  /// @brief Descriptive constructor
472  /// @details This constructor allows for an easier way to define the boundaries for items moving about inside the entresol.
473  /// This constructor provides no default arguments, but allows for maximum customization. In addition to everything the other
474  /// constructors this one can accept a vector of pointers to managers which will be added.
475  /// @param PhysicsInfo All the info needed to initialize the physics subsystem.
476  /// @param PluginsFileName The filename of the plugins file to be loaded. This is relative to the EngineDataPath.
477  /// @param EngineDataPath The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources.
478  /// @param LogFileName This is the place that log messages get sent to.
479  /// @param SceneType A cue to the scenemanager as to how rendering should occur.
480  /// @param ManagerToBeAdded This is a vector of manager pointers that will be used instead of creating new ones.
481  Entresol( const Physics::ManagerConstructionInfo& PhysicsInfo,
482  const String& SceneType,
483  const String& EngineDataPath,
484  const String& LogFileName,
485  const std::vector <ManagerBase*>& ManagerToBeAdded);
486  /// @brief Default constructor.
487  /// @details This simply performs the same work as the descriptive constructor with some sane, but small, limits. It will give you a entresol which expands for 100 units from the Origin, and only allows 10 Actors.
488  /// @warning Do not make a new entresol if one already exists. This can only cause problems.
489  Entresol();
490  /// @brief Deconstructor.
491  /// @details This Tears down all the items created by the entresol, and safely frees any graphical resources, we will also delete any Objects passed into the
492  /// entresol by pointer. We will not delete any pointers we pass out (like from the Events from the Event manager).
493  ~Entresol();
494 
495  ///////////////////////////////////////////////////////////////////////////////
496  // Utility
497 
498  /// @brief Pauses all animations, particles, and object movement throughout the world.
499  /// @param Pause Pauses the world if true, unpauses if false.
500  void PauseWorld(bool Pause);
501 
502  ///////////////////////////////////////////////////////////////////////////////
503  // Logging
504 
505  /// @brief Runtime event and message logging.
506  /// @param Message This is what will be streamed to the log
507  /// @throws Anything GetLogStream could throw.
508  template <class T> void Log(const T& Message)
509  { this->LogString(StringTools::ConvertToString(Message)); }
510  /// @brief Log String directly with no conversion
511  /// @param message The string to log
512  /// @throws Anything GetLogStream could throw.
513  void LogString(const String& message);
514  /// @brief A nearly threadsafe logging sink.
515  /// @details If ID is not supplied and the thread is managed by the framescheduler this should be thread safe.
516  /// @param ID Defaults to the id of the current thread, but can be used to retrieve the logger for any thread.
517  /// @return A Logger that can be used by the thread with given ID or outside of Framescheduling in a non-threadsafe way.
518  /// @throws A ParametersRangeException if the thread is not managed by the frame scheduler or it Threading::FrameScheduler::CreateThreads() has not
519  /// been called (It creates the ThreadSpecific resources that contain the Loggers).
521 
522  /// @internal
523  /// @brief This is used to asynchronously handle log messages.
524  Threading::LogAggregator* GetLogAggregator();
525 
526  ///////////////////////////////////////////////////////////////////////////////
527  // Timing system methods
528 
529  /// @brief This sets a new Target Frame Rate
530  /// @details This sets a new time for each frame. This divides 1000 by the NewFrameRate, drops and floating point amount and uses that amount in an call to
531  /// Entresol::SetTargetFrameTime. For example a target frame rate of 40 with cause each frame to take 25 milliseconds, and a Framerate of 70 would take 14 ms
532  /// @param NewFrameRate The new desired frame rate.
533  /// @warning Setting vary low or very High values could cause unknown errors, This is on our todo list of issues to fix.
534  void SetTargetFrameRate(const Whole NewFrameRate);
535  /// @brief This sets a new target time in milliseconds.
536  /// @details This sets a new time for each frame. Each iteration of the game loop will take around this long to run, but rarely exactly this long. Setting this value
537  /// Higher can results in power savings (battery life), but setting it too High can cause choppiness. Settings this value higher can result in smoother gameplay, but
538  /// set it too high, and system resources could becom completely taxed and power will be wasted.
539  /// @param NewTargetTime The new length of time, in milliseconds.
540  /// @warning Setting vary low or very High values could cause unknown errors, This is on our todo list of issues to fix.
541  void SetTargetFrameTimeMilliseconds(const Whole NewTargetTime);
542  /// @brief This sets a new target time microseconds.
543  /// @details This sets a new time for each frame. Each iteration of the game loop will take around this long to run, but rarely exactly this long. Setting this value
544  /// Higher can results in power savings (battery life), but setting it too High can cause choppiness. Settings this value higher can result in smoother gameplay, but
545  /// set it too high, and system resources could becom completely taxed and power will be wasted.
546  /// @param NewTargetTime The new length of time, in microseconds.
547  /// @warning Setting vary low or very High values could cause unknown errors, This is on our todo list of issues to fix.
548  void SetTargetFrameTimeMicroseconds(const Whole NewTargetTime);
549  /// @brief Retrieves the amount of milliseconds we would like each iteration of the Main Loop to be.
550  /// @details In practice I've done some more testing, started out digging through the code to see if there was anything wrong, there seemed to be random extra words inside our code that the compiler didn't mind that shouldn't be there. like there was a " Schedule : " right after a line where a pointer was initialized. I only found such occurrences in gamebase.cpp though, removed them and did two tests. First test I was just randomly clicking and then I inadvertently threw the metal sphere down into the abyss, the sphere was really close to the camera when this happened, about to go over. Second time I ran the game trying to click stuff, I simply couldn't click anything. I even tried zooming in on the robots, although I can only get so close to them before I have to tamper with the camera, which I haven't done yet, but there were no results with the Robots. The third time I was successfully able to stop two spheres and move them around the platform quite smoothly. These spheres were slightly further away from the camera compared to the first run. I stopped the wooden sphere and the second metal sphere. I included a screen shot and a copy of my log for the third run. The spheres in the screenshot are both in a rest position.dware performance or timing concerns can cause this goal to be unnaitanable or trivially easy. The main loop with actually
551  /// pause execution until this amount of time is reach is main loop iteration, However, the mainloop will always skip waiting if hardware is overburdened.
552  /// @return This returns a Whole with the current value in milliseconds.
553  Whole GetTargetFrameTimeMilliseconds() const;
554  /// @brief Retrieves the amount of milliseconds we would like each iteration of the Main Loop to be.
555  /// @details In practice I've done some more testing, started out digging through the code to see if there was anything wrong, there seemed to be random extra words inside our code that the compiler didn't mind that shouldn't be there. like there was a " Schedule : " right after a line where a pointer was initialized. I only found such occurrences in gamebase.cpp though, removed them and did two tests. First test I was just randomly clicking and then I inadvertently threw the metal sphere down into the abyss, the sphere was really close to the camera when this happened, about to go over. Second time I ran the game trying to click stuff, I simply couldn't click anything. I even tried zooming in on the robots, although I can only get so close to them before I have to tamper with the camera, which I haven't done yet, but there were no results with the Robots. The third time I was successfully able to stop two spheres and move them around the platform quite smoothly. These spheres were slightly further away from the camera compared to the first run. I stopped the wooden sphere and the second metal sphere. I included a screen shot and a copy of my log for the third run. The spheres in the screenshot are both in a rest position.dware performance or timing concerns can cause this goal to be unnaitanable or trivially easy. The main loop with actually
556  /// pause execution until this amount of time is reach is main loop iteration, However, the mainloop will always skip waiting if hardware is overburdened.
557  /// @return This returns a Whole with the current value in microseconds.
558  Whole GetTargetFrameTimeMicroseconds() const;
559 
560  /// @brief Gets the amount of time since the last time the last frame took to run.
561  /// @details This returns, in milliseconds the amount of time since the frame started.
562  /// @return This returns a whole number which can be used to aid in the timimg of various algorithms.
563  Whole GetLastFrameTimeMilliseconds() const;
564  /// @brief Gets the amount of time since the last time the last frame took to run.
565  /// @details This returns, in microseconds the amount of time since the frame started.
566  /// @return This returns a whole number which can be used to aid in the timimg of various algorithms.
567  Whole GetLastFrameTimeMicroseconds() const;
568 
569  ///////////////////////////////////////////////////////////////////////////////
570  // Initialization
571 
572  /// @brief This initializes all managers and worlds currently in the Entresol.
573  /// @param CallMainLoop Should the main loop be called.
574  void EngineInit(const bool& CallMainLoop = false);
575 
576  ///////////////////////////////////////////////////////////////////////////////
577  // Main Loop
578 
579  /// @brief Gets the core structure responsible for scheduling work in the Entresol main loop.
580  /// @return Returns a reference to the FrameScheduler being used by this Entresol.
581  Threading::FrameScheduler& GetScheduler();
582 
583  /// @brief This Function house the main loop.
584  /// @details If using this you don't need to worry about initialization of managers or other pre main loop items.
585  void MainLoop();
586 
587  /// @brief Initialize any default managers and any added after construction. This should be called before DoOneFrame()
588  void PreMainLoopInit();
589 
590  /// @brief Run one frame
591  /// @details This should only be called after Managers and other Pre Main loop items
592  void DoOneFrame();
593 
594  /// @brief This makes the main loop end after it's current frame (or cancels a previous attempt to do so).
595  /// @param Break If true this will break the main loop after the next iteration or the end of the current one. If false the main loop will just keep running.
596  /// @details If called while not in the main loop, it will affect the next main loop iteration.
597  /// This function is thread safe and can be called from any work unit at any time.
598  void BreakMainLoop(Boolean Break = true);
599 
600  /// @brief How many frames have elasped?
601  /// @return A Whole containing the currect 0 based frame number.
602  Whole GetFrameCount() const;
603 
604  ///////////////////////////////////////////////////////////////////////////////
605  // Factory Management
606 
607  /// @brief Adds/registers a manager factory with this Entresol, allowing it to be constructed through this API.
608  /// @param ToBeAdded The manager factory to be added.
609  void AddManagerFactory(ManagerFactory* ToBeAdded);
610  /// @brief Removes a manager factory from this Entresol.
611  /// @param ToBeRemoved A pointer to the manager factory that is to be removed.
612  void RemoveManagerFactory(ManagerFactory* ToBeRemoved);
613  /// @brief Removes a manager factory from this Entresol.
614  /// @param ImplName The name of the manager implementation created by the factory to be removed.
615  void RemoveManagerFactory(const String& ImplName);
616  /// @brief Removes and destroys a manager factory in this Entresol.
617  /// @param ToBeRemoved A pointer to the manager factory that is to be removed and destroyed.
618  void DestroyManagerFactory(ManagerFactory* ToBeRemoved);
619  /// @brief Removes and destroys a manager factory in this Entresol.
620  /// @param ImplName The name of the manager implementation created by the factory to be removed and destroyed.
621  void DestroyManagerFactory(const String& ImplName);
622  /// @brief Destroys all manager factories in this Entresol.
623  /// @warning The destruction of manager factories should only be done after the corresponding managers have been destroyed, otherwise this will cause an exception.
624  void DestroyAllManagerFactories();
625  /// @brief Adds all the default manager factories provided by the engine to the Entresol.
626  void AddAllEngineDefaultManagerFactories();
627 
628  ///////////////////////////////////////////////////////////////////////////////
629  // Upper Management
630 
631  /// @brief Creates a new manager.
632  /// @param ManagerImplName The name of the manager implementation to create.
633  /// @param Params A list of name-value pairs for the params that are to be used when creating the manager.
634  /// @param AddToEntresol Whether or not to add the created manager to the Entresol after creation.
635  /// @return Returns a pointer to the created manager.
636  ManagerBase* CreateManager(const String& ManagerImplName, NameValuePairList& Params, bool AddToEntresol = true);
637  /// @brief Creates a new manager.
638  /// @param ManagerImplName The name of the manager implementation to create.
639  /// @param XMLNode An XML node containing all construction and initialization info for the manager to be created.
640  /// @param AddToEntresol Whether or not to add the created manager to the Entresol after creation.
641  /// @return Returns a pointer to the created manager.
642  ManagerBase* CreateManager(const String& ManagerImplName, XML::Node& XMLNode, bool AddToEntresol = true);
643  /// @brief Destroys a manager.
644  /// @param ToBeDestroyed The manager to be destroyed.
645  void DestroyManager(ManagerBase* ToBeDestroyed);
646  /// @brief Destroys all managers currently in the Entresol.
647  /// @warning Do not call this in anything that is run during the main loop. If you do you will have a bad time.
648  void DestroyAllManagers();
649 
650  /// @brief This adds a manager, in the correct order, to the list that the Entresol calls on.
651  /// @param ManagerToAdd The pointer to the manager to be added.
652  void AddManager(ManagerBase* ManagerToAdd);
653  /// @brief This removes a manager by finding the matching pointer.
654  /// @param ManagerToRemove A pointer to the manager to be removed.
655  void RemoveManager(ManagerBase* ManagerToRemove);
656  /// @brief This is will find the manager of a given type.
657  /// @param RetrieveType The ManagerBase::ManagerTypeName of the manager to get.
658  /// @param WhichOne If not getting the first/only manager of the given type, get one.
659  /// @return This returns a pointer to a ManagerBase, or a NULL pointer if no matching manager exists.
660  ManagerBase* GetManager(const ManagerBase::ManagerType RetrieveType, UInt16 WhichOne = 0);
661  /// @brief This removes a manager of a specific type from the list
662  /// @param ManagersToRemoveType The ManagerBase::ManagerTypeName of the manager to remove.
663  /// @param WhichOne If not removing the first/only manager of the given type, which one by count are you erasing.
664  void RemoveManager(const ManagerBase::ManagerType ManagersToRemoveType, UInt16 WhichOne = 0);
665 
666  /// @brief This gets the ActorManager from the manager list.
667  /// @param WhichOne If you have multiple ActorManagers this will choose which one to return.
668  /// @return This returns a pointer to a ActorManager, or a NULL pointer if no matching manager exists.
669  ActorManager* GetActorManager(const UInt16 WhichOne = 0);
670  /// @brief This gets the AreaEffectManager from the manager list.
671  /// @param WhichOne If you have multiple AreaEffectManagers this will choose which one to return.
672  /// @return This returns a pointer to a AreaEffectManager, or a NULL pointer if no matching manager exists.
673  AreaEffectManager* GetAreaEffectManager(const UInt16 WhichOne = 0);
674  /// @brief This gets the AudioManager from the manager list.
675  /// @param WhichOne If you have multiple AudioManagers this will choose which one to return.
676  /// @return This returns a pointer to a AudioManager, or a NULL pointer if no matching manager exists.
677  Audio::AudioManager* GetAudioManager(const UInt16 WhichOne = 0);
678  /// @brief This gets the CameraManager from the manager list.
679  /// @param WhichOne If you have multiple CameraManagers this will choose which one to return.
680  /// @return This returns a pointer to a CameraManager, or a NULL pointer if no matching manager exists.
681  Graphics::CameraManager* GetCameraManager(const UInt16 WhichOne = 0);
682  /// @brief This gets the CollisionShapeManager from the manager list.
683  /// @param WhichOne If you have multiple CollisionShapeManagers this will choose which one to return.
684  /// @return This returns a pointer to a CollisionShapeManager, or a NULL pointer if no matching manager exists.
685  Physics::CollisionShapeManager* GetCollisionShapeManager(const UInt16 WhichOne = 0);
686  /// @brief This gets the DebrisManager from the manager list.
687  /// @param WhichOne If you have multiple CollisionShapeManagers this will choose which one to return.
688  /// @return This returns a pointer to a DebrisManager, or a NULL pointer if no matching manager exists.
689  DebrisManager* GetDebrisManager(const UInt16 WhichOne = 0);
690  /// @brief This gets the EventManager from the manager list.
691  /// @param WhichOne If you have multiple EventManagers this will choose which one to return.
692  /// @return This returns a pointer to a EventManager, or a NULL pointer if no matching manager exists.
693  EventManager* GetEventManager(const UInt16 WhichOne = 0);
694  /// @brief This gets the GraphicsManager from the manager list.
695  /// @param WhichOne If you have multiple GraphicsManagers this will choose which one to return.
696  /// @return This returns a pointer to a GraphicsManager, or a NULL pointer if no matching manager exists.
697  Graphics::GraphicsManager* GetGraphicsManager(const UInt16 WhichOne = 0);
698  /// @brief This gets the InputManager from the manager list.
699  /// @param WhichOne If you have multiple InputManagers this will choose which one to return.
700  /// @return This returns a pointer to a InputManager, or a NULL pointer if no matching manager exists.
701  Input::InputManager* GetInputManager(const UInt16 WhichOne = 0);
702  /// @brief This gets the MeshManager from the manager list.
703  /// @param WhichOne If you have multiple MeshManagers this will choose which one to return.
704  /// @return This returns a pointer to a MeshManager, or a NULL pointer if no matching manager exists.
705  Graphics::MeshManager* GetMeshManager(const UInt16 WhichOne = 0);
706 #ifdef MEZZNETWORK
707  /// @brief This gets the NetworkManager from the manager list.
708  /// @param WhichOne If you have multiple NetworkManagers this will choose which one to return.
709  /// @return This returns a pointer to a NetworkManager, or a NULL pointer if no matching manager exists.
710  NetworkManager* GetNetworkManager(const UInt16 WhichOne = 0);
711 #endif
712  /// @brief This gets the PhysicsManager from the manager list.
713  /// @param WhichOne If you have multiple PhysicsManagers this will choose which one to return.
714  /// @return This returns a pointer to a PhysicsManager, or a NULL pointer if no matching manager exists.
715  Physics::PhysicsManager* GetPhysicsManager(const UInt16 WhichOne = 0);
716  /// @brief This gets the SceneManager from the manager list.
717  /// @param WhichOne If you have multiple SceneManagers this will choose which one to return.
718  /// @return This returns a pointer to a SceneManager, or a NULL pointer if no matching manager exists.
719  Graphics::SceneManager* GetSceneManager(const UInt16 WhichOne = 0);
720  /// @brief This gets the SoundScapeManager from the manager list.
721  /// @param WhichOne If you have multiple SoundScapeManagers this will choose which one to return.
722  /// @return This returns a pointer to a SoundScapeManager, or a NULL pointer if no matching manager exists.
723  Audio::SoundScapeManager* GetSoundScapeManager(const UInt16 WhichOne = 0);
724  /// @brief This gets the ResourceManager from the manager list. These are responsible for reading and writing files on the disk.
725  /// @param WhichOne If you have multiple ResourceManagers this will choose which one to return.
726  /// @return This returns a pointer to a ResourceManager, or a NULL pointer if no matching manager exists.
727  ResourceManager* GetResourceManager(const UInt16 WhichOne = 0);
728  /// @brief This gets the UIManager from the manager list.
729  /// @param WhichOne If you have multiple UIManagers this will choose which one to return.
730  /// @return This returns a pointer to a UIManager, or a NULL pointer if no matching manager exists.
731  UI::UIManager* GetUIManager(const UInt16 WhichOne = 0);
732  };//Entresol
733 }//Mezzanine
734 #endif