i6engine  1.0
SubSystemController.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_CORE_SUBSYSTEMCONTROLLER_H__
26 #define __I6ENGINE_CORE_SUBSYSTEMCONTROLLER_H__
27 
28 #include <cstdint>
29 #include <mutex>
30 #include <set>
31 
33 
35 
36 #include "boost/thread.hpp"
37 
62 namespace i6e {
63 namespace core {
64 
65  class EngineControllerInterface;
66  class EngineCoreController;
67  class ModuleController;
68 
69  enum class SubsystemType;
70 
71  typedef struct {
74  uint32_t framerate;
75  std::set<Subsystem> waitingFor;
76  } QueuedModule;
77 
86  /* Only the EngineCoreController should run methods of this class */
87  friend class EngineCoreController;
88 
89  public:
94 
99  inline bool getGlobalShutDown() const { return _bolGlobalShutDown; }
100 
104  void ShutDown();
105 
109  void JoinAllSubsystems();
110 
114  inline void SubSystemInitialized() { _bolWaitForInit = false; }
115 
122  void QueueSubSystemStart(ModuleController * objSubsystem, const uint32_t lngFrameTime);
123 
130  void QueueSubSystemStart(ModuleController * objSubsystem, const std::set<Subsystem> & waitingFor);
131 
136  inline size_t GetSubSystemAmount() const { return _objQueuedSubSystems.size(); }
137 
141  bool isShutdownComplete();
142 
146  void registerController(EngineCoreController * ecc) { _coreController = ecc; }
147 
148  private:
149  bool _bolGlobalShutDown;
150  bool _bolWaitForInit;
151  std::vector<boost::thread *> _objThreadGrp;
152  std::vector<QueuedModule> _objQueuedSubSystems;
153  EngineCoreController * _coreController;
154  std::mutex _lock;
155 
159  void Start();
160 
164  void startSubSystemTicking(ModuleController * objSubSystem, const uint32_t lngFrameTime);
165 
169  void startSubSystemWaiting(ModuleController * objSubSystem, const std::set<Subsystem> & waitingFor);
170 
174  SubSystemController(const SubSystemController &) = delete;
175 
179  SubSystemController & operator=(const SubSystemController &) = delete;
180  };
181 
182 } /* namespace core */
183 } /* namespace i6e */
184 
185 #endif /* __I6ENGINE_CORE_SUBSYSTEMCONTROLLER_H__ */
186 
size_t GetSubSystemAmount() const
This method returns the amount of subsystems.
bool getGlobalShutDown() const
This method will get the flag which indicates if the subsystems have to be shut down.
Part of the Subsystem that keeps the whole module running.
ModuleController * module
this class is used as an abstraction layer
#define ISIXE_CORE_API
void registerController(EngineCoreController *ecc)
registers an EngineCoreController for the SubSystemController
std::set< Subsystem > waitingFor
void SubSystemInitialized()
This methods tells the SubSystemController that the synchronously started SubSystem has been complete...
This class is used as an abstraction layer.