28 #ifndef __SharedPtr_H__ 29 #define __SharedPtr_H__ 117 template<
class T>
class SharedPtr
157 assert(!
"Bad method");
185 assert(
pRep != r.pRep ||
pInfo == r.pInfo || dynamic_cast<SharedPtrInfoNone*>(
pInfo) || dynamic_cast<SharedPtrInfoNone*>(r.pInfo));
201 #if __cplusplus >= 201103L 203 class =
typename std::enable_if<std::is_convertible<Y*, T*>::value>::type>
218 #if __cplusplus >= 201103L 220 class =
typename std::enable_if<std::is_assignable<T*, Y*>::value>::type>
227 assert(
pRep != r.pRep ||
pInfo == r.pInfo|| dynamic_cast<SharedPtrInfoNone*>(
pInfo) || dynamic_cast<SharedPtrInfoNone*>(r.pInfo));
255 Y* rep = dynamic_cast<Y*>(
pRep);
328 return a.get() == b.get();
333 return a.get() != b.get();
338 return std::less<const void*>()(a.get(), b.get());
SharedPtr(const SharedPtr< Y > &r)
void setUseCount(unsigned value)
void swap(SharedPtr< T > &other)
Use OGRE_DELETE to free the memory.
SharedPtr(T *rep, SharedPtrInfo *info)
SharedPtr & operator=(const SharedPtr< Y > &r)
Use OGRE_FREE to free (only MEMCATEGORY_GENERAL supported)
AtomicScalar< unsigned > useCount
SharedPtr & operator=(const SharedPtr &r)
virtual ~SharedPtrInfoDeleteT()
SharedPtr(const SharedPtr &r)
Don`t free resource at all, lifetime controlled externally.
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
#define OGRE_DELETE_T(ptr, T, category)
Free the memory allocated with OGRE_NEW_T. Category is required to be restated to ensure the matching...
unsigned int useCount() const
virtual ~SharedPtrInfoFree()
SharedPtr()
Constructor, does not initialise the SharedPtr.
SharedPtrInfoDelete(T *o)
SharedPtr< Y > dynamicCast() const
#define OGRE_NEW_T(T, category)
Allocate space for one primitive type, external type or non-virtual type with constructor parameters.
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
void bind(T *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
Binds rep to the SharedPtr.
void destroy(void)
IF YOU GET A CRASH HERE, YOU FORGOT TO FREE UP POINTERS BEFORE SHUTTING OGRE DOWN Use setNull() befor...
SharedPtrFreeMethod
The method to use to free memory on destruction.
Reference-counted shared pointer, used for objects where implicit destruction is required.
SharedPtr(Y *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
Constructor.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
SharedPtr< Y > staticCast() const
Use OGRE_DELETE_T to free (only MEMCATEGORY_GENERAL supported)
SharedPtrInfoDeleteT(T *o)
virtual ~SharedPtrInfoDelete()
static SharedPtrInfo * createInfoForMethod(T *rep, SharedPtrFreeMethod method)
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)