7#ifndef REFCOUNTEDOBJECT_H_INCLUDED
8#define REFCOUNTEDOBJECT_H_INCLUDED
16template <
typename allocatorT =
void>
17class RefCountedObject;
20template <
typename T,
typename allocatorT>
22typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
bool>::type
helper_decRef(
24template <
typename T,
typename allocatorT>
25typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
void>::type
helper_incRef(
28template <
typename T,
typename allocatorT>
29typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value, allocatorT *&>::type
32template <
typename allocatorT>
36 template <
typename T_,
typename allocatorT_>
37 friend typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value,
bool>::type
39 template <
typename T_,
typename allocatorT_>
40 friend typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value,
void>::type
42 template <
typename T_,
typename allocatorT_>
44 typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT_>, T_>::value, allocatorT_ *&>::type
59template <
typename T,
typename allocatorT>
60typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
bool>::type
helper_decRef(
66 if (ptr->refcount == 0)
67 throw std::bad_alloc();
70 return ptr->refcount == 0;
72template <
typename T,
typename allocatorT>
73typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value,
void>::type
helper_incRef(
79 if (ptr->refcount + 1 < ptr->refcount)
80 throw std::runtime_error(
"reference counting failed (overflow)");
84template <
typename T,
typename allocatorT>
85typename std::enable_if<std::is_base_of<etiss::RefCountedObject<allocatorT>, T>::value, allocatorT *&>::type
88 return ptr->allocator;
96 helper_incRef<T, typename T::refcount_allocatorT>(ptr);
100typename std::enable_if<std::is_base_of<etiss::RefCountedObject<void>, T>::value,
bool>::type
decRef(T *ptr)
102 bool ret = helper_decRef<T, void>(ptr);
general configuration and logging
friend std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT_ >, T_ >::value, allocatorT_ *& >::type helper_allocator_ptr_ref(T_ *ptr)
friend std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT_ >, T_ >::value, void >::type helper_incRef(T_ *ptr)
RefCountedObject(const RefCountedObject &cpy)
virtual ~RefCountedObject()
RefCountedObject(RefCountedObject &&cpy)
allocatorT refcount_allocatorT
friend 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, allocatorT *& >::type helper_allocator_ptr_ref(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< ObjectPool< T > >, T >::value, bool >::type decRef(T *ptr)
std::enable_if< std::is_base_of< etiss::RefCountedObject< allocatorT >, T >::value, void >::type helper_incRef(T *ptr)