| Support Forum Library Source SourceForge Page G3D Web Page |
Use ReferenceCountedPointer<T> in place of T* in your program. More...
Public Types | |
| typedef T | element_type |
Public Member Functions | |
| ReferenceCountedPointer () | |
| template<class S > | |
| ReferenceCountedPointer (const ReferenceCountedPointer< S > &p) | |
| Allow silent cast to the base class. | |
| ReferenceCountedPointer (const ReferenceCountedPointer< T > &p) | |
| ReferenceCountedPointer (const T *p) | |
| Allows construction from a raw pointer. | |
| ~ReferenceCountedPointer () | |
| template<class S > | |
| ReferenceCountedPointer< S > | _downcast () |
| Explicit cast to a subclass. | |
| template<class S > | |
| const ReferenceCountedPointer< S > | _downcast () const |
| bool | _isNull () const |
| bool | _notNull () const |
| T * | get () const |
| size_t | hashCode () const |
| operator bool () const | |
| For compatibility with shared_ptr. | |
| bool | operator!= (const ReferenceCountedPointer< T > &y) const |
| T & | operator* () const |
| T * | operator-> () const |
| bool | operator< (const ReferenceCountedPointer< T > &y) const |
| bool | operator<= (const ReferenceCountedPointer< T > &y) const |
| const ReferenceCountedPointer < T > & | operator= (const ReferenceCountedPointer< T > &p) |
| ReferenceCountedPointer< T > & | operator= (T *p) |
| bool | operator== (const ReferenceCountedPointer< T > &y) const |
| bool | operator> (const ReferenceCountedPointer< T > &y) const |
| bool | operator>= (const ReferenceCountedPointer< T > &y) const |
| T * | pointer () const |
| template<class S > | |
| bool | pointsToA () const |
| Returns true if this is a non-NULL pointer to an object of type S. | |
| void | reset (T *p) |
| For compatibility with shared_ptr. | |
| int | unique () const |
| Returns true if this is the last reference to an object. | |
Use ReferenceCountedPointer<T> in place of T* in your program.
T must subclass ReferenceCountedObject. For convenience, most classes define a "Ref" typedef member:
class Foo : public ReferenceCountedObject { public: typedef ReferenceCountedPointer<Foo> Ref; };
| typedef T G3D::ReferenceCountedPointer< T >::element_type |
|
inline |
|
inline |
Allow silent cast to the base class.
SubRef s = new Sub(); BaseRef b = s;
i.e., compile-time subtyping rule RCP<T> <: RCP<S> if T <: S
|
inline |
|
inline |
Allows construction from a raw pointer.
That object will thereafter be reference counted – do not call delete on it.
Use of const allows downcast on const references
|
inline |
|
inline |
Explicit cast to a subclass.
Acts like dynamic cast; the result will be NULL if the cast cannot succeed. Not supported on VC6. Sub::Ref s = new Sub(); Base::Ref b = s; s = b._downcast<Sub>(); // Note that the template argument is the object type, not the pointer type.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
For compatibility with shared_ptr.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Referenced by G3D::GuiControl::MethodRefCallback< Class >::execute(), HashTrait< ReferenceCountedPointer< T > >::hashCode(), G3D::WeakReferenceCountedPointer< GuiTextureBoxInspector >::operator=(), G3D::WeakReferenceCountedPointer< GuiTextureBoxInspector >::operator>=(), G3D::ReferenceCountedPointer< class Surface2D >::ReferenceCountedPointer(), and G3D::WeakReferenceCountedPointer< GuiTextureBoxInspector >::WeakReferenceCountedPointer().
|
inline |
Returns true if this is a non-NULL pointer to an object of type S.
GuiWindow::Ref c = ...; if (c.pointsToA<CameraControlWindow>()) { ... }
|
inline |
For compatibility with shared_ptr.
|
inline |
Returns true if this is the last reference to an object.
Useful for flushing memoization caches– a cache that holds the last reference is unnecessarily keeping an object alive.
Not threadsafe.
1.8.1.2