aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/main/main.cpp1
-rw-r--r--include/cru/common/ClonablePtr.hpp48
-rw-r--r--include/cru/common/Event.hpp1
-rw-r--r--include/cru/platform/HeapDebug.hpp7
-rw-r--r--src/platform/CMakeLists.txt2
-rw-r--r--src/platform/filesystem/CMakeLists.txt0
6 files changed, 31 insertions, 28 deletions
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 <memory>
-#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<element_type> ptr_;
};
@@ -104,92 +116,92 @@ void swap(ClonablePtr<T>& left, ClonablePtr<T>& right) noexcept {
template <typename T>
bool operator==(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() == right.get();
+ return left.Compare(right) == 0;
}
template <typename T>
bool operator!=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() != right.get();
+ return left.Compare(right) != 0;
}
template <typename T>
bool operator<(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() < right.get();
+ return left.Compare(right) < 0;
}
template <typename T>
bool operator<=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() <= right.get();
+ return left.Compare(right) <= 0;
}
template <typename T>
bool operator>(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() > right.get();
+ return left.Compare(right) > 0;
}
template <typename T>
bool operator>=(const ClonablePtr<T>& left, const ClonablePtr<T>& right) {
- return left.get() >= right.get();
+ return left.Compare(right) >= 0;
}
template <typename T>
bool operator==(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() == nullptr;
+ return left.Compare(nullptr) == 0;
}
template <typename T>
bool operator!=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() != nullptr;
+ return left.Compare(nullptr) != 0;
}
template <typename T>
bool operator<(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() < nullptr;
+ return left.Compare(nullptr) < 0;
}
template <typename T>
bool operator<=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() <= nullptr;
+ return left.Compare(nullptr) <= 0;
}
template <typename T>
bool operator>(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() > nullptr;
+ return left.Compare(nullptr) > 0;
}
template <typename T>
bool operator>=(const ClonablePtr<T>& left, std::nullptr_t) {
- return left.get() >= nullptr;
+ return left.Compare(nullptr) >= 0;
}
template <typename T>
bool operator==(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr == right.get();
+ return right.Compare(nullptr) == 0;
}
template <typename T>
bool operator!=(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr != right.get();
+ return right.Compare(nullptr) != 0;
}
template <typename T>
bool operator<(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr < right.get();
+ return right.Compare(nullptr) > 0;
}
template <typename T>
bool operator<=(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr <= right.get();
+ return right.Compare(nullptr) >= 0;
}
template <typename T>
bool operator>(std::nullptr_t, const ClonablePtr<T>& right) {
- return nullptr > right.get();
+ return right.Compare(nullptr) < 0;
}
template <typename T>
bool operator>=(std::nullptr_t, const ClonablePtr<T>& 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 <initializer_list>
#include <memory>
#include <utility>
-#include <variant>
#include <vector>
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
--- /dev/null
+++ b/src/platform/filesystem/CMakeLists.txt