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
50 template<
class t_other_type,
class t_type>
51 constexpr typename std::enable_if<std::is_polymorphic<t_type>::value,
bool>::type
CheckCanCast(t_type* other)
53 return dynamic_cast<t_other_type*
>(other) !=
nullptr;
55 template<
class t_other_type,
class t_type>
56 constexpr typename std::enable_if<!std::is_polymorphic<t_type>::value,
bool>::type
CheckCanCast(t_type*)
60 template<
class t_type>
69 :
m_core(value ==
nullptr ?
nullptr :
new Core())
74 ,
m_object(
new t_type(std::move(value)))
92 void set(t_type&& value)
96 m_object =
new t_type(std::move(value));
166 template<
class t_type>
177 Pointer(t_type* value) noexcept
180 Pointer(t_type&& value) noexcept
181 : m_ptr(
new t_type(std::move(value)))
189 lib_assert(m_ptr !=
nullptr,
"Tried to access null pointer");
192 void set(t_type&& value)
194 m_ptr = std::shared_ptr<t_type>(
new t_type(std::move(value)));
198 m_ptr = pointer.m_ptr;
211 bool isNull()
const {
return m_ptr ==
nullptr; }
214 m_ptr = std::shared_ptr<t_type>();
218 return pointer.m_ptr == m_ptr;
222 return pointer.m_ptr != m_ptr;
226 std::swap(m_ptr, pointer.m_ptr);
229 std::shared_ptr<t_type> m_ptr;
232 template<
class t_type>
233 class ConstPointer :
public Pointer<t_type>
260 void set(t_type&& value)
noexcept
280 template<
class t_other_type>
284#ifndef NDEVR_USE_STD_POINTER
296 template<
class t_type,
class t_index_type,
bool t_null_term>
298 template<
class t_allocater,
class t_type>
301 template<
class t_type>
321 constexpr t_type&
get()
const
351 template<
class t_other_type>
355#ifndef NDEVR_USE_STD_POINTER
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Definition Pointer.hpp:297
static uint04 increment(volatile uint04 &value)
Definition ConcurrentOperation.cpp:12
static uint04 decrement(volatile uint04 &value)
Definition ConcurrentOperation.cpp:20
Definition GraphicsPipeline.h:42
ConstPointer()
Definition Pointer.hpp:236
constexpr const t_type * rawptr() const
Definition Pointer.hpp:256
ConstPointer< t_other_type > as() const
Definition Pointer.hpp:281
ConstPointer(const t_type *value) noexcept
Definition Pointer.hpp:244
ConstPointer(const Pointer< t_type > &value) noexcept
Definition Pointer.hpp:247
ConstPointer< t_type > & operator=(t_type *pointer)
Definition Pointer.hpp:275
ConstPointer(t_type &&value) noexcept
Definition Pointer.hpp:238
const t_type & get() const
Definition Pointer.hpp:251
ConstPointer< t_type > & operator=(const Pointer< t_type > &pointer) noexcept
Definition Pointer.hpp:270
void set(t_type &&value) noexcept
Definition Pointer.hpp:260
const t_type * operator->() const
Definition Pointer.hpp:264
Definition Pointer.hpp:303
DynamicPointer< t_other_type > as() const
Definition Pointer.hpp:352
void set(t_type &&value)
Definition Pointer.hpp:330
DynamicPointer & operator=(const DynamicPointer &pointer)
Definition Pointer.hpp:340
DynamicPointer(t_type *value) noexcept
Definition Pointer.hpp:308
DynamicPointer & operator=(t_type *pointer)
Definition Pointer.hpp:345
DynamicPointer()
Definition Pointer.hpp:306
constexpr t_type * rawptr() const
Definition Pointer.hpp:325
DynamicPointer(DynamicPointer< t_type > &&value) noexcept
Definition Pointer.hpp:317
t_type * operator->() const
Definition Pointer.hpp:334
DynamicPointer(t_type &&value) noexcept
Definition Pointer.hpp:311
constexpr t_type & get() const
Definition Pointer.hpp:321
DynamicPointer(const DynamicPointer< t_type > &value) noexcept
Definition Pointer.hpp:314
Definition Pointer.hpp:299
Definition Pointer.hpp:62
void set(t_type &&value)
Definition Pointer.hpp:92
t_type * m_object
Definition Pointer.hpp:163
Pointer & operator=(t_type *pointer)
Definition Pointer.hpp:110
constexpr t_type * rawptr() const
Definition Pointer.hpp:88
Pointer(t_type &&value) noexcept
Definition Pointer.hpp:72
Core * m_core
Definition Pointer.hpp:162
t_type & get() const
Definition Pointer.hpp:83
void setToNull()
Definition Pointer.hpp:128
uint04 referenceCount() const
Definition Pointer.hpp:141
void swap(Pointer< t_type > &pointer)
Definition Pointer.hpp:156
~Pointer()
Definition Pointer.hpp:122
bool isNull() const
Definition Pointer.hpp:127
bool operator!=(const Pointer< t_type > &pointer) const
Definition Pointer.hpp:152
bool operator==(const Pointer< t_type > &pointer) const
Definition Pointer.hpp:148
Pointer() noexcept
Definition Pointer.hpp:64
Pointer(t_type *value) noexcept
Definition Pointer.hpp:68
Pointer & operator=(const Pointer &pointer)
Definition Pointer.hpp:98
Pointer(const Pointer< t_type > &value) noexcept
Definition Pointer.hpp:76
constexpr std::enable_if< std::is_polymorphic< t_type >::value, bool >::type CheckCanCast(t_type *other)
Definition Pointer.hpp:51
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
Definition Pointer.hpp:43
Core()
Definition Pointer.hpp:44
volatile uint04 reference_count
Definition Pointer.hpp:47