summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/NewKit/Ref.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/NewKit/Ref.hxx')
-rw-r--r--dev/Kernel/NewKit/Ref.hxx106
1 files changed, 0 insertions, 106 deletions
diff --git a/dev/Kernel/NewKit/Ref.hxx b/dev/Kernel/NewKit/Ref.hxx
deleted file mode 100644
index 14d66f0a..00000000
--- a/dev/Kernel/NewKit/Ref.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-
-/* -------------------------------------------
-
- Copyright ZKA Technologies.
-
-------------------------------------------- */
-
-#ifndef _NEWKIT_REF_HPP_
-#define _NEWKIT_REF_HPP_
-
-#include <NewKit/Defines.hxx>
-#include <NewKit/KernelCheck.hxx>
-
-namespace Kernel
-{
- template <typename T>
- class Ref final
- {
- public:
- Ref() = default;
-
- ~Ref()
- {
- if (fStrong)
- {
- fClass = nullptr;
- }
- }
-
- public:
- Ref(T cls, const bool& strong = false)
- : fClass(&cls), fStrong(strong)
- {
- }
-
- Ref& operator=(T ref)
- {
- *fClass = ref;
- return *this;
- }
-
- public:
- T operator->() const
- {
- return *fClass;
- }
-
- T& Leak() noexcept
- {
- return *fClass;
- }
-
- T& TryLeak() const noexcept
- {
- MUST_PASS(*fClass);
- return *fClass;
- }
-
- T operator*()
- {
- return *fClass;
- }
-
- bool IsStrong() const
- {
- return fStrong;
- }
-
- operator bool() noexcept
- {
- return fStrong;
- }
-
- private:
- T* fClass;
- Bool fStrong{false};
- };
-
- template <typename T>
- class NonNullRef final
- {
- public:
- NonNullRef() = delete;
- NonNullRef(nullPtr) = delete;
-
- NonNullRef(T* ref)
- : fRef(ref, true)
- {
- MUST_PASS(ref != nullptr);
- }
-
- Ref<T>& operator->()
- {
- MUST_PASS(fRef);
- return fRef;
- }
-
- NonNullRef& operator=(const NonNullRef<T>& ref) = delete;
- NonNullRef(const NonNullRef<T>& ref) = default;
-
- private:
- Ref<T> fRef{nullptr};
- };
-} // namespace Kernel
-
-#endif // ifndef _NEWKIT_REF_HPP_