28 #ifndef __SharedPtr_H__
29 #define __SharedPtr_H__
111 template<
class T>
class SharedPtr
150 assert(!
"Bad method");
179 assert(
pInfo == r.pInfo);
194 #if __cplusplus >= 201103L
196 class =
typename std::enable_if<std::is_convertible<Y*, T*>::value>::type>
211 #if __cplusplus >= 201103L
213 class =
typename std::enable_if<std::is_assignable<T*, Y*>::value>::type>
246 Y* rep =
dynamic_cast<Y*
>(
pRep);
254 inline T*
get()
const {
return pRep; }
318 return a.get() == b.get();
323 return a.get() != b.get();
326 template<
class T,
class U>
inline bool operator<(SharedPtr<T>
const& a,
SharedPtr<U> const& b)
328 return std::less<const void*>()(a.get(), b.get());
SharedPtrInfoDelete(T *o)
SharedPtrInfoDeleteT(T *o)
SharedPtr & operator=(const SharedPtr &r)
void swap(SharedPtr< T > &other)
virtual ~SharedPtrInfoDelete()
SharedPtr(const SharedPtr &r)
Use OGRE_DELETE_T to free (only MEMCATEGORY_GENERAL supported)
SharedPtr()
Constructor, does not initialise the SharedPtr.
void bind(T *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
Binds rep to the SharedPtr.
#define OGRE_NEW_T(T, category)
Allocate space for one primitive type, external type or non-virtual type with constructor parameters...
SharedPtr< Y > dynamicCast() const
AtomicScalar< unsigned > useCount
void destroy(void)
IF YOU GET A CRASH HERE, YOU FORGOT TO FREE UP POINTERS BEFORE SHUTTING OGRE DOWN Use setNull() befor...
SharedPtr(Y *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
Constructor.
void setUseCount(unsigned value)
SharedPtr< Y > staticCast() const
SharedPtr(const SharedPtr< Y > &r)
Use OGRE_DELETE to free the memory.
unsigned int useCount() const
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Use OGRE_FREE to free (only MEMCATEGORY_GENERAL supported)
SharedPtr(T *rep, SharedPtrInfo *info)
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
SharedPtrFreeMethod
The method to use to free memory on destruction.
#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...
Reference-counted shared pointer, used for objects where implicit destruction is required.
SharedPtr & operator=(const SharedPtr< Y > &r)
static SharedPtrInfo * createInfoForMethod(T *rep, SharedPtrFreeMethod method)
virtual ~SharedPtrInfoFree()
virtual ~SharedPtrInfoDeleteT()
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)