1#ifndef SDL3PP_RESOURCE_H_
2#define SDL3PP_RESOURCE_H_
18template<
typename RAW_POINTER,
typename RAW_CONST_POINTER = RAW_POINTER>
30 : m_resource(resource)
41 constexpr explicit operator bool()
const {
return !!m_resource; }
65 std::swap(lhs.m_resource, rhs.m_resource);
73template<
typename RAW_POINTER>
82 : m_resource(resource)
93 constexpr explicit operator bool()
const {
return !!m_resource; }
99 constexpr operator RawPointer()
const {
return m_resource; }
109template<
typename RAW_POINTER,
typename RAW_CONST_POINTER>
121 : m_resource(resource)
127 : m_resource(nullptr)
132 constexpr explicit operator bool()
const {
return !!m_resource; }
154template<
typename RESOURCE>
157 using RESOURCE::RESOURCE;
185 : RESOURCE(resource.get())
197 : RESOURCE(std::move(resource).
release())
203 : RESOURCE(other.get())
209 : RESOURCE(other.get())
220 RESOURCE::operator=(RESOURCE(other.get()));
Base class for resources.
Definition SDL3pp_resource.h:20
constexpr RawPointer get() const noexcept
Retrieves underlying resource pointer.
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Retrieves underlying resource pointer and clear this.
Definition SDL3pp_resource.h:56
constexpr auto operator<=>(const ResourceBase &other) const =default
Comparison.
constexpr RawConstPointer operator->() const noexcept
member access to underlying resource pointer.
Definition SDL3pp_resource.h:47
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr ResourceBase(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition SDL3pp_resource.h:35
constexpr RawPointer operator->() noexcept
member access to underlying resource pointer.
Definition SDL3pp_resource.h:50
RAW_CONST_POINTER RawConstPointer
The underlying const raw pointer type.
Definition SDL3pp_resource.h:26
RAW_POINTER RawPointer
The underlying raw pointer type.
Definition SDL3pp_resource.h:23
AnimationRaw RawPointer
Definition SDL3pp_resource.h:114
AnimationRawConst RawConstPointer
Definition SDL3pp_resource.h:117
constexpr ResourceConstRef(RawConstPointer resource)
Constructs from const pointer.
Definition SDL3pp_resource.h:120
constexpr auto operator<=>(const ResourceConstRef &other) const =default
Comparison.
constexpr ResourceConstRef(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition SDL3pp_resource.h:126
constexpr auto operator->() const
member access to underlying type.
Definition SDL3pp_resource.h:147
constexpr auto operator->() const
member access to underlying type.
Definition SDL3pp_resource.h:102
constexpr ResourceLegacyRef(RawPointer resource)
Constructs from RawPointer.
Definition SDL3pp_resource.h:81
RAW_POINTER RawPointer
The underlying raw pointer type.
Definition SDL3pp_resource.h:78
constexpr auto operator<=>(const ResourceLegacyRef &other) const =default
Comparison.
constexpr ResourceLegacyRef(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition SDL3pp_resource.h:87
Main include header for the SDL3pp library.
constexpr ResourceRef(RawPointer resource) noexcept
Constructs from raw resource.
Definition SDL3pp_resource.h:172
constexpr ResourceRef(RESOURCE &&resource) noexcept
Constructs from RESOURCE.
Definition SDL3pp_resource.h:196
~ResourceRef()
Destructor.
Definition SDL3pp_resource.h:214
constexpr ResourceRef(ResourceRef &&other) noexcept
Move constructor.
Definition SDL3pp_resource.h:208
AsyncIO::RawConstPointer RawConstPointer
Definition SDL3pp_resource.h:163
AsyncIO::RawPointer RawPointer
Definition SDL3pp_resource.h:160
constexpr ResourceRef(const RESOURCE &resource) noexcept
Constructs from resource.
Definition SDL3pp_resource.h:184
constexpr ResourceRef(const ResourceRef &other) noexcept
Copy constructor.
Definition SDL3pp_resource.h:202
ResourceRef & operator=(const ResourceRef &other) noexcept
Assignment operator.
Definition SDL3pp_resource.h:217