From 37738d254b66c818a0f63bd4ad203a29c33a3a00 Mon Sep 17 00:00:00 2001 From: sguionni Date: Sat, 22 Jun 2024 04:58:02 +0200 Subject: [PATCH] Move Collection to Util --- lib/app/include/app/action/visualization.hpp | 6 +- .../include/app/controller/camera/freefly.hpp | 2 +- .../app/controller/camera/trackball.hpp | 4 +- .../app/controller/picker/selection.hpp | 2 +- .../include/app/controller/shortcut/debug.hpp | 2 +- .../app/controller/shortcut/global.hpp | 2 +- .../app/controller/shortcut/visualization.hpp | 2 +- .../core/controller/controller_manager.hpp | 4 +- .../include/app/core/player/base_player.hpp | 4 +- lib/app/include/app/core/player/loop.hpp | 6 +- lib/app/include/app/core/player/once.hpp | 6 +- lib/app/include/app/core/player/ping_pong.hpp | 6 +- lib/app/include/app/core/player/players.hpp | 4 +- .../include/app/core/player/revert_loop.hpp | 6 +- .../include/app/core/player/revert_once.hpp | 6 +- lib/app/include/app/core/player/stop.hpp | 6 +- .../app/core/system/system_handler.hpp | 4 +- lib/app/include/app/mode/visualization.hpp | 6 +- lib/app/include/app/vtx_app.hpp | 2 +- lib/app/src/app/action/animation.cpp | 2 +- lib/app/src/app/action/visualization.cpp | 2 +- .../src/app/core/system/system_handler.cpp | 55 ------------------- lib/app/src/app/mode/visualization.cpp | 6 +- lib/app/src/app/vtx_app.cpp | 2 +- lib/tool/include/tool/core/tool_registry.hpp | 2 +- .../core => util/include/util}/collection.hpp | 8 +-- lib/{app => util}/test/src/collection.cpp | 33 +++++------ 27 files changed, 68 insertions(+), 122 deletions(-) delete mode 100644 lib/app/src/app/core/system/system_handler.cpp rename lib/{app/include/app/core => util/include/util}/collection.hpp (94%) rename lib/{app => util}/test/src/collection.cpp (67%) diff --git a/lib/app/include/app/action/visualization.hpp b/lib/app/include/app/action/visualization.hpp index 626b3fd66..d565ea6cc 100644 --- a/lib/app/include/app/action/visualization.hpp +++ b/lib/app/include/app/action/visualization.hpp @@ -2,7 +2,7 @@ #define __VTX_UI_ACTION_VISUALIZATION__ #include -#include +#include #include #include @@ -17,11 +17,11 @@ namespace VTX::App::Action::Visualization class ChangeCameraController final : public App::Core::Action::BaseAction { public: - ChangeCameraController( const App::Core::CollectionKey & p_controllerID ) : _controllerID( p_controllerID ) {} + ChangeCameraController( const Util::CollectionKey & p_controllerID ) : _controllerID( p_controllerID ) {} void execute() override; private: - App::Core::CollectionKey _controllerID; + Util::CollectionKey _controllerID; }; class ApplyNextCameraController final : public App::Core::Action::BaseAction diff --git a/lib/app/include/app/controller/camera/freefly.hpp b/lib/app/include/app/controller/camera/freefly.hpp index 88b4f7a4f..6da441c72 100644 --- a/lib/app/include/app/controller/camera/freefly.hpp +++ b/lib/app/include/app/controller/camera/freefly.hpp @@ -13,7 +13,7 @@ namespace VTX::App::Controller::Camera class Freefly : public Core::Controller::BaseCameraController { public: - inline static const Core::CollectionKey COLLECTION_ID = "CONTROLLER_FREEFLY"; + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_FREEFLY"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: diff --git a/lib/app/include/app/controller/camera/trackball.hpp b/lib/app/include/app/controller/camera/trackball.hpp index f257672a4..1b8620183 100644 --- a/lib/app/include/app/controller/camera/trackball.hpp +++ b/lib/app/include/app/controller/camera/trackball.hpp @@ -15,8 +15,8 @@ namespace VTX::App::Controller::Camera class Trackball : public Core::Controller::BaseCameraController { public: - inline static const Core::CollectionKey COLLECTION_ID = "CONTROLLER_TRACKBALL"; - inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_TRACKBALL"; + inline static const Util::Hashing::Hash HASHED_COLLECTION_ID = Util::Hashing::hash( COLLECTION_ID ); private: inline static const Core::Controller::ControllerCollection::Registration _reg { COLLECTION_ID }; diff --git a/lib/app/include/app/controller/picker/selection.hpp b/lib/app/include/app/controller/picker/selection.hpp index 639b93f69..89d38cab8 100644 --- a/lib/app/include/app/controller/picker/selection.hpp +++ b/lib/app/include/app/controller/picker/selection.hpp @@ -15,7 +15,7 @@ namespace VTX::App::Controller::Picker public: using PickingInfo = App::Application::Selection::PickingInfo; - inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_PICKER"; + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_PICKER"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: diff --git a/lib/app/include/app/controller/shortcut/debug.hpp b/lib/app/include/app/controller/shortcut/debug.hpp index 40ef0e65f..c33c97a1c 100644 --- a/lib/app/include/app/controller/shortcut/debug.hpp +++ b/lib/app/include/app/controller/shortcut/debug.hpp @@ -11,7 +11,7 @@ namespace VTX::App::Controller::Shortcut class Debug final : public Core::Controller::BaseShortcutController { public: - inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_DEBUG"; + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_DEBUG"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: diff --git a/lib/app/include/app/controller/shortcut/global.hpp b/lib/app/include/app/controller/shortcut/global.hpp index 5a4235990..c4d818b9b 100644 --- a/lib/app/include/app/controller/shortcut/global.hpp +++ b/lib/app/include/app/controller/shortcut/global.hpp @@ -13,7 +13,7 @@ namespace VTX::App::Controller::Shortcut class Global final : public Core::Controller::BaseShortcutController { public: - inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_GLOBAL"; + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_GLOBAL"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: diff --git a/lib/app/include/app/controller/shortcut/visualization.hpp b/lib/app/include/app/controller/shortcut/visualization.hpp index 294c9505d..72269be4c 100644 --- a/lib/app/include/app/controller/shortcut/visualization.hpp +++ b/lib/app/include/app/controller/shortcut/visualization.hpp @@ -12,7 +12,7 @@ namespace VTX::App::Controller::Shortcut class Visualization final : public Core::Controller::BaseShortcutController { public: - inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_VISUALIZATION"; + inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_VISUALIZATION"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: diff --git a/lib/app/include/app/core/controller/controller_manager.hpp b/lib/app/include/app/core/controller/controller_manager.hpp index 193e3446c..e4ed17a35 100644 --- a/lib/app/include/app/core/controller/controller_manager.hpp +++ b/lib/app/include/app/core/controller/controller_manager.hpp @@ -2,10 +2,10 @@ #define __VTX_UI_QT_CONTROLLER_CONTROLLER_MANAGER__ #include "base_controller.hpp" -#include +#include namespace VTX::App::Core::Controller { - using ControllerCollection = App::Core::Collection; + using ControllerCollection = Util::Collection; } // namespace VTX::App::Core::Controller #endif diff --git a/lib/app/include/app/core/player/base_player.hpp b/lib/app/include/app/core/player/base_player.hpp index ce47ac287..34619cd56 100644 --- a/lib/app/include/app/core/player/base_player.hpp +++ b/lib/app/include/app/core/player/base_player.hpp @@ -1,10 +1,10 @@ #ifndef __VTX_APP_CORE_PLAYER_BASE_PLAYER__ #define __VTX_APP_CORE_PLAYER_BASE_PLAYER__ -#include "app/core/collection.hpp" #include #include #include +#include #include namespace VTX::App::Core::Player @@ -39,7 +39,7 @@ namespace VTX::App::Core::Player virtual std::unique_ptr clone() const = 0; virtual const std::string & getDisplayName() const = 0; - virtual const CollectionKey & getCollectionKey() const = 0; + virtual const Util::CollectionKey & getCollectionKey() const = 0; Util::Callback<> onPlay; Util::Callback<> onPause; diff --git a/lib/app/include/app/core/player/loop.hpp b/lib/app/include/app/core/player/loop.hpp index b9ed3fce1..8aed1c470 100644 --- a/lib/app/include/app/core/player/loop.hpp +++ b/lib/app/include/app/core/player/loop.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class Loop : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "LOOP"; - inline static const std::string DISPLAYED_NAME = "Loop"; + inline static const Util::CollectionKey COLLECTION_ID = "LOOP"; + inline static const std::string DISPLAYED_NAME = "Loop"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -20,7 +20,7 @@ namespace VTX::App::Core::Player Loop( const Loop & p_source ) = default; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/player/once.hpp b/lib/app/include/app/core/player/once.hpp index 54dae08d6..68213dda2 100644 --- a/lib/app/include/app/core/player/once.hpp +++ b/lib/app/include/app/core/player/once.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class Once : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "ONCE"; - inline static const std::string DISPLAYED_NAME = "Once"; + inline static const Util::CollectionKey COLLECTION_ID = "ONCE"; + inline static const std::string DISPLAYED_NAME = "Once"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -20,7 +20,7 @@ namespace VTX::App::Core::Player Once( const Once & p_source ) = default; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/player/ping_pong.hpp b/lib/app/include/app/core/player/ping_pong.hpp index d76ba4131..5cdff1ac2 100644 --- a/lib/app/include/app/core/player/ping_pong.hpp +++ b/lib/app/include/app/core/player/ping_pong.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class PingPong : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "PING_PONG"; - inline static const std::string DISPLAYED_NAME = "Ping Pong"; + inline static const Util::CollectionKey COLLECTION_ID = "PING_PONG"; + inline static const std::string DISPLAYED_NAME = "Ping Pong"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -20,7 +20,7 @@ namespace VTX::App::Core::Player PingPong( const PingPong & p_source ) = default; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/player/players.hpp b/lib/app/include/app/core/player/players.hpp index d96060932..e836c086c 100644 --- a/lib/app/include/app/core/player/players.hpp +++ b/lib/app/include/app/core/player/players.hpp @@ -1,11 +1,11 @@ #ifndef __VTX_APP_CORE_PLAYER_PLAYERS__ #define __VTX_APP_CORE_PLAYER_PLAYERS__ -#include "app/core/collection.hpp" +#include "Util/collection.hpp" #include "app/core/player/base_player.hpp" namespace VTX::App::Core::Player { - using Players = Collection; + using Players = Util::Collection; } // namespace VTX::App::Core::Player #endif diff --git a/lib/app/include/app/core/player/revert_loop.hpp b/lib/app/include/app/core/player/revert_loop.hpp index c1d106ff1..58945e42d 100644 --- a/lib/app/include/app/core/player/revert_loop.hpp +++ b/lib/app/include/app/core/player/revert_loop.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class RevertLoop : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "REVERT_LOOP"; - inline static const std::string DISPLAYED_NAME = "Revert Loop"; + inline static const Util::CollectionKey COLLECTION_ID = "REVERT_LOOP"; + inline static const std::string DISPLAYED_NAME = "Revert Loop"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -20,7 +20,7 @@ namespace VTX::App::Core::Player RevertLoop( const RevertLoop & p_source ) = default; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/player/revert_once.hpp b/lib/app/include/app/core/player/revert_once.hpp index 564823254..baf248adc 100644 --- a/lib/app/include/app/core/player/revert_once.hpp +++ b/lib/app/include/app/core/player/revert_once.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class RevertOnce : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "REVERT_ONCE"; - inline static const std::string DISPLAYED_NAME = "Revert Once"; + inline static const Util::CollectionKey COLLECTION_ID = "REVERT_ONCE"; + inline static const std::string DISPLAYED_NAME = "Revert Once"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -20,7 +20,7 @@ namespace VTX::App::Core::Player RevertOnce( const RevertOnce & p_source ) = default; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/player/stop.hpp b/lib/app/include/app/core/player/stop.hpp index ef4f1fa09..e1a953337 100644 --- a/lib/app/include/app/core/player/stop.hpp +++ b/lib/app/include/app/core/player/stop.hpp @@ -9,8 +9,8 @@ namespace VTX::App::Core::Player class Stop : public BasePlayer { public: - inline static const CollectionKey COLLECTION_ID = "STOP"; - inline static const std::string DISPLAYED_NAME = "Stop"; + inline static const Util::CollectionKey COLLECTION_ID = "STOP"; + inline static const std::string DISPLAYED_NAME = "Stop"; private: inline static const Players::Registration _reg { COLLECTION_ID }; @@ -22,7 +22,7 @@ namespace VTX::App::Core::Player void play() override; const std::string & getDisplayName() const override { return DISPLAYED_NAME; } - const CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } + const Util::CollectionKey & getCollectionKey() const override { return COLLECTION_ID; } std::unique_ptr clone() const override { return std::make_unique( *this ); } void reset() override; diff --git a/lib/app/include/app/core/system/system_handler.hpp b/lib/app/include/app/core/system/system_handler.hpp index c20e2926a..f66a1b735 100644 --- a/lib/app/include/app/core/system/system_handler.hpp +++ b/lib/app/include/app/core/system/system_handler.hpp @@ -21,14 +21,14 @@ namespace VTX::App::Core::System ~SystemHandler() = default; template - inline void store( const Util::Hashing::Hash & p_hash ) + void store( const Util::Hashing::Hash & p_hash ) { assert( not _systems.contains( p_hash ) ); const std::unique_ptr & ptr = _storage.emplace_back( std::make_unique() ); _systems.emplace( p_hash, ptr.get() ); } - inline void reference( const Util::Hashing::Hash & p_hash, BaseSystem * p_systemPtr ) + void reference( const Util::Hashing::Hash & p_hash, BaseSystem * p_systemPtr ) { assert( not _systems.contains( p_hash ) ); _systems.emplace( p_hash, p_systemPtr ); diff --git a/lib/app/include/app/mode/visualization.hpp b/lib/app/include/app/mode/visualization.hpp index 5767ae4f0..be0872b3e 100644 --- a/lib/app/include/app/mode/visualization.hpp +++ b/lib/app/include/app/mode/visualization.hpp @@ -49,12 +49,12 @@ namespace VTX::App::Mode return *_currentPickerController; } - Core::Controller::BaseController & getController( const App::Core::CollectionKey & p_controllerKey ); + Core::Controller::BaseController & getController( const Util::CollectionKey & p_controllerKey ); void setCameraController( const Util::Hashing::Hash & p_controllerKey ); - void setCameraController( const App::Core::CollectionKey & p_controllerKey ); + void setCameraController( const Util::CollectionKey & p_controllerKey ); void setPickerController( const Util::Hashing::Hash & p_controllerHash ); - void setPickerController( const App::Core::CollectionKey & p_controllerKey ); + void setPickerController( const Util::CollectionKey & p_controllerKey ); const std::set> & getCameraControllers() const { diff --git a/lib/app/include/app/vtx_app.hpp b/lib/app/include/app/vtx_app.hpp index f045c349b..50cc27aff 100644 --- a/lib/app/include/app/vtx_app.hpp +++ b/lib/app/include/app/vtx_app.hpp @@ -50,7 +50,7 @@ namespace VTX::App inline Mode::BaseMode & getCurrentMode() { return *_currentMode; } inline const Mode::BaseMode & getCurrentMode() const { return *_currentMode; } - Util::Callback<> onAppReady; + Util::Callback<> onStart; Util::Callback onPreUpdate; Util::Callback onUpdate; diff --git a/lib/app/src/app/action/animation.cpp b/lib/app/src/app/action/animation.cpp index 00d7b4ccd..e646bf3c7 100644 --- a/lib/app/src/app/action/animation.cpp +++ b/lib/app/src/app/action/animation.cpp @@ -2,7 +2,7 @@ #include "app/core/animation/animation_system.hpp" #include #include -#include +#include namespace VTX::App::Action::Animation { diff --git a/lib/app/src/app/action/visualization.cpp b/lib/app/src/app/action/visualization.cpp index e4ad43fca..9bdbc10ce 100644 --- a/lib/app/src/app/action/visualization.cpp +++ b/lib/app/src/app/action/visualization.cpp @@ -1,9 +1,9 @@ #include "app/action/visualization.hpp" -#include "app/core/collection.hpp" #include "app/core/controller/base_camera_controller.hpp" #include "app/core/controller/controller_manager.hpp" #include "app/mode/base_mode.hpp" #include "app/mode/visualization.hpp" +#include namespace VTX::App::Action::Visualization { diff --git a/lib/app/src/app/core/system/system_handler.cpp b/lib/app/src/app/core/system/system_handler.cpp deleted file mode 100644 index c20e2926a..000000000 --- a/lib/app/src/app/core/system/system_handler.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __VTX_APP_CORE_SYSTEM_SYSTEM_HANDLER__ -#define __VTX_APP_CORE_SYSTEM_SYSTEM_HANDLER__ - -#include "app/core/system/base_system.hpp" -#include -#include -#include -#include -#include -#include - -namespace VTX::App::Core::System -{ - template - concept SystemConcept = std::derived_from; - - class SystemHandler - { - public: - SystemHandler() = default; - ~SystemHandler() = default; - - template - inline void store( const Util::Hashing::Hash & p_hash ) - { - assert( not _systems.contains( p_hash ) ); - const std::unique_ptr & ptr = _storage.emplace_back( std::make_unique() ); - _systems.emplace( p_hash, ptr.get() ); - } - - inline void reference( const Util::Hashing::Hash & p_hash, BaseSystem * p_systemPtr ) - { - assert( not _systems.contains( p_hash ) ); - _systems.emplace( p_hash, p_systemPtr ); - } - - inline bool exists( const Util::Hashing::Hash & p_hash ) const - { - return _systems.find( p_hash ) != _systems.end(); - } - - template - inline T & get( const Util::Hashing::Hash & p_hash ) - { - assert( _systems.contains( p_hash ) ); - return static_cast( *_systems[ p_hash ] ); - } - - private: - std::vector> _storage; - std::map _systems; - }; -} // namespace VTX::App::Core::System - -#endif diff --git a/lib/app/src/app/mode/visualization.cpp b/lib/app/src/app/mode/visualization.cpp index 60971753e..1168587f6 100644 --- a/lib/app/src/app/mode/visualization.cpp +++ b/lib/app/src/app/mode/visualization.cpp @@ -93,7 +93,7 @@ namespace VTX::App::Mode _otherControllers.emplace( std::move( p_controllerPtr ) ); } - Core::Controller::BaseController & Visualization::getController( const App::Core::CollectionKey & p_controllerKey ) + Core::Controller::BaseController & Visualization::getController( const Util::CollectionKey & p_controllerKey ) { const auto controllerIt = std::find_if( _otherControllers.begin(), @@ -125,7 +125,7 @@ namespace VTX::App::Mode onCameraController( *_currentCameraController ); } - void Visualization::setCameraController( const App::Core::CollectionKey & p_controllerKey ) + void Visualization::setCameraController( const Util::CollectionKey & p_controllerKey ) { setCameraController( Util::Hashing::hash( p_controllerKey ) ); } @@ -149,7 +149,7 @@ namespace VTX::App::Mode onPickerController( *_currentPickerController ); } - void Visualization::setPickerController( const App::Core::CollectionKey & p_controllerKey ) + void Visualization::setPickerController( const Util::CollectionKey & p_controllerKey ) { setPickerController( Util::Hashing::hash( p_controllerKey ) ); } diff --git a/lib/app/src/app/vtx_app.cpp b/lib/app/src/app/vtx_app.cpp index c2a33f09e..898c88fd3 100644 --- a/lib/app/src/app/vtx_app.cpp +++ b/lib/app/src/app/vtx_app.cpp @@ -68,7 +68,7 @@ namespace VTX::App _handleArgs( p_args ); - onAppReady(); + onStart(); } void VTXApp::update( const float p_elapsedTime ) diff --git a/lib/tool/include/tool/core/tool_registry.hpp b/lib/tool/include/tool/core/tool_registry.hpp index 26b5ad5e3..a6dfff6b6 100644 --- a/lib/tool/include/tool/core/tool_registry.hpp +++ b/lib/tool/include/tool/core/tool_registry.hpp @@ -3,11 +3,11 @@ #include "base_ui_tool.hpp" #include "layout_descriptor.hpp" -#include #include #include #include #include +#include namespace VTX::UI::Core { diff --git a/lib/app/include/app/core/collection.hpp b/lib/util/include/util/collection.hpp similarity index 94% rename from lib/app/include/app/core/collection.hpp rename to lib/util/include/util/collection.hpp index 693e53e31..c25bd96d3 100644 --- a/lib/app/include/app/core/collection.hpp +++ b/lib/util/include/util/collection.hpp @@ -1,14 +1,14 @@ #ifndef __VTX_APP_CORE_COLLECTION__ #define __VTX_APP_CORE_COLLECTION__ +#include "util/generic/base_static_singleton.hpp" +#include "util/hashing.hpp" #include #include #include #include -#include -#include -namespace VTX::App::Core +namespace VTX::Util { using CollectionKey = std::string; @@ -80,5 +80,5 @@ namespace VTX::App::Core std::map> _collection; }; -} // namespace VTX::App::Core +} // namespace VTX::Util #endif diff --git a/lib/app/test/src/collection.cpp b/lib/util/test/src/collection.cpp similarity index 67% rename from lib/app/test/src/collection.cpp rename to lib/util/test/src/collection.cpp index 12a371cc6..9b41263de 100644 --- a/lib/app/test/src/collection.cpp +++ b/lib/util/test/src/collection.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include namespace @@ -16,7 +16,7 @@ namespace virtual std::unique_ptr clone() const = 0; }; - using CollectionTest = VTX::App::Core::Collection; + using CollectionTest = VTX::Util::Collection; class DerivedClass1 final : public BaseClass { private: @@ -62,50 +62,51 @@ namespace TEST_CASE( "VTX_APP - Core::Collection", "[unit]" ) { using namespace VTX; - using namespace VTX::App; + using namespace VTX::Util; std::unique_ptr ptr = nullptr; - ptr = CollectionTest::get().instantiateItem( "DerivedClass1" ); + auto & collection = CollectionTest::get(); + + ptr = collection.instantiateItem( "DerivedClass1" ); REQUIRE( ptr != nullptr ); CHECK( ptr->getValue() == 1 ); - ptr = CollectionTest::get().instantiateItem( "DerivedClass2" ); + ptr = collection.instantiateItem( "DerivedClass2" ); REQUIRE( ptr != nullptr ); CHECK( ptr->getValue() == 2 ); - ptr = CollectionTest::get().instantiateItem( "DerivedClass3" ); + ptr = collection.instantiateItem( "DerivedClass3" ); REQUIRE( ptr != nullptr ); CHECK( ptr->getValue() == 3 ); - ptr = CollectionTest::get().instantiateItem( "DerivedClass100" ); + ptr = collection.instantiateItem( "DerivedClass100" ); CHECK( ptr == nullptr ); - ptr = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass1" ) ); + ptr = collection.instantiateItem( Util::Hashing::hash( "DerivedClass1" ) ); REQUIRE( ptr != nullptr ); CHECK( ptr->getValue() == 1 ); - ptr = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass2" ) ); + ptr = collection.instantiateItem( Util::Hashing::hash( "DerivedClass2" ) ); REQUIRE( ptr != nullptr ); CHECK( ptr->getValue() == 2 ); - ptr = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass3" ) ); + ptr = collection.instantiateItem( Util::Hashing::hash( "DerivedClass3" ) ); CHECK( ptr != nullptr ); CHECK( ptr->getValue() == 3 ); - ptr = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass100" ) ); + ptr = collection.instantiateItem( Util::Hashing::hash( "DerivedClass100" ) ); CHECK( ptr == nullptr ); - std::unique_ptr ptrDerivedClass1 - = CollectionTest::get().instantiateItem( "DerivedClass1" ); + std::unique_ptr ptrDerivedClass1 = collection.instantiateItem( "DerivedClass1" ); REQUIRE( ptrDerivedClass1 != nullptr ); - ptrDerivedClass1 = CollectionTest::get().instantiateItem( "DerivedClass2" ); + ptrDerivedClass1 = collection.instantiateItem( "DerivedClass2" ); REQUIRE( ptrDerivedClass1 == nullptr ); - ptrDerivedClass1 = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass1" ) ); + ptrDerivedClass1 = collection.instantiateItem( Util::Hashing::hash( "DerivedClass1" ) ); REQUIRE( ptrDerivedClass1 != nullptr ); - ptrDerivedClass1 = CollectionTest::get().instantiateItem( Util::Hashing::hash( "DerivedClass2" ) ); + ptrDerivedClass1 = collection.instantiateItem( Util::Hashing::hash( "DerivedClass2" ) ); REQUIRE( ptrDerivedClass1 == nullptr ); };