Spinning Topp Logo BlackTopp Studios
inc
managerbase.cpp
1 // © Copyright 2010 - 2016 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 _managerbase_cpp
41 #define _managerbase_cpp
42 
43 #include "entresol.h"
44 #include "managerbase.h"
45 #include "stringtool.h"
46 
47 namespace Mezzanine
48 {
50  TheEntresol(NULL),
51  Initialized(false)
52  {
54  }
55 
57  {}
58 
59  ///////////////////////////////////////////////////////////////////////////////
60  // Utility
61 
62  ///////////////////////////////////////////////////////////////////////////////
63  // Initialization Methods
64 
66  { return Initialized; }
67 
68  ///////////////////////////////////////////////////////////////////////////////
69  // Type Identifier Methods
70 
72  {
74  }
75 
77  {
78  switch( ManagerType )
79  {
80  case ManagerBase::MT_ActorManager:
81  return "ActorManager";
82  break;
83  case ManagerBase::MT_AnimationManager:
84  return "AnimationManager";
85  break;
86  case ManagerBase::MT_AreaEffectManager:
87  return "AreaEffectManager";
88  break;
89  case ManagerBase::MT_AudioManager:
90  return "AudioManager";
91  break;
92  case ManagerBase::MT_CollisionShapeManager:
93  return "CollisionShapeManager";
94  break;
95  case ManagerBase::MT_CompositorManager:
96  return "CompositorManager";
97  break;
98  case ManagerBase::MT_DebrisManager:
99  return "DebrisManager";
100  break;
101  case ManagerBase::MT_EventManager:
102  return "EventManager";
103  break;
104  case ManagerBase::MT_GraphicsManager:
105  return "GraphicsManager";
106  break;
107  case ManagerBase::MT_InputManager:
108  return "InputManager";
109  break;
110  case ManagerBase::MT_LogManager:
111  return "LogManager";
112  break;
113  case ManagerBase::MT_MaterialManager:
114  return "MaterialManager";
115  break;
116  case ManagerBase::MT_MeshManager:
117  return "MeshManager";
118  break;
119  case ManagerBase::MT_NetworkManager:
120  return "NetworkManager";
121  break;
122  case ManagerBase::MT_PagingManager:
123  return "PagingManager";
124  break;
125  case ManagerBase::MT_PhysicsManager:
126  return "PhysicsManager";
127  break;
128  case ManagerBase::MT_ResourceManager:
129  return "ResourceManager";
130  break;
131  case ManagerBase::MT_SceneManager:
132  return "SceneManager";
133  break;
134  case ManagerBase::MT_ScriptingManager:
135  return "ScriptingManager";
136  break;
137  case ManagerBase::MT_SoundScapeManager:
138  return "SoundScapeManager";
139  break;
140  case ManagerBase::MT_TerrainManager:
141  return "TerrainManager";
142  break;
143  case ManagerBase::MT_TextureManager:
144  return "TextureManager";
145  break;
146  case ManagerBase::MT_UIManager:
147  return "UIManager";
148  break;
149  case ManagerBase::MT_VehicleManager:
150  return "VehicleManager";
151  break;
153  return "UserCreated";
154  break;
155  default:
156  return "Unknown";
157  break;
158  }
159  }
160 
162  {
163  String Lower = ManagerName;
165  switch ( Lower.at(0) )
166  {
167  case 'a':
168  {
169  if( 'c' == Lower.at(1) ) return ManagerBase::MT_ActorManager;
170  else if( 'n' == Lower.at(1) ) return ManagerBase::MT_AnimationManager;
171  else if( 'r' == Lower.at(1) ) return ManagerBase::MT_AreaEffectManager;
172  else if( 'u' == Lower.at(1) ) return ManagerBase::MT_AudioManager;
173  break;
174  }
175  case 'c':
176  {
177  if( 'o' == Lower.at(1) ) {
178  if( 'l' == Lower.at(2) ) return ManagerBase::MT_CollisionShapeManager;
179  else if( 'm' == Lower.at(2) ) return ManagerBase::MT_CompositorManager;
180  }
181  break;
182  }
183  case 'd':
184  {
185  return ManagerBase::MT_DebrisManager;
186  break;
187  }
188  case 'e':
189  {
190  return ManagerBase::MT_EventManager;
191  break;
192  }
193  case 'g':
194  {
195  return ManagerBase::MT_GraphicsManager;
196  break;
197  }
198  case 'i':
199  {
200  return ManagerBase::MT_InputManager;
201  break;
202  }
203  case 'l':
204  {
205  return ManagerBase::MT_LogManager;
206  break;
207  }
208  case 'm':
209  {
210  if( 'a' == Lower.at(1) ) return ManagerBase::MT_MaterialManager;
211  else if( 'e' == Lower.at(1) )return ManagerBase::MT_MeshManager;
212  break;
213  }
214  case 'n':
215  {
216  return ManagerBase::MT_NetworkManager;
217  break;
218  }
219  case 'p':
220  {
221  if( 'a' == Lower.at(1) ) return ManagerBase::MT_PagingManager;
222  else if( 'h' == Lower.at(1) ) return ManagerBase::MT_PhysicsManager;
223  break;
224  }
225  case 'r':
226  {
227  return ManagerBase::MT_ResourceManager;
228  break;
229  }
230  case 's':
231  {
232  if( 'o' == Lower.at(1) ) {
233  return ManagerBase::MT_SoundScapeManager;
234  }else{
235  // Both of these start with the same two letters, so skip to the third.
236  if( 'e' == Lower.at(2) ) return ManagerBase::MT_SceneManager;
237  else if( 'r' == Lower.at(2) ) return ManagerBase::MT_ScriptingManager;
238  }
239  break;
240  }
241  case 't':
242  {
243  if( 'r' == Lower.at(2) ) return ManagerBase::MT_TerrainManager;
244  else if( 'x' == Lower.at(2) ) return ManagerBase::MT_TextureManager;
245  break;
246  }
247  case 'u':
248  {
249  if( 'i' == Lower.at(1) ) return ManagerBase::MT_UIManager;
250  else if( 's' == Lower.at(1) ) return ManagerBase::MT_UserCreated;
251  break;
252  }
253  case 'v':
254  {
255  return ManagerBase::MT_VehicleManager;
256  break;
257  }
258  }
259 
260  //If we got this far, there was a problem with the string provided.
261  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Attempting to get ManagerType from string, but no match was found. Is the string valid?");
262  }
263 }//Mezzanine
264 
265 #endif
virtual ManagerType GetInterfaceType() const =0
This returns the type of this manager.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
ManagerType
A listing of Manager Types.
Definition: managerbase.h:65
ManagerBase()
Class constructor.
Definition: managerbase.cpp:49
This, and values above it, is what User created managers that do not derive from any other managers a...
Definition: managerbase.h:103
virtual ~ManagerBase()
Class destructor.
Definition: managerbase.cpp:56
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
static String GetTypeAsString(const ManagerType &ManagerType)
Gets the string form of the type of manager.
Definition: managerbase.cpp:76
void ToLowerCase(String &Source)
Converts all upper case characters in a string to their respective lower case.
Definition: stringtool.cpp:193
static Entresol * GetSingletonPtr()
Fetches a pointer to the singleton.
Definition: singleton.h:97
Entresol * TheEntresol
The actual pointer to the Entresol core class.
Definition: managerbase.h:108
Thrown when parameters are checked at runtime and found invalid.
Definition: exception.h:108
static ManagerType GetTypeFromString(const String &ManagerName)
Gets the type of manager requested from a string.
Boole IsInitialized() const
Gets whether or not this manager has been initialized.
Definition: managerbase.cpp:65
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
virtual String GetInterfaceTypeAsString() const
Gets a string of the interface type of this manager.
Definition: managerbase.cpp:71
Boole Initialized
Simple Boole indicating whether or not this manager has been initialized.
Definition: managerbase.h:111