ezEngine  Milestone 7
SubSystem.h
1 #pragma once
2 
3 #include <Foundation/Basics.h>
5 
8 {
9  enum Enum
10  {
11  None = -1,
12  Base,
13  Core,
15 
16  ENUM_COUNT
17  };
18 };
19 
28 class EZ_FOUNDATION_DLL ezSubSystem : public ezEnumerable<ezSubSystem>
29 {
31  EZ_DISALLOW_COPY_AND_ASSIGN(ezSubSystem);
32 
33 public:
34  ezSubSystem()
35  {
36  m_szPluginName = nullptr;
37 
38  for (ezInt32 i = 0; i < ezStartupStage::ENUM_COUNT; ++i)
39  m_bStartupDone[i] = false;
40  }
41 
42  virtual ~ezSubSystem()
43  {
44  for (ezInt32 i = ezStartupStage::Core; i < ezStartupStage::ENUM_COUNT; ++i)
45  {
46  // Can't call GetSubSystemName and GetGroupName, because they are pure virtual and the destructor is called
47  // after the derived destructor has already run, thus those virtual functions are potentially not available anymore.
48  // This actually gives a linker error already.
49  EZ_ASSERT_DEV(!m_bStartupDone[i], "This SubSystem is not entirely shut down. Phase %i is still active.", i);
50  }
51  }
52 
54  virtual const char* GetSubSystemName() const = 0;
55 
57  virtual const char* GetGroupName() const = 0;
58 
60  virtual const char* GetDependency(ezInt32 iDep) { return nullptr; }
61 
63  const char* GetPluginName() const { return m_szPluginName; }
64 
66  bool IsStartupPhaseDone(ezStartupStage::Enum Stage) const { return m_bStartupDone[Stage]; }
67 
68 private:
69  // only the startup system may access the following functionality
70  friend class ezStartup;
71 
73  virtual void OnBaseStartup() { }
74 
76  virtual void OnCoreStartup() { }
77 
79  virtual void OnCoreShutdown() { }
80 
82  virtual void OnEngineStartup() { }
83 
85  virtual void OnEngineShutdown() { }
86 
88  const char* m_szPluginName;
89 
91  bool m_bStartupDone[ezStartupStage::ENUM_COUNT];
92 };
93 
95