// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_RESOURCEREF_HPP #define NAZARA_RESOURCEREF_HPP #include #include #include #include namespace Nz { template class ObjectRef { public: ObjectRef(); ObjectRef(T* object); ObjectRef(const ObjectRef& ref); template ObjectRef(const ObjectRef& ref); ObjectRef(ObjectRef&& ref) noexcept; ~ObjectRef(); T* Get() const; bool IsValid() const; T* Release(); bool Reset(T* object = nullptr); ObjectRef& Swap(ObjectRef& ref); explicit operator bool() const; operator T*() const; T* operator->() const; ObjectRef& operator=(T* object); ObjectRef& operator=(const ObjectRef& ref); template ObjectRef& operator=(const ObjectRef& ref); ObjectRef& operator=(ObjectRef&& ref) noexcept; private: T* m_object; }; template bool operator==(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator==(const T& lhs, const ObjectRef& rhs); template bool operator==(const ObjectRef& lhs, const T& rhs); template bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator!=(const T& lhs, const ObjectRef& rhs); template bool operator!=(const ObjectRef& lhs, const T& rhs); template bool operator<(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator<(const T& lhs, const ObjectRef& rhs); template bool operator<(const ObjectRef& lhs, const T& rhs); template bool operator<=(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator<=(const T& lhs, const ObjectRef& rhs); template bool operator<=(const ObjectRef& lhs, const T& rhs); template bool operator>(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator>(const T& lhs, const ObjectRef& rhs); template bool operator>(const ObjectRef& lhs, const T& rhs); template bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs); template bool operator>=(const T& lhs, const ObjectRef& rhs); template bool operator>=(const ObjectRef& lhs, const T& rhs); template ObjectRef ConstRefCast(const ObjectRef& ref); template ObjectRef DynamicRefCast(const ObjectRef& ref); template ObjectRef ReinterpretRefCast(const ObjectRef& ref); template ObjectRef StaticRefCast(const ObjectRef& ref); template struct PointedType> { using type = T; }; template struct PointedType const> { using type = T; }; } #include #endif // NAZARA_RESOURCEREF_HPP