diff --git a/framework/engine/src/mm/engine.cpp b/framework/engine/src/mm/engine.cpp index 87f570b..477face 100644 --- a/framework/engine/src/mm/engine.cpp +++ b/framework/engine/src/mm/engine.cpp @@ -127,7 +127,7 @@ void Engine::stop(void) { _is_running = false; } -bool Engine::enableService(service_family::family_type s_t) { +bool Engine::enableService(entt::id_type s_t) { if (_services.count(s_t)) { auto* ss_entry = _services[s_t].get(); if (ss_entry->first) { @@ -148,7 +148,7 @@ bool Engine::enableService(service_family::family_type s_t) { return false; } -void Engine::disableService(service_family::family_type s_t) { +void Engine::disableService(entt::id_type s_t) { if (_services.count(s_t)) { auto* s_entry = _services[s_t].get(); if (s_entry->first) { @@ -167,7 +167,7 @@ void Engine::disableService(service_family::family_type s_t) { } } -bool Engine::provide(service_family::family_type I, service_family::family_type T) { +bool Engine::provide(entt::id_type I, entt::id_type T) { if (!_services.count(T)) { // TODO: log error return false; diff --git a/framework/engine/src/mm/engine.hpp b/framework/engine/src/mm/engine.hpp index b1082ef..bcd2567 100644 --- a/framework/engine/src/mm/engine.hpp +++ b/framework/engine/src/mm/engine.hpp @@ -2,7 +2,7 @@ #include "./engine_fwd.hpp" -#include +#include #include #include @@ -27,10 +27,10 @@ class Engine { friend Services::ImGuiEngineTools; private: - using service_family = entt::family; + //using service_family = entt::family; public: - using service_family_type = service_family::family_type; + //using service_family_type = service_family::family_type; protected: std::unique_ptr _update_strategy; @@ -64,11 +64,11 @@ class Engine { void stop(void); private: - std::vector _service_add_order; // ? - std::vector _service_enable_order; // ? + std::vector _service_add_order; // ? + std::vector _service_enable_order; // ? std::unordered_map< - service_family::family_type, + entt::id_type, std::shared_ptr @@ -77,15 +77,16 @@ class Engine { public: template - constexpr auto type(void) { - return service_family::type; + constexpr static auto type(void) { + //return entt::type_id.hash(); + return entt::type_hash::value(); } template T& addService(Args&& ... args) { assert(!tryService()); - auto& ss_entry = _services[service_family::type] = + auto& ss_entry = _services[type()] = std::make_shared>>( std::make_pair>( false, @@ -93,11 +94,11 @@ class Engine { ) ); - _service_add_order.emplace_back(service_family::type); + _service_add_order.emplace_back(type()); // add updates to update strategy _update_strategy->registerService( - service_family::type, + type(), ss_entry.get()->second->registerUpdates() ); @@ -106,8 +107,8 @@ class Engine { template [[nodiscard]] T* tryService(void) const { - if (_services.count(service_family::type)) { - return static_cast(_services.at(service_family::type).get()->second.get()); + if (_services.count(type())) { + return static_cast(_services.at(type()).get()->second.get()); } return nullptr; @@ -126,22 +127,22 @@ class Engine { return *tmp; } - bool enableService(service_family::family_type s_t); - void disableService(service_family::family_type s_t); + bool enableService(entt::id_type s_t); + void disableService(entt::id_type s_t); template bool enableService(void) { - return enableService(service_family::type); + return enableService(type()); } template void disableService(void) { - disableService(service_family::type); + disableService(type()); } // provide T as I implementation // T needs to be an added Service - bool provide(service_family::family_type I, service_family::family_type T); + bool provide(entt::id_type I, entt::id_type T); // provide T as I implementation // T needs to be an added Service @@ -150,7 +151,7 @@ class Engine { static_assert(std::is_base_of_v, "T is not derived from I!"); static_assert(!std::is_same_v, "I and T are the same, makes no sense!"); - return provide(service_family::type, service_family::type); + return provide(type(), type()); } // TODO: reimplement??? diff --git a/framework/screen_director/src/mm/services/screen_director.hpp b/framework/screen_director/src/mm/services/screen_director.hpp index 517869a..b31b106 100644 --- a/framework/screen_director/src/mm/services/screen_director.hpp +++ b/framework/screen_director/src/mm/services/screen_director.hpp @@ -20,20 +20,20 @@ class ScreenDirector : public Service { public: struct Screen { // lists of services relevant for this screen, disable and enable are called when its changed to - std::vector start_disable; - std::vector start_enable; + std::vector start_disable; + std::vector start_enable; // register provider, when its changed to std::vector< std::pair< - Engine::service_family_type, // I - Engine::service_family_type // T + entt::id_type, // I + entt::id_type // T > > start_provide; // lists of services relevant for this screen, disable and enable are called when its changed from - std::vector end_disable; - std::vector end_enable; + std::vector end_disable; + std::vector end_enable; // called when its changed to, after services disable and enable std::function start_fn = [](MM::Engine&){};