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; }
264 assert(!pRep && !pInfo);
275 inline bool isNull(
void)
const {
return pRep == 0; }
305 assert(pRep && pInfo);
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());
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)
unsigned int useCount() const
AtomicScalar< unsigned > useCount
SharedPtr< Y > staticCast() const
SharedPtr & operator=(const SharedPtr &r)
virtual ~SharedPtrInfoDeleteT()
SharedPtr(const SharedPtr &r)
SharedPtr< Y > dynamicCast() const
#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, (ISO C++)
#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...
virtual ~SharedPtrInfoFree()
SharedPtr()
Constructor, does not initialise the SharedPtr.
SharedPtrInfoDelete(T *o)
#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, (ISO C++)
Use OGRE_DELETE_T to free (only MEMCATEGORY_GENERAL supported)
SharedPtrInfoDeleteT(T *o)
virtual ~SharedPtrInfoDelete()
static SharedPtrInfo * createInfoForMethod(T *rep, SharedPtrFreeMethod method)