DynObjPtr< T > Struct Template Reference
[Templates for DynI and friends]

#include <DynObjPtr.hpp>

Inheritance diagram for DynObjPtr< T >:

ScopedDynObj< T >

List of all members.

Public Types

enum  { isStatic = 1, hasDoRef = 2, hasWeakRef = 4, hasStrongRef = 8 }

Public Member Functions

 DynObjPtr ()
 DynObjPtr (T *pt, bool try_strong_ref=false)
 DynObjPtr (DynObjPtr &dop)
DynObjPtroperator= (T *pt)
DynObjPtroperator= (DynObjPtr< T > &dop)
DynObjPtrAssign (T *pt, bool try_strong_ref=false)
 operator T * ()
 operator T & ()
T & operator* ()
T * operator-> ()
T * Get ()
bool HasStrongRef ()
bool IsOk ()
bool Release ()

Protected Member Functions

bool InternalAssign (T *pt, int try_strong_ref)
void InternalRelease ()
virtual bool docall OnNotify (NotifierI *pni, int evt, NotifDataI *pnd)

Protected Attributes

char m_flags
bool m_flag_unused2
bool m_flag_unused1
bool m_flag_unused
T * m_pt
union {
   NotifierI *   m_pni
   DynObj *   m_pdo
}; 


Detailed Description

template<class T>
struct DynObjPtr< T >

This is a smart DynObj pointer class. It relies on the held object being trackable in one or two of these ways: 1 - It implements NotifierI (giving off notfications in its dtor) 2 - It is a safely trackable DynObj (requires DoRunTime) 3 - It is a ref counted object and we hold a ref 4 - It is a static object from the main module and can be safely held. Even for case 3 (ref counting) we _still_ track object lifetime (using 1 or 2) in addition to pure ref counting. This allow for keeping our pointers safe even when a module is unloaded prematurely.

So, if all objects instantiated from a plugin are held with a DynObjPtr, that plugin can be safely unloaded (with regards to valid pointers).


Constructor & Destructor Documentation

template<class T>
DynObjPtr< T >::DynObjPtr (  )  [inline]

No argument constructor.

template<class T>
DynObjPtr< T >::DynObjPtr ( T *  pt,
bool  try_strong_ref = false 
) [inline, explicit]

Two argument constructor.

Parameters:
pt The DynObj we want to own. Should implement RefCountI.
do_add_ref If we should add a reference or not (default value: false).

template<class T>
DynObjPtr< T >::DynObjPtr ( DynObjPtr< T > &  dop  )  [inline, explicit]

One argument constructor.


Member Function Documentation

template<class T>
DynObjPtr& DynObjPtr< T >::operator= ( T *  pt  )  [inline]

Assignment operator.

Parameters:
pt The DynObj we want to own.

template<class T>
DynObjPtr& DynObjPtr< T >::operator= ( DynObjPtr< T > &  dop  )  [inline]

Assignment operator.

Parameters:
dop The DynObj we want to own.

template<class T>
DynObjPtr& DynObjPtr< T >::Assign ( T *  pt,
bool  try_strong_ref = false 
) [inline]

Assignment operator.

Parameters:
pt The DynObj we want to own.
try_strong_ref Attempt to create a shared ref on the object? (default: false).

template<class T>
DynObjPtr< T >::operator T * (  )  [inline]

Access raw pointer.

template<class T>
DynObjPtr< T >::operator T & (  )  [inline]

Access as a reference.

template<class T>
T& DynObjPtr< T >::operator* (  )  [inline]

Access as a reference.

template<class T>
T* DynObjPtr< T >::operator-> (  )  [inline]

Access raw pointer.

template<class T>
T* DynObjPtr< T >::Get (  )  [inline]

Access raw pointer.

template<class T>
bool DynObjPtr< T >::HasStrongRef (  )  [inline]

Returns true if we have a ref on a shared object

template<class T>
bool DynObjPtr< T >::IsOk (  )  [inline]

Do we have an object now?

Reimplemented in ScopedDynObj< T >.

template<class T>
bool DynObjPtr< T >::Release (  )  [inline]

Release our object in the suitable way


The documentation for this struct was generated from the following file:

Generated on Sun Feb 15 16:35:57 2009 for DynObj by  doxygen 1.5.6