43 #ifndef REFCOUNTEDOBJECT_H_INCLUDED
44 #define REFCOUNTEDOBJECT_H_INCLUDED
47 #include <type_traits>
52 template <
typename allocatorT =
void>
53 class RefCountedObject;
56 template <
typename T,
typename allocatorT>
58 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
bool>
::type helper_decRef(
60 template <
typename T,
typename allocatorT>
61 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
void>
::type helper_incRef(
64 template <
typename T,
typename allocatorT>
65 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value, allocatorT *&>
::type
68 template <
typename allocatorT>
72 template <
typename T_,
typename allocatorT_>
73 friend typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value,
bool>
::type
75 template <
typename T_,
typename allocatorT_>
76 friend typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value,
void>
::type
78 template <
typename T_,
typename allocatorT_>
80 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value, allocatorT_ *&>
::type
95 template <
typename T,
typename allocatorT>
96 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
bool>
::type helper_decRef(
102 if (ptr->refcount == 0)
103 throw std::bad_alloc();
106 return ptr->refcount == 0;
108 template <
typename T,
typename allocatorT>
109 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
void>
::type helper_incRef(
115 if (ptr->refcount + 1 < ptr->refcount)
116 throw std::runtime_error(
"reference counting failed (overflow)");
120 template <
typename T,
typename allocatorT>
121 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value, allocatorT *&>
::type
124 return ptr->allocator;
127 template <
typename T>
132 helper_incRef<T, typename T::refcount_allocatorT>(ptr);
135 template <
typename T>
136 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<void>, T>::value,
bool>
::type decRef(T *ptr)
138 bool ret = helper_decRef<T, void>(ptr);
general configuration and logging
friend std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT_ >, T_ >::value, void >::type helper_incRef(T_ *ptr)
friend std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT_ >, T_ >::value, bool >::type helper_decRef(T_ *ptr)
RefCountedObject(const RefCountedObject &cpy)
friend std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT_ >, T_ >::value, allocatorT_ *& >::type helper_allocator_ptr_ref(T_ *ptr)
virtual ~RefCountedObject()
RefCountedObject(RefCountedObject &&cpy)
allocatorT refcount_allocatorT
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT >, T >::value, allocatorT *& >::type helper_allocator_ptr_ref(T *ptr)
std::enable_if< std::is_base_of< etiss::RefCountedObject< ObjectPool< T > >, T >::value, bool >::type decRef(T *ptr)
std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT >, T >::value, bool >::type helper_decRef(T *ptr)
std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT >, T >::value, void >::type helper_incRef(T *ptr)