33#include <NDEVR/ConcurrentOperation.h>
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/LibAssert.h>
36#ifdef NDEVR_USE_STD_POINTER
39#ifndef NDEVR_USE_STD_POINTER
53 template<
class t_other_type,
class t_type>
54 constexpr typename std::enable_if<std::is_polymorphic<t_type>::value,
bool>::type
CheckCanCast(t_type* other)
56 return dynamic_cast<t_other_type*
>(other) !=
nullptr;
58 template<
class t_other_type,
class t_type>
59 constexpr typename std::enable_if<!std::is_polymorphic<t_type>::value,
bool>::type
CheckCanCast(t_type*)
69 template<
class t_type>
83 ,
m_object(
new t_type(std::move(value)))
105 m_object =
new t_type(std::move(value));
175 template<
class t_type>
186 Pointer(t_type* value) noexcept
189 Pointer(t_type&& value) noexcept
190 : m_ptr(
new t_type(std::move(value)))
198 lib_assert(m_ptr !=
nullptr,
"Tried to access null pointer");
201 void set(t_type&& value)
203 m_ptr = std::shared_ptr<t_type>(
new t_type(std::move(value)));
207 m_ptr = pointer.m_ptr;
220 bool isNull()
const {
return m_ptr ==
nullptr; }
223 m_ptr = std::shared_ptr<t_type>();
227 return pointer.m_ptr == m_ptr;
231 return pointer.m_ptr != m_ptr;
235 std::swap(m_ptr, pointer.m_ptr);
238 std::shared_ptr<t_type> m_ptr;
246 template<
class t_type>
247 class ConstPointer :
public Pointer<t_type>
274 void set(t_type&& value)
noexcept
294 template<
class t_other_type>
298#ifndef NDEVR_USE_STD_POINTER
310 template<
class t_type,
class t_index_type,
bool t_null_term>
318 template<
class t_type>
337 constexpr t_type&
get()
const
367 template<
class t_other_type>
371#ifndef NDEVR_USE_STD_POINTER
#define lib_assert(expression, message)
Definition LibAssert.h:61
Specific logic for reserving memory for a Buffer. When managed, and more memory is needed memory is r...
Definition Pointer.hpp:311
static uint04 decrement(volatile uint04 &value)
static uint04 increment(volatile uint04 &value)
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
ConstPointer()
Definition Pointer.hpp:250
constexpr const t_type * rawptr() const
Definition Pointer.hpp:270
ConstPointer< t_other_type > as() const
Definition Pointer.hpp:295
ConstPointer(const t_type *value) noexcept
Definition Pointer.hpp:258
ConstPointer(const Pointer< t_type > &value) noexcept
Definition Pointer.hpp:261
ConstPointer< t_type > & operator=(t_type *pointer)
Definition Pointer.hpp:289
ConstPointer(t_type &&value) noexcept
Definition Pointer.hpp:252
const t_type & get() const
Definition Pointer.hpp:265
ConstPointer< t_type > & operator=(const Pointer< t_type > &pointer) noexcept
Definition Pointer.hpp:284
void set(t_type &&value) noexcept
Definition Pointer.hpp:274
const t_type * operator->() const
Definition Pointer.hpp:278
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
DynamicPointer< t_other_type > as() const
Definition Pointer.hpp:368
void set(t_type &&value)
Definition Pointer.hpp:346
DynamicPointer & operator=(const DynamicPointer &pointer)
Definition Pointer.hpp:356
DynamicPointer(t_type *value) noexcept
Definition Pointer.hpp:324
DynamicPointer & operator=(t_type *pointer)
Definition Pointer.hpp:361
DynamicPointer()
Definition Pointer.hpp:322
constexpr t_type * rawptr() const
Definition Pointer.hpp:341
DynamicPointer(DynamicPointer< t_type > &&value) noexcept
Definition Pointer.hpp:333
t_type * operator->() const
Definition Pointer.hpp:350
DynamicPointer(t_type &&value) noexcept
Definition Pointer.hpp:327
constexpr t_type & get() const
Definition Pointer.hpp:337
DynamicPointer(const DynamicPointer< t_type > &value) noexcept
Definition Pointer.hpp:330
Provides shared ownership of a dynamically allocated object.
Definition Pointer.hpp:71
void set(t_type &&value)
Definition Pointer.hpp:101
t_type * m_object
Definition Pointer.hpp:172
Pointer & operator=(t_type *pointer)
Definition Pointer.hpp:119
PointerCore * m_core
Definition Pointer.hpp:171
constexpr t_type * rawptr() const
Definition Pointer.hpp:97
Pointer(t_type &&value) noexcept
Definition Pointer.hpp:81
t_type & get() const
Definition Pointer.hpp:92
void setToNull()
Definition Pointer.hpp:137
uint04 referenceCount() const
Definition Pointer.hpp:150
void swap(Pointer< t_type > &pointer)
Definition Pointer.hpp:165
~Pointer()
Definition Pointer.hpp:131
bool isNull() const
Definition Pointer.hpp:136
bool operator!=(const Pointer< t_type > &pointer) const
Definition Pointer.hpp:161
bool operator==(const Pointer< t_type > &pointer) const
Definition Pointer.hpp:157
Pointer() noexcept
Definition Pointer.hpp:73
Pointer(t_type *value) noexcept
Definition Pointer.hpp:77
Pointer & operator=(const Pointer &pointer)
Definition Pointer.hpp:107
Pointer(const Pointer< t_type > &value) noexcept
Definition Pointer.hpp:85
constexpr std::enable_if< std::is_polymorphic< t_type >::value, bool >::type CheckCanCast(t_type *other)
Definition Pointer.hpp:54
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Used by Pointer to store the reference count of the pointer.
Definition Pointer.hpp:46
PointerCore()
Definition Pointer.hpp:47
volatile uint04 reference_count
Definition Pointer.hpp:50