ezEngine  Milestone 7
Startup.h
1 #pragma once
2 
3 #include <Foundation/Configuration/SubSystem.h>
4 #include <Foundation/Containers/Deque.h>
6 
7 #define EZ_GLOBALEVENT_STARTUP_CORE_BEGIN "ezStartup_StartupCore_Begin"
8 #define EZ_GLOBALEVENT_STARTUP_CORE_END "ezStartup_StartupCore_End"
9 #define EZ_GLOBALEVENT_SHUTDOWN_CORE_BEGIN "ezStartup_ShutdownCore_Begin"
10 #define EZ_GLOBALEVENT_SHUTDOWN_CORE_END "ezStartup_ShutdownCore_End"
11 
12 #define EZ_GLOBALEVENT_STARTUP_ENGINE_BEGIN "ezStartup_StartupEngine_Begin"
13 #define EZ_GLOBALEVENT_STARTUP_ENGINE_END "ezStartup_StartupEngine_End"
14 #define EZ_GLOBALEVENT_SHUTDOWN_ENGINE_BEGIN "ezStartup_ShutdownEngine_Begin"
15 #define EZ_GLOBALEVENT_SHUTDOWN_ENGINE_END "ezStartup_ShutdownEngine_End"
16 
17 #define EZ_GLOBALEVENT_UNLOAD_PLUGIN_BEGIN "ezStartup_UnloadPlugin_Begin"
18 #define EZ_GLOBALEVENT_UNLOAD_PLUGIN_END "ezStartup_UnloadPlugin_End"
19 
74 class EZ_FOUNDATION_DLL ezStartup
75 {
76 public:
77 
78  // 'Base Startup' happens even before 'Core Startup', but only really low level stuff should be done there
79  // and those subsystems should not have any dependencies on each other.
80  // 'Base Startup' is automatically done right before 'Core Startup'
81  // There is actually no 'Base Shutdown', everything that is initialized in 'Base Startup' should not require
82  // any explicit shutdown.
83 
89  static void StartupBase() { Startup(ezStartupStage::Base); }
90 
95  static void StartupCore() { Startup(ezStartupStage::Core); }
96 
102  static void ShutdownCore() { Shutdown(ezStartupStage::Core); }
103 
110  static void StartupEngine() { Startup(ezStartupStage::Engine); }
111 
117  static void ShutdownEngine() { Shutdown(ezStartupStage::Engine); }
118 
120  static void PrintAllSubsystems();
121 
125  static void ReinitToCurrentState();
126 
127 private:
128 
133  static void UnloadPluginSubSystems(const char* szPluginName);
134 
135  static void PluginEventHandler(const ezPlugin::PluginEvent& EventData);
136  static void AssignSubSystemPlugin(const char* szPluginName);
137 
138  static void ComputeOrder(ezDeque<ezSubSystem*>& Order);
139  static bool HasDependencyOnPlugin(ezSubSystem* pSubSystem, const char* szModule);
140 
141  static void Startup(ezStartupStage::Enum stage);
142  static void Shutdown(ezStartupStage::Enum stage);
143 
144  static bool s_bPrintAllSubSystems;
145  static ezStartupStage::Enum s_CurrentState;
146 };
147