From 193b3fe67eaadf291ae77f689362d87861c26118 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 20 Jan 2022 23:17:17 +0800 Subject: ... --- include/cru/ui/mapper/CornerRadiusMapper.hpp | 18 ++++++++++++++++++ include/cru/ui/mapper/MapperRegistry.hpp | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 include/cru/ui/mapper/CornerRadiusMapper.hpp (limited to 'include/cru/ui/mapper') diff --git a/include/cru/ui/mapper/CornerRadiusMapper.hpp b/include/cru/ui/mapper/CornerRadiusMapper.hpp new file mode 100644 index 00000000..b9fe6a52 --- /dev/null +++ b/include/cru/ui/mapper/CornerRadiusMapper.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "Mapper.hpp" + +namespace cru::ui::mapper { +class CRU_UI_API CornerRadiusMapper : public BasicMapper { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CornerRadiusMapper) + + public: + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + protected: + std::unique_ptr DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper 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& GetAllMappers() const { return mapper_list_; } + template + BasicMapper* GetMapper() const { + for (auto mapper : mapper_list_) { + if (mapper->GetTypeIndex() == typeid(T)) { + return static_cast*>(mapper); + } + } + return nullptr; + } + void RegisterMapper(MapperBase* mapper); void UnregisterMapper(MapperBase* mapper); -- cgit v1.2.3