From 01f98ce88950cdb729f5db58bf26f2fffa1c326c Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 12 Jan 2022 00:53:13 +0800 Subject: ... --- demos/main/main.cpp | 1 - include/cru/common/ClonablePtr.hpp | 48 +++++++++++++++++++++------------- include/cru/common/Event.hpp | 1 - include/cru/platform/HeapDebug.hpp | 7 ----- src/platform/CMakeLists.txt | 2 +- src/platform/filesystem/CMakeLists.txt | 0 6 files changed, 31 insertions(+), 28 deletions(-) delete mode 100644 include/cru/platform/HeapDebug.hpp create mode 100644 src/platform/filesystem/CMakeLists.txt diff --git a/demos/main/main.cpp b/demos/main/main.cpp index c98b9fcc..9a3e8d62 100644 --- a/demos/main/main.cpp +++ b/demos/main/main.cpp @@ -1,5 +1,4 @@ #include -#include "cru/platform/HeapDebug.hpp" #include "cru/platform/bootstrap/Bootstrap.hpp" #include "cru/platform/gui/Base.hpp" #include "cru/platform/gui/UiApplication.hpp" diff --git a/include/cru/common/ClonablePtr.hpp b/include/cru/common/ClonablePtr.hpp index 5e4b80c9..39b5b454 100644 --- a/include/cru/common/ClonablePtr.hpp +++ b/include/cru/common/ClonablePtr.hpp @@ -93,6 +93,18 @@ class ClonablePtr { 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(nullptr_t) const noexcept { return ptr_ ? 1 : 0; } + private: std::unique_ptr ptr_; }; @@ -104,92 +116,92 @@ void swap(ClonablePtr& left, ClonablePtr& right) noexcept { template bool operator==(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() == right.get(); + return left.Compare(right) == 0; } template bool operator!=(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() != right.get(); + return left.Compare(right) != 0; } template bool operator<(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() < right.get(); + return left.Compare(right) < 0; } template bool operator<=(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() <= right.get(); + return left.Compare(right) <= 0; } template bool operator>(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() > right.get(); + return left.Compare(right) > 0; } template bool operator>=(const ClonablePtr& left, const ClonablePtr& right) { - return left.get() >= right.get(); + return left.Compare(right) >= 0; } template bool operator==(const ClonablePtr& left, std::nullptr_t) { - return left.get() == nullptr; + return left.Compare(nullptr) == 0; } template bool operator!=(const ClonablePtr& left, std::nullptr_t) { - return left.get() != nullptr; + return left.Compare(nullptr) != 0; } template bool operator<(const ClonablePtr& left, std::nullptr_t) { - return left.get() < nullptr; + return left.Compare(nullptr) < 0; } template bool operator<=(const ClonablePtr& left, std::nullptr_t) { - return left.get() <= nullptr; + return left.Compare(nullptr) <= 0; } template bool operator>(const ClonablePtr& left, std::nullptr_t) { - return left.get() > nullptr; + return left.Compare(nullptr) > 0; } template bool operator>=(const ClonablePtr& left, std::nullptr_t) { - return left.get() >= nullptr; + return left.Compare(nullptr) >= 0; } template bool operator==(std::nullptr_t, const ClonablePtr& right) { - return nullptr == right.get(); + return right.Compare(nullptr) == 0; } template bool operator!=(std::nullptr_t, const ClonablePtr& right) { - return nullptr != right.get(); + return right.Compare(nullptr) != 0; } template bool operator<(std::nullptr_t, const ClonablePtr& right) { - return nullptr < right.get(); + return right.Compare(nullptr) > 0; } template bool operator<=(std::nullptr_t, const ClonablePtr& right) { - return nullptr <= right.get(); + return right.Compare(nullptr) >= 0; } template bool operator>(std::nullptr_t, const ClonablePtr& right) { - return nullptr > right.get(); + return right.Compare(nullptr) < 0; } template bool operator>=(std::nullptr_t, const ClonablePtr& right) { - return nullptr >= right.get(); + return right.Compare(nullptr) <= 0; } } // namespace cru diff --git a/include/cru/common/Event.hpp b/include/cru/common/Event.hpp index b6999aa4..5d60c5b3 100644 --- a/include/cru/common/Event.hpp +++ b/include/cru/common/Event.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include namespace cru { diff --git a/include/cru/platform/HeapDebug.hpp b/include/cru/platform/HeapDebug.hpp deleted file mode 100644 index 10ebfd2c..00000000 --- a/include/cru/platform/HeapDebug.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include "cru/common/PreConfig.hpp" - -namespace cru::platform { -// Setup the heap debug function. Currently I only use this on Windows... -void SetupHeapDebug(); -} // namespace cru::platform diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index 8d6929ec..466b6900 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -9,13 +9,13 @@ target_sources(cru_platform_base PUBLIC ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Color.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Exception.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/GraphicsBase.hpp - ${CRU_PLATFORM_BASE_INCLUDE_DIR}/HeapDebug.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Matrix.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Resource.hpp ) target_link_libraries(cru_platform_base PUBLIC cru_base) target_compile_definitions(cru_platform_base PRIVATE CRU_PLATFORM_EXPORT_API) +add_subdirectory(filesystem) add_subdirectory(graphics) add_subdirectory(gui) diff --git a/src/platform/filesystem/CMakeLists.txt b/src/platform/filesystem/CMakeLists.txt new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3