diff options
author | crupest <crupest@outlook.com> | 2022-01-20 23:17:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-20 23:17:17 +0800 |
commit | 193b3fe67eaadf291ae77f689362d87861c26118 (patch) | |
tree | bebf8343a730b3b43502d403be83350b871d672b /include/cru/ui/mapper/MapperRegistry.hpp | |
parent | c0f802594e17efd5b93d4019431bf1a6d24249c3 (diff) | |
download | cru-193b3fe67eaadf291ae77f689362d87861c26118.tar.gz cru-193b3fe67eaadf291ae77f689362d87861c26118.tar.bz2 cru-193b3fe67eaadf291ae77f689362d87861c26118.zip |
...
Diffstat (limited to 'include/cru/ui/mapper/MapperRegistry.hpp')
-rw-r--r-- | include/cru/ui/mapper/MapperRegistry.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/cru/ui/mapper/MapperRegistry.hpp b/include/cru/ui/mapper/MapperRegistry.hpp index a170440d..94643ce0 100644 --- a/include/cru/ui/mapper/MapperRegistry.hpp +++ b/include/cru/ui/mapper/MapperRegistry.hpp @@ -8,6 +8,8 @@ namespace cru::ui::mapper { class CRU_UI_API MapperRegistry { public: + static MapperRegistry* GetInstance(); + MapperRegistry(); CRU_DELETE_COPY(MapperRegistry) @@ -17,6 +19,16 @@ class CRU_UI_API MapperRegistry { const std::vector<MapperBase*>& GetAllMappers() const { return mapper_list_; } + template <typename T> + BasicMapper<T>* GetMapper() const { + for (auto mapper : mapper_list_) { + if (mapper->GetTypeIndex() == typeid(T)) { + return static_cast<BasicMapper<T>*>(mapper); + } + } + return nullptr; + } + void RegisterMapper(MapperBase* mapper); void UnregisterMapper(MapperBase* mapper); |