This is the online documentation for Colossus Entertainments
Pixie Game Engine
System.hGo to the documentation of this file.00001
00012 #ifndef __System_H__
00013 #define __System_H__
00014
00015
00016
00017
00018
00019
00020
00021 #pragma warning( disable : 4511) // copy constructor could not be generated
00022 #pragma warning( disable : 4512) // assignment operator could not be generated
00023
00024
00025 #include "Engine.h"
00026
00027
00028
00029
00030 class System
00031 {
00032 friend class SystemManager;
00033 friend class Engine;
00034 public:
00035 bool IsInitialized();
00036 bool IsStarted();
00037 bool IsRunning();
00038
00039 protected:
00040 System();
00041 virtual ~System();
00042
00043 virtual void Initialize();
00044 virtual void Start();
00045 virtual void Stop();
00046 virtual void Terminate();
00047
00048 private:
00049 void SetInitialized(bool initialized);
00050 void SetStarted(bool started);
00051
00052 private:
00053 bool initialized_;
00054 bool started_;
00055
00056
00057
00058 private:
00059 System(const System&);
00060 const System& operator=(const System&);
00061 };
00062
00063
00064 #define SYSTEM_IMPLEMENTATION(implementationName) \
00065 private: \
00066 static implementationName* Create##implementationName##Instance() \
00067 { \
00068 return new implementationName; \
00069 } \
00070 public: \
00071 static void Register() \
00072 { \
00073 Engine::GetInstance()->RegisterSystem( \
00074 #implementationName, \
00075 (void*)Create##implementationName##Instance); \
00076 }
00077
00078 #define IMPLEMENT_GETINSTANCE(className) \
00079 inline className* GetInstance_##className(bool assertExists = true) \
00080 { \
00081 static className* instance=0; \
00082 if (instance) \
00083 { \
00084 return instance; \
00085 } \
00086 \
00087 if (!assertExists && !Engine::GetInstance()->IsSystemPresent(#className)) \
00088 { \
00089 return 0; \
00090 } \
00091 \
00092 instance=(className*)Engine::GetInstance()->GetSystem(#className); \
00093 return instance; \
00094 } \
00095
00096
00097
00098 #endif
|