@@ -354,6 +354,7 @@ class Manager final : public Singleton<Manager, false>
354354 OrderedEvents orderedEvents;
355355 GarbageComponents garbageComponents;
356356 std::mutex locker;
357+ uint64_t tickIndex = 0 ;
357358 bool initialized = false ;
358359
359360 #ifndef NDEBUG
@@ -364,7 +365,7 @@ class Manager final : public Singleton<Manager, false>
364365public:
365366 volatile bool isRunning = false ; /* *< Is manager update loop running. */
366367
367- /* *
368+ /* ******************************************************************************************************************
368369 * @brief Creates a new manager instance.
369370 * @param setSingleton set manager singleton instance
370371 */
@@ -374,11 +375,11 @@ class Manager final : public Singleton<Manager, false>
374375 */
375376 ~Manager ();
376377
377- /* ******************************************************************************************************************
378+ /* *
378379 * @brief Creates a new system instance.
379380 *
380381 * @details
381- * Instantiates a new system and registers it component,
382+ * Allocates a new system instance and registers it component,
382383 * but initialization occurs only after the @ref initialize() call.
383384 *
384385 * @tparam T target system type
@@ -391,6 +392,8 @@ class Manager final : public Singleton<Manager, false>
391392 void createSystem (Args&&... args)
392393 {
393394 static_assert (std::is_base_of_v<System, T>, " Must be derived from the System class." );
395+ if (initialized)
396+ throw EcsmError (" Manager is already initialized, can't create a new system." );
394397 #ifndef NDEBUG
395398 if (isChanging)
396399 throw EcsmError (" Creation of the system inside other create/destroy is not allowed." );
@@ -405,42 +408,6 @@ class Manager final : public Singleton<Manager, false>
405408 #endif
406409 }
407410
408- /* *
409- * @brief Terminates and destroys system.
410- * @param type target system typeid()
411- * @throw EcsmError if system is not found.
412- */
413- void destroySystem (std::type_index type);
414- /* *
415- * @brief Terminates and destroys system.
416- * @tparam T target system type
417- * @throw EcsmError if system is not found.
418- */
419- template <class T >
420- void destroySystem ()
421- {
422- static_assert (std::is_base_of_v<System, T>, " Must be derived from the System class." );
423- destroySystem (typeid (T));
424- }
425-
426- /* *
427- * @brief Terminates and destroys system if exists.
428- * @param type target system typeid()
429- * @return True if system is destroyed, otherwise false.
430- */
431- bool tryDestroySystem (std::type_index type);
432- /* *
433- * @brief Terminates and destroys system if exists.
434- * @tparam T target system type
435- * @return True if system is destroyed, otherwise false.
436- */
437- template <class T >
438- bool tryDestroySystem ()
439- {
440- static_assert (std::is_base_of_v<System, T>, " Must be derived from the System class." );
441- return tryDestroySystem (typeid (T));
442- }
443-
444411 /* ******************************************************************************************************************
445412 * @brief Adds specified system to the system group.
446413 *
@@ -1323,28 +1290,37 @@ class Manager final : public Singleton<Manager, false>
13231290 * @note Use manager functions to check if component is garbage.
13241291 */
13251292 const GarbageComponents& getGarbageComponents () const noexcept { return garbageComponents; }
1293+ /* *
1294+ * @brief Returns current tick index since manager creation. (Total update count)
1295+ */
1296+ uint64_t getTickIndex () const noexcept { return tickIndex; }
13261297 /* *
13271298 * @brief Returns true if manager is initialized.
1299+ * @note You can't add more systems after manager initialization.
13281300 */
13291301 bool isInitialized () const noexcept { return initialized; }
13301302
13311303 /* ******************************************************************************************************************
1332- * @brief Initializes all created systems.
1304+ * @brief Initializes all manager created systems.
13331305 * @throw EcsmError if manager is already initialized.
13341306 */
13351307 void initialize ();
1308+ /* *
1309+ * @brief Terminates all manager created systems.
1310+ * @throw EcsmError if manager is already terminated.
1311+ */
1312+ void terminate ();
13361313
13371314 /* *
1338- * @brief Runs ordered events and disposes destroyed resources on each tick .
1315+ * @brief Runs ordered events and disposes destroyed resources.
13391316 * @throw EcsmError if manager is not initialized.
13401317 */
13411318 void update ();
1342-
13431319 /* *
1344- * @brief Enters update loop. Executes @ref update() on each tick.
1320+ * @brief Enters update loop. Executes @ref Manager:: update() on each tick.
13451321 * @throw EcsmError if manager is not initialized.
13461322 */
1347- void start ();
1323+ void enterLoop ();
13481324
13491325 /* ******************************************************************************************************************
13501326 * @brief Actually destroys garbage components.
0 commit comments