diff options
Diffstat (limited to 'include')
24 files changed, 231 insertions, 328 deletions
diff --git a/include/cru/base/ClonablePtr.h b/include/cru/base/ClonablePtr.h deleted file mode 100644 index 1198315f..00000000 --- a/include/cru/base/ClonablePtr.h +++ /dev/null @@ -1,216 +0,0 @@ -#pragma once - -#include <cstddef> -#include <functional> -#include <memory> -#include <type_traits> - -namespace cru { -template <typename TClonable> -class ClonablePtr { - template <typename T> - friend class ClonablePtr; - - public: - using element_type = typename std::unique_ptr<TClonable>::element_type; - using pointer = typename std::unique_ptr<TClonable>::pointer; - - ClonablePtr() = default; - ClonablePtr(std::nullptr_t) noexcept : ptr_(nullptr) {} - explicit ClonablePtr(pointer p) noexcept : ptr_(p) {} - ClonablePtr(std::unique_ptr<element_type>&& p) noexcept - : ptr_(std::move(p)) {} - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr(std::unique_ptr<O>&& p) : ptr_(std::move(p)) {} - ClonablePtr(const ClonablePtr& other) : ptr_(other.ptr_->Clone()) {} - ClonablePtr(ClonablePtr&& other) = default; - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr(const ClonablePtr<O>& other) : ptr_(other.ptr_->Clone()) {} - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr(ClonablePtr<O>&& other) noexcept : ptr_(std::move(other.ptr_)) {} - ClonablePtr& operator=(std::nullptr_t) noexcept { - ptr_ = nullptr; - return *this; - } - ClonablePtr& operator=(std::unique_ptr<element_type>&& other) noexcept { - ptr_ = std::move(other); - return *this; - } - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(std::unique_ptr<O>&& p) noexcept { - ptr_ = std::move(p); - return *this; - } - ClonablePtr& operator=(const ClonablePtr& other) { - if (this != &other) { - ptr_ = std::unique_ptr<element_type>(other.ptr_->Clone()); - } - return *this; - } - ClonablePtr& operator=(ClonablePtr&& other) = default; - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(const ClonablePtr<O>& other) noexcept { - if (this != &other) { - ptr_ = std::unique_ptr<element_type>(other.ptr_->Clone()); - } - return *this; - } - template <typename O, - std::enable_if_t<std::is_convertible_v< - typename ClonablePtr<O>::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(ClonablePtr<O>&& other) noexcept { - ptr_ = std::move(other.ptr_); - } - - ~ClonablePtr() = default; - - public: - pointer release() noexcept { return ptr_.release(); } - void reset(pointer p = pointer()) noexcept { ptr_.reset(p); } - void swap(ClonablePtr& other) noexcept { ptr_.swap(other.ptr_); } - - public: - pointer get() const noexcept { return ptr_.get(); } - - operator bool() const noexcept { return ptr_ != nullptr; } - - element_type& operator*() const noexcept { return *ptr_; } - pointer operator->() const noexcept { return ptr_.get(); } - - int Compare(const ClonablePtr& other) const noexcept { - if (ptr_ == other.ptr_) { - return 0; - } else if (ptr_ < other.ptr_) { - return -1; - } else { - return 1; - } - } - - int Compare(std::nullptr_t) const noexcept { return ptr_ ? 1 : 0; } - - private: - std::unique_ptr<element_type> ptr_; -}; - -template <typename T> -void swap(ClonablePtr<T>& left, ClonablePtr<T>& right) noexcept { - left.swap(right); -} - -template <typename T> -bool operator==(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) == 0; -} - -template <typename T> -bool operator!=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) != 0; -} - -template <typename T> -bool operator<(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) < 0; -} - -template <typename T> -bool operator<=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) <= 0; -} - -template <typename T> -bool operator>(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) > 0; -} - -template <typename T> -bool operator>=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) { - return left.Compare(right) >= 0; -} - -template <typename T> -bool operator==(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) == 0; -} - -template <typename T> -bool operator!=(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) != 0; -} - -template <typename T> -bool operator<(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) < 0; -} - -template <typename T> -bool operator<=(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) <= 0; -} - -template <typename T> -bool operator>(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) > 0; -} - -template <typename T> -bool operator>=(const ClonablePtr<T>& left, std::nullptr_t) { - return left.Compare(nullptr) >= 0; -} - -template <typename T> -bool operator==(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) == 0; -} - -template <typename T> -bool operator!=(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) != 0; -} - -template <typename T> -bool operator<(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) > 0; -} - -template <typename T> -bool operator<=(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) >= 0; -} - -template <typename T> -bool operator>(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) < 0; -} - -template <typename T> -bool operator>=(std::nullptr_t, const ClonablePtr<T>& right) { - return right.Compare(nullptr) <= 0; -} - -} // namespace cru - -namespace std { -template <typename T> -struct hash<cru::ClonablePtr<T>> { - std::size_t operator()(const cru::ClonablePtr<T>& p) const { - return std::hash<typename cru::ClonablePtr<T>::pointer>(p.get()); - } -}; -} // namespace std diff --git a/include/cru/base/ClonePtr.h b/include/cru/base/ClonePtr.h new file mode 100644 index 00000000..452c2cdd --- /dev/null +++ b/include/cru/base/ClonePtr.h @@ -0,0 +1,119 @@ +#pragma once + +#include <cstddef> +#include <functional> +#include <memory> +#include <type_traits> + +namespace cru { +template <typename T> +class ClonePtr { + template <typename O> + friend class ClonePtr; + + public: + using element_type = typename std::unique_ptr<T>::element_type; + using pointer = typename std::unique_ptr<T>::pointer; + + ClonePtr() = default; + ClonePtr(std::nullptr_t) noexcept : ptr_(nullptr) {} + explicit ClonePtr(pointer p) noexcept : ptr_(p) {} + ClonePtr(std::unique_ptr<element_type>&& p) noexcept : ptr_(std::move(p)) {} + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr(std::unique_ptr<O>&& p) : ptr_(std::move(p)) {} + ClonePtr(const ClonePtr& other) : ptr_(other.ptr_->Clone()) {} + ClonePtr(ClonePtr&& other) = default; + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr(const ClonePtr<O>& other) : ptr_(other.ptr_->Clone()) {} + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr(ClonePtr<O>&& other) noexcept : ptr_(std::move(other.ptr_)) {} + ClonePtr& operator=(std::nullptr_t) noexcept { + ptr_ = nullptr; + return *this; + } + ClonePtr& operator=(std::unique_ptr<element_type>&& other) noexcept { + ptr_ = std::move(other); + return *this; + } + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr& operator=(std::unique_ptr<O>&& p) noexcept { + ptr_ = std::move(p); + return *this; + } + ClonePtr& operator=(const ClonePtr& other) { + if (this != &other) { + ptr_ = std::unique_ptr<element_type>(other.ptr_->Clone()); + } + return *this; + } + ClonePtr& operator=(ClonePtr&& other) = default; + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr& operator=(const ClonePtr<O>& other) noexcept { + if (this != &other) { + ptr_ = std::unique_ptr<element_type>(other.ptr_->Clone()); + } + return *this; + } + template <typename O, + std::enable_if_t< + std::is_convertible_v<typename ClonePtr<O>::pointer, pointer>, + int> = 0> + ClonePtr& operator=(ClonePtr<O>&& other) noexcept { + ptr_ = std::move(other.ptr_); + } + + ~ClonePtr() = default; + + public: + pointer release() noexcept { return ptr_.release(); } + void reset(pointer p = pointer()) noexcept { ptr_.reset(p); } + void swap(ClonePtr& other) noexcept { ptr_.swap(other.ptr_); } + + public: + pointer get() const noexcept { return ptr_.get(); } + + operator bool() const noexcept { return ptr_ != nullptr; } + + element_type& operator*() const noexcept { return *ptr_; } + pointer operator->() const noexcept { return ptr_.get(); } + + auto operator<=>(std::nullptr_t) const { return ptr_.operator<=>(nullptr); } + + auto operator<=>(const ClonePtr& other) const { + return ptr_.operator<=>(other.ptr_); + } + + private: + std::unique_ptr<element_type> ptr_; +}; + +template <typename T> +void swap(ClonePtr<T>& left, ClonePtr<T>& right) noexcept { + left.swap(right); +} + +} // namespace cru + +namespace std { +template <typename T> +struct hash<cru::ClonePtr<T>> { + std::size_t operator()(const cru::ClonePtr<T>& p) const { + return std::hash<typename cru::ClonePtr<T>::pointer>(p.get()); + } +}; +} // namespace std diff --git a/include/cru/ui/mapper/Mapper.h b/include/cru/ui/mapper/Mapper.h index 88081816..164329d3 100644 --- a/include/cru/ui/mapper/Mapper.h +++ b/include/cru/ui/mapper/Mapper.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/base/xml/XmlNode.h" #include <memory> @@ -88,5 +88,5 @@ template <typename T> using BasicSharedPtrMapper = BasicMapper<std::shared_ptr<T>>; template <typename T> -using BasicClonablePtrMapper = BasicMapper<ClonablePtr<T>>; +using BasicClonePtrMapper = BasicMapper<ClonePtr<T>>; } // namespace cru::ui::mapper diff --git a/include/cru/ui/mapper/MapperRegistry.h b/include/cru/ui/mapper/MapperRegistry.h index ca1170b5..fae90b40 100644 --- a/include/cru/ui/mapper/MapperRegistry.h +++ b/include/cru/ui/mapper/MapperRegistry.h @@ -35,8 +35,8 @@ class CRU_UI_API MapperRegistry { } template <typename T> - BasicClonablePtrMapper<T>* GetClonablePtrMapper() const { - return GetMapper<ClonablePtr<T>>(); + BasicClonePtrMapper<T>* GetClonePtrMapper() const { + return GetMapper<ClonePtr<T>>(); } template <typename T> diff --git a/include/cru/ui/mapper/style/AndConditionMapper.h b/include/cru/ui/mapper/style/AndConditionMapper.h index 65d0337c..5569e0fc 100644 --- a/include/cru/ui/mapper/style/AndConditionMapper.h +++ b/include/cru/ui/mapper/style/AndConditionMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API AndConditionMapper - : public BasicClonablePtrMapper<ui::style::AndCondition>, + : public BasicClonePtrMapper<ui::style::AndCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(AndConditionMapper) @@ -13,13 +13,13 @@ class CRU_UI_API AndConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::AndCondition> DoMapFromXml( + ClonePtr<ui::style::AndCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/BorderStylerMapper.h b/include/cru/ui/mapper/style/BorderStylerMapper.h index 8cb4d392..c1554255 100644 --- a/include/cru/ui/mapper/style/BorderStylerMapper.h +++ b/include/cru/ui/mapper/style/BorderStylerMapper.h @@ -1,13 +1,13 @@ #pragma once #include "../Mapper.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/style/IStylerMapper.h" #include "cru/ui/style/Styler.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { class CRU_UI_API BorderStylerMapper - : public BasicClonablePtrMapper<ui::style::BorderStyler>, + : public BasicClonePtrMapper<ui::style::BorderStyler>, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper) @@ -16,13 +16,13 @@ class CRU_UI_API BorderStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::BorderStyler> DoMapFromXml( + ClonePtr<ui::style::BorderStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/CheckedConditionMapper.h b/include/cru/ui/mapper/style/CheckedConditionMapper.h index 1bed9597..87d892a7 100644 --- a/include/cru/ui/mapper/style/CheckedConditionMapper.h +++ b/include/cru/ui/mapper/style/CheckedConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API CheckedConditionMapper - : public BasicClonablePtrMapper<ui::style::CheckedCondition>, + : public BasicClonePtrMapper<ui::style::CheckedCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CheckedConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API CheckedConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::CheckedCondition> DoMapFromXml( + ClonePtr<ui::style::CheckedCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/ClickStateConditionMapper.h b/include/cru/ui/mapper/style/ClickStateConditionMapper.h index a54a3ad4..13c72a36 100644 --- a/include/cru/ui/mapper/style/ClickStateConditionMapper.h +++ b/include/cru/ui/mapper/style/ClickStateConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API ClickStateConditionMapper - : public BasicClonablePtrMapper<ui::style::ClickStateCondition>, + : public BasicClonePtrMapper<ui::style::ClickStateCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(ClickStateConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API ClickStateConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } public: - ClonablePtr<ui::style::ClickStateCondition> DoMapFromXml( + ClonePtr<ui::style::ClickStateCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/ContentBrushStylerMapper.h b/include/cru/ui/mapper/style/ContentBrushStylerMapper.h index 04b19bf8..d15eb28a 100644 --- a/include/cru/ui/mapper/style/ContentBrushStylerMapper.h +++ b/include/cru/ui/mapper/style/ContentBrushStylerMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class ContentBrushStylerMapper - : public BasicClonablePtrMapper<ui::style::ContentBrushStyler>, + : public BasicClonePtrMapper<ui::style::ContentBrushStyler>, public virtual IStylerMapper { public: ContentBrushStylerMapper(); @@ -13,13 +13,13 @@ class ContentBrushStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::ContentBrushStyler> DoMapFromXml( + ClonePtr<ui::style::ContentBrushStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/CursorStylerMapper.h b/include/cru/ui/mapper/style/CursorStylerMapper.h index c88a5170..54ade7f0 100644 --- a/include/cru/ui/mapper/style/CursorStylerMapper.h +++ b/include/cru/ui/mapper/style/CursorStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API CursorStylerMapper - : public BasicClonablePtrMapper<ui::style::CursorStyler>, + : public BasicClonePtrMapper<ui::style::CursorStyler>, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CursorStylerMapper) @@ -14,13 +14,13 @@ class CRU_UI_API CursorStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::CursorStyler> DoMapFromXml( + ClonePtr<ui::style::CursorStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/FocusConditionMapper.h b/include/cru/ui/mapper/style/FocusConditionMapper.h index 6a7c56a2..e18150cf 100644 --- a/include/cru/ui/mapper/style/FocusConditionMapper.h +++ b/include/cru/ui/mapper/style/FocusConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API FocusConditionMapper - : public BasicClonablePtrMapper<ui::style::FocusCondition>, + : public BasicClonePtrMapper<ui::style::FocusCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(FocusConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API FocusConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::FocusCondition> DoMapFromXml( + ClonePtr<ui::style::FocusCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/FontStylerMapper.h b/include/cru/ui/mapper/style/FontStylerMapper.h index 34c94b73..6a79eb99 100644 --- a/include/cru/ui/mapper/style/FontStylerMapper.h +++ b/include/cru/ui/mapper/style/FontStylerMapper.h @@ -3,7 +3,7 @@ #include "IStylerMapper.h" namespace cru::ui::mapper::style { -class FontStylerMapper : public BasicClonablePtrMapper<ui::style::FontStyler>, +class FontStylerMapper : public BasicClonePtrMapper<ui::style::FontStyler>, public virtual IStylerMapper { public: FontStylerMapper(); @@ -12,13 +12,13 @@ class FontStylerMapper : public BasicClonablePtrMapper<ui::style::FontStyler>, public: bool SupportMapFromXml() override { return true; } - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::FontStyler> DoMapFromXml( + ClonePtr<ui::style::FontStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/HoverConditionMapper.h b/include/cru/ui/mapper/style/HoverConditionMapper.h index d3aa0b60..faa889e7 100644 --- a/include/cru/ui/mapper/style/HoverConditionMapper.h +++ b/include/cru/ui/mapper/style/HoverConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API HoverConditionMapper - : public BasicClonablePtrMapper<ui::style::HoverCondition>, + : public BasicClonePtrMapper<ui::style::HoverCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(HoverConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API HoverConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::HoverCondition> DoMapFromXml( + ClonePtr<ui::style::HoverCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/IConditionMapper.h b/include/cru/ui/mapper/style/IConditionMapper.h index 7bfd1427..27c09e82 100644 --- a/include/cru/ui/mapper/style/IConditionMapper.h +++ b/include/cru/ui/mapper/style/IConditionMapper.h @@ -1,6 +1,6 @@ #pragma once #include "../../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/Mapper.h" #include "cru/ui/style/Condition.h" #include "cru/base/xml/XmlNode.h" @@ -11,7 +11,7 @@ struct CRU_UI_API IConditionMapper : virtual Interface { return dynamic_cast<MapperBase*>(this)->XmlElementIsOfThisType(node); } - virtual ClonablePtr<ui::style::Condition> MapConditionFromXml( + virtual ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) = 0; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/IStylerMapper.h b/include/cru/ui/mapper/style/IStylerMapper.h index 4aa43665..ce9c4243 100644 --- a/include/cru/ui/mapper/style/IStylerMapper.h +++ b/include/cru/ui/mapper/style/IStylerMapper.h @@ -1,6 +1,6 @@ #pragma once #include "../../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/Mapper.h" #include "cru/ui/style/Styler.h" #include "cru/base/xml/XmlNode.h" @@ -11,7 +11,7 @@ struct CRU_UI_API IStylerMapper : virtual Interface { return dynamic_cast<MapperBase*>(this)->XmlElementIsOfThisType(node); } - virtual ClonablePtr<ui::style::Styler> MapStylerFromXml( + virtual ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) = 0; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/MarginStylerMapper.h b/include/cru/ui/mapper/style/MarginStylerMapper.h index 39d55fb6..b20452a9 100644 --- a/include/cru/ui/mapper/style/MarginStylerMapper.h +++ b/include/cru/ui/mapper/style/MarginStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API MarginStylerMapper - : public BasicClonablePtrMapper<ui::style::MarginStyler>, + : public BasicClonePtrMapper<ui::style::MarginStyler>, public virtual IStylerMapper { public: MarginStylerMapper(); @@ -14,13 +14,13 @@ class CRU_UI_API MarginStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::MarginStyler> DoMapFromXml( + ClonePtr<ui::style::MarginStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/NoConditionMapper.h b/include/cru/ui/mapper/style/NoConditionMapper.h index bd2adf14..8acb79e0 100644 --- a/include/cru/ui/mapper/style/NoConditionMapper.h +++ b/include/cru/ui/mapper/style/NoConditionMapper.h @@ -2,13 +2,13 @@ #include "../Mapper.h" #include "IConditionMapper.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/style/Condition.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { class CRU_UI_API NoConditionMapper - : public BasicClonablePtrMapper<ui::style::NoCondition>, + : public BasicClonePtrMapper<ui::style::NoCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(NoConditionMapper) @@ -17,13 +17,13 @@ class CRU_UI_API NoConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::NoCondition> DoMapFromXml( + ClonePtr<ui::style::NoCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/OrConditionMapper.h b/include/cru/ui/mapper/style/OrConditionMapper.h index de8e0695..0aa5b241 100644 --- a/include/cru/ui/mapper/style/OrConditionMapper.h +++ b/include/cru/ui/mapper/style/OrConditionMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API OrConditionMapper - : public BasicClonablePtrMapper<ui::style::OrCondition>, + : public BasicClonePtrMapper<ui::style::OrCondition>, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(OrConditionMapper) @@ -13,13 +13,13 @@ class CRU_UI_API OrConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Condition> MapConditionFromXml( + ClonePtr<ui::style::Condition> MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::OrCondition> DoMapFromXml( + ClonePtr<ui::style::OrCondition> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/PaddingStylerMapper.h b/include/cru/ui/mapper/style/PaddingStylerMapper.h index e7515ec1..bf0c5650 100644 --- a/include/cru/ui/mapper/style/PaddingStylerMapper.h +++ b/include/cru/ui/mapper/style/PaddingStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API PaddingStylerMapper - : public BasicClonablePtrMapper<ui::style::PaddingStyler>, + : public BasicClonePtrMapper<ui::style::PaddingStyler>, public virtual IStylerMapper { public: PaddingStylerMapper(); @@ -14,13 +14,13 @@ class CRU_UI_API PaddingStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::PaddingStyler> DoMapFromXml( + ClonePtr<ui::style::PaddingStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h b/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h index f46b70d5..ee4f5705 100644 --- a/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h +++ b/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API PreferredSizeStylerMapper - : public BasicClonablePtrMapper<ui::style::PreferredSizeStyler>, + : public BasicClonePtrMapper<ui::style::PreferredSizeStyler>, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(PreferredSizeStylerMapper) @@ -14,13 +14,13 @@ class CRU_UI_API PreferredSizeStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr<ui::style::Styler> MapStylerFromXml( + ClonePtr<ui::style::Styler> MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr<ui::style::PreferredSizeStyler> DoMapFromXml( + ClonePtr<ui::style::PreferredSizeStyler> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/StyleRuleMapper.h b/include/cru/ui/mapper/style/StyleRuleMapper.h index b4cb95e7..5622d0f4 100644 --- a/include/cru/ui/mapper/style/StyleRuleMapper.h +++ b/include/cru/ui/mapper/style/StyleRuleMapper.h @@ -1,12 +1,12 @@ #pragma once #include "../Mapper.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/style/StyleRule.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { -class CRU_UI_API StyleRuleMapper : public BasicClonablePtrMapper<ui::style::StyleRule> { +class CRU_UI_API StyleRuleMapper : public BasicClonePtrMapper<ui::style::StyleRule> { CRU_DEFINE_CLASS_LOG_TAG("StyleRuleMapper") public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(StyleRuleMapper) @@ -16,7 +16,7 @@ class CRU_UI_API StyleRuleMapper : public BasicClonablePtrMapper<ui::style::Styl bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; protected: - ClonablePtr<ui::style::StyleRule> DoMapFromXml( + ClonePtr<ui::style::StyleRule> DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/style/Condition.h b/include/cru/ui/style/Condition.h index 2d2dceac..e9b0e9d5 100644 --- a/include/cru/ui/style/Condition.h +++ b/include/cru/ui/style/Condition.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/base/Event.h" #include "cru/ui/controls/IClickableControl.h" #include "cru/ui/helper/ClickDetector.h" @@ -23,8 +23,8 @@ class CRU_UI_API Condition : public Object { class CRU_UI_API NoCondition : public Condition { public: - static ClonablePtr<NoCondition> Create() { - return ClonablePtr<NoCondition>(new NoCondition); + static ClonePtr<NoCondition> Create() { + return ClonePtr<NoCondition>(new NoCondition); }; std::vector<IBaseEvent*> ChangeOn(controls::Control*) const override { @@ -38,23 +38,23 @@ class CRU_UI_API NoCondition : public Condition { class CRU_UI_API CompoundCondition : public Condition { public: - explicit CompoundCondition(std::vector<ClonablePtr<Condition>> conditions); + explicit CompoundCondition(std::vector<ClonePtr<Condition>> conditions); std::vector<IBaseEvent*> ChangeOn(controls::Control* control) const override; - std::vector<ClonablePtr<Condition>> GetChildren() const { + std::vector<ClonePtr<Condition>> GetChildren() const { return conditions_; } protected: - std::vector<ClonablePtr<Condition>> conditions_; + std::vector<ClonePtr<Condition>> conditions_; }; class CRU_UI_API AndCondition : public CompoundCondition { public: - static ClonablePtr<AndCondition> Create( - std::vector<ClonablePtr<Condition>> conditions) { - return ClonablePtr<AndCondition>(new AndCondition(std::move(conditions))); + static ClonePtr<AndCondition> Create( + std::vector<ClonePtr<Condition>> conditions) { + return ClonePtr<AndCondition>(new AndCondition(std::move(conditions))); } using CompoundCondition::CompoundCondition; @@ -66,9 +66,9 @@ class CRU_UI_API AndCondition : public CompoundCondition { class CRU_UI_API OrCondition : public CompoundCondition { public: - static ClonablePtr<OrCondition> Create( - std::vector<ClonablePtr<Condition>> conditions) { - return ClonablePtr<OrCondition>(new OrCondition(std::move(conditions))); + static ClonePtr<OrCondition> Create( + std::vector<ClonePtr<Condition>> conditions) { + return ClonePtr<OrCondition>(new OrCondition(std::move(conditions))); } using CompoundCondition::CompoundCondition; @@ -80,8 +80,8 @@ class CRU_UI_API OrCondition : public CompoundCondition { class CRU_UI_API FocusCondition : public Condition { public: - static ClonablePtr<FocusCondition> Create(bool has_focus) { - return ClonablePtr<FocusCondition>(new FocusCondition(has_focus)); + static ClonePtr<FocusCondition> Create(bool has_focus) { + return ClonePtr<FocusCondition>(new FocusCondition(has_focus)); } explicit FocusCondition(bool has_focus); @@ -101,8 +101,8 @@ class CRU_UI_API FocusCondition : public Condition { class CRU_UI_API HoverCondition : public Condition { public: - static ClonablePtr<HoverCondition> Create(bool hover) { - return ClonablePtr<HoverCondition>(new HoverCondition(hover)); + static ClonePtr<HoverCondition> Create(bool hover) { + return ClonePtr<HoverCondition>(new HoverCondition(hover)); } explicit HoverCondition(bool hover) : hover_(hover) {} @@ -118,9 +118,9 @@ class CRU_UI_API HoverCondition : public Condition { class CRU_UI_API ClickStateCondition : public Condition { public: - static ClonablePtr<ClickStateCondition> Create( + static ClonePtr<ClickStateCondition> Create( helper::ClickState click_state) { - return ClonablePtr<ClickStateCondition>( + return ClonePtr<ClickStateCondition>( new ClickStateCondition(click_state)); } @@ -141,8 +141,8 @@ class CRU_UI_API ClickStateCondition : public Condition { class CRU_UI_API CheckedCondition : public Condition { public: - static ClonablePtr<CheckedCondition> Create(bool checked) { - return ClonablePtr<CheckedCondition>(new CheckedCondition(checked)); + static ClonePtr<CheckedCondition> Create(bool checked) { + return ClonePtr<CheckedCondition>(new CheckedCondition(checked)); } explicit CheckedCondition(bool checked); diff --git a/include/cru/ui/style/StyleRule.h b/include/cru/ui/style/StyleRule.h index 382cd664..dd0d8780 100644 --- a/include/cru/ui/style/StyleRule.h +++ b/include/cru/ui/style/StyleRule.h @@ -2,7 +2,7 @@ #include "../Base.h" #include "Condition.h" #include "Styler.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" namespace cru::ui::style { /** @@ -11,14 +11,14 @@ namespace cru::ui::style { */ class CRU_UI_API StyleRule { public: - static ClonablePtr<StyleRule> Create(ClonablePtr<Condition> condition, - ClonablePtr<Styler> styler, + static ClonePtr<StyleRule> Create(ClonePtr<Condition> condition, + ClonePtr<Styler> styler, std::string name = {}) { - return ClonablePtr<StyleRule>(new StyleRule( + return ClonePtr<StyleRule>(new StyleRule( std::move(condition), std::move(styler), std::move(name))); } - StyleRule(ClonablePtr<Condition> condition, ClonablePtr<Styler> styler, + StyleRule(ClonePtr<Condition> condition, ClonePtr<Styler> styler, std::string name = {}); public: @@ -26,12 +26,12 @@ class CRU_UI_API StyleRule { Condition* GetCondition() const { return condition_.get(); } Styler* GetStyler() const { return styler_.get(); } - StyleRule WithNewCondition(ClonablePtr<Condition> condition, + StyleRule WithNewCondition(ClonePtr<Condition> condition, std::string name = {}) const { return StyleRule{std::move(condition), styler_, std::move(name)}; } - StyleRule WithNewStyler(ClonablePtr<Styler> styler, + StyleRule WithNewStyler(ClonePtr<Styler> styler, std::string name = {}) const { return StyleRule{condition_, std::move(styler), std::move(name)}; } @@ -39,8 +39,8 @@ class CRU_UI_API StyleRule { bool CheckAndApply(controls::Control* control) const; private: - ClonablePtr<Condition> condition_; - ClonablePtr<Styler> styler_; + ClonePtr<Condition> condition_; + ClonePtr<Styler> styler_; std::string name_; }; } // namespace cru::ui::style diff --git a/include/cru/ui/style/Styler.h b/include/cru/ui/style/Styler.h index 3ed85e1e..0e21945d 100644 --- a/include/cru/ui/style/Styler.h +++ b/include/cru/ui/style/Styler.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" #include "ApplyBorderStyleInfo.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/platform/graphics/Brush.h" #include "cru/platform/gui/Cursor.h" #include "cru/ui/render/MeasureRequirement.h" @@ -12,7 +12,7 @@ namespace cru::ui::style { /** * \brief The base class for all styler implementations. - * \remarks Styler should be immutable. And we use cru::ClonablePtr to wrap it + * \remarks Styler should be immutable. And we use cru::ClonePtr to wrap it * in order to get both polymorphic and value semantics. */ class CRU_UI_API Styler : public Object { @@ -25,17 +25,17 @@ class CRU_UI_API Styler : public Object { class CRU_UI_API CompoundStyler : public Styler { public: template <typename... S> - static ClonablePtr<CompoundStyler> Create(ClonablePtr<S>... s) { - return ClonablePtr<CompoundStyler>( - new CompoundStyler(std::vector<ClonablePtr<Styler>>{std::move(s)...})); + static ClonePtr<CompoundStyler> Create(ClonePtr<S>... s) { + return ClonePtr<CompoundStyler>( + new CompoundStyler(std::vector<ClonePtr<Styler>>{std::move(s)...})); } - static ClonablePtr<CompoundStyler> Create( - std::vector<ClonablePtr<Styler>> stylers) { - return ClonablePtr<CompoundStyler>(new CompoundStyler(std::move(stylers))); + static ClonePtr<CompoundStyler> Create( + std::vector<ClonePtr<Styler>> stylers) { + return ClonePtr<CompoundStyler>(new CompoundStyler(std::move(stylers))); } - explicit CompoundStyler(std::vector<ClonablePtr<Styler>> stylers) + explicit CompoundStyler(std::vector<ClonePtr<Styler>> stylers) : stylers_(std::move(stylers)) {} void Apply(controls::Control* control) const override { @@ -44,24 +44,24 @@ class CRU_UI_API CompoundStyler : public Styler { } } - std::vector<ClonablePtr<Styler>> GetChildren() const { return stylers_; } + std::vector<ClonePtr<Styler>> GetChildren() const { return stylers_; } virtual CompoundStyler* Clone() const override { return new CompoundStyler(stylers_); } private: - std::vector<ClonablePtr<Styler>> stylers_; + std::vector<ClonePtr<Styler>> stylers_; }; class CRU_UI_API BorderStyler : public Styler { public: - static ClonablePtr<BorderStyler> Create() { - return ClonablePtr<BorderStyler>(new BorderStyler()); + static ClonePtr<BorderStyler> Create() { + return ClonePtr<BorderStyler>(new BorderStyler()); } - static ClonablePtr<BorderStyler> Create(ApplyBorderStyleInfo style) { - return ClonablePtr<BorderStyler>(new BorderStyler(std::move(style))); + static ClonePtr<BorderStyler> Create(ApplyBorderStyleInfo style) { + return ClonePtr<BorderStyler>(new BorderStyler(std::move(style))); } BorderStyler() = default; @@ -79,12 +79,12 @@ class CRU_UI_API BorderStyler : public Styler { class CRU_UI_API CursorStyler : public Styler { public: - static ClonablePtr<CursorStyler> Create( + static ClonePtr<CursorStyler> Create( std::shared_ptr<platform::gui::ICursor> cursor) { - return ClonablePtr<CursorStyler>(new CursorStyler(std::move(cursor))); + return ClonePtr<CursorStyler>(new CursorStyler(std::move(cursor))); } - static ClonablePtr<CursorStyler> Create(platform::gui::SystemCursorType type); + static ClonePtr<CursorStyler> Create(platform::gui::SystemCursorType type); explicit CursorStyler(std::shared_ptr<platform::gui::ICursor> cursor) : cursor_(std::move(cursor)) {} @@ -101,8 +101,8 @@ class CRU_UI_API CursorStyler : public Styler { class CRU_UI_API PreferredSizeStyler : public Styler { public: - static ClonablePtr<PreferredSizeStyler> Create(render::MeasureSize size) { - return ClonablePtr<PreferredSizeStyler>(new PreferredSizeStyler(size)); + static ClonePtr<PreferredSizeStyler> Create(render::MeasureSize size) { + return ClonePtr<PreferredSizeStyler>(new PreferredSizeStyler(size)); } explicit PreferredSizeStyler(render::MeasureSize size) : size_(size) {} @@ -121,8 +121,8 @@ class CRU_UI_API PreferredSizeStyler : public Styler { class CRU_UI_API MarginStyler : public Styler { public: - static ClonablePtr<MarginStyler> Create(const Thickness& margin) { - return ClonablePtr<MarginStyler>(new MarginStyler(margin)); + static ClonePtr<MarginStyler> Create(const Thickness& margin) { + return ClonePtr<MarginStyler>(new MarginStyler(margin)); } explicit MarginStyler(const Thickness& margin) : margin_(margin) {} @@ -139,8 +139,8 @@ class CRU_UI_API MarginStyler : public Styler { class CRU_UI_API PaddingStyler : public Styler { public: - static ClonablePtr<PaddingStyler> Create(const Thickness& padding) { - return ClonablePtr<PaddingStyler>(new PaddingStyler(padding)); + static ClonePtr<PaddingStyler> Create(const Thickness& padding) { + return ClonePtr<PaddingStyler>(new PaddingStyler(padding)); } explicit PaddingStyler(const Thickness& padding) : padding_(padding) {} @@ -157,9 +157,9 @@ class CRU_UI_API PaddingStyler : public Styler { class CRU_UI_API ContentBrushStyler : public Styler { public: - static ClonablePtr<ContentBrushStyler> Create( + static ClonePtr<ContentBrushStyler> Create( std::shared_ptr<platform::graphics::IBrush> brush) { - return ClonablePtr<ContentBrushStyler>( + return ClonePtr<ContentBrushStyler>( new ContentBrushStyler(std::move(brush))); } @@ -182,9 +182,9 @@ class CRU_UI_API ContentBrushStyler : public Styler { class CRU_UI_API FontStyler : public Styler { public: - static ClonablePtr<FontStyler> Create( + static ClonePtr<FontStyler> Create( std::shared_ptr<platform::graphics::IFont> font) { - return ClonablePtr<FontStyler>(new FontStyler(std::move(font))); + return ClonePtr<FontStyler>(new FontStyler(std::move(font))); } explicit FontStyler(std::shared_ptr<platform::graphics::IFont> font) |
