19 #ifndef LUNCHBOX_REFPTR_H 
   20 #define LUNCHBOX_REFPTR_H 
   22 #include <lunchbox/debug.h> 
   41     typedef T* 
RefPtr::*bool_t;
 
   48     RefPtr( T* 
const ptr )       : _ptr( ptr )       { _ref(); }
 
   58         : _ptr( from.
get( )) { _ref(); }
 
   66         if( _ptr == rhs._ptr )
 
   72         if( tmp ) tmp->unref( 
this );
 
   85         if( tmp ) tmp->unref( 
this );
 
   94     { 
return ( _ptr == rhs._ptr ); }
 
  101     { 
return ( _ptr != rhs._ptr ); }
 
  107     operator bool_t()
 const { 
return _ptr == 0 ? 0 : &RefPtr::_ptr; }
 
  128     bool operator == ( 
const T* ptr )
 const { 
return ( _ptr == ptr ); }
 
  134     bool operator != ( 
const T* ptr )
 const { 
return ( _ptr != ptr ); }
 
  138     { LBASSERTINFO( _ptr, 
className( 
this )); 
return _ptr; }
 
  141     { LBASSERTINFO( _ptr, 
className( 
this )); 
return _ptr; }
 
  144     { LBASSERTINFO( _ptr, 
className( 
this )); 
return *_ptr; }
 
  147     { LBASSERTINFO( _ptr, 
className( 
this )); 
return *_ptr; }
 
  150     T*       
get()                { 
return _ptr; }
 
  152     const T* 
get() 
const          { 
return _ptr; }
 
  155     bool isValid()
 const { 
return ( _ptr != 0 ); }
 
  161     void _ref()   { 
if(_ptr) _ptr->ref( 
this ); }
 
  171             if( _ptr->unref( 
this ))
 
  180 inline std::ostream& operator << ( std::ostream& os, RefPtr< T > rp )
 
  182     const T* p = rp.get();
 
  184         return os << 
"RP[ 0:NULL ]";
 
  186     os << 
disableFlush << 
"RP[" << p->getRefCount() << 
":" << *p << 
"]";
 
  187     p->printHolders( os );
 
  191 template< 
class T > 
inline std::string 
className( 
const RefPtr<T>& rp )
 
  195 #include <boost/serialization/split_free.hpp> 
  199 namespace serialization
 
  202 template< 
class Archive, 
class T >
 
  206     const T* ptr = t.
get();
 
  210 template< 
class Archive, 
class T >
 
  219 template< 
class Archive, 
class T >
 
  221                        const unsigned int version )
 
  223     boost::serialization::split_free( ar, t, version );
 
  229 #endif //LUNCHBOX_REFPTR_H 
const T * operator->() const 
Access the held object. 
 
RefPtr & operator=(const RefPtr &rhs)
Assign another RefPtr to this reference pointer. 
 
std::string className(const T *object)
Print the RTTI name of the given class. 
 
RefPtr()
Construct a new, empty reference pointer. 
 
LUNCHBOX_API std::ostream & enableFlush(std::ostream &os)
Re-enable flushing of the Log stream. 
 
bool operator==(const RefPtr &rhs) const 
 
bool operator>(const RefPtr &rhs) const 
 
T & operator*()
Access the held object. 
 
RefPtr(const RefPtr &from)
Construct a copy of a reference pointer. 
 
T * operator->()
Access the held object. 
 
~RefPtr()
Destruct this reference pointer. 
 
bool operator<(const RefPtr &rhs) const 
 
A smart reference pointer, aka boost::intrusive_ptr. 
 
RefPtr(RefPtr< O > from)
Construct a copy of a reference pointer of a different type. 
 
LUNCHBOX_API std::ostream & disableFlush(std::ostream &os)
Disable flushing of the Log stream. 
 
const T & operator*() const 
Access the held object. 
 
bool operator!=(const RefPtr &rhs) const 
 
RefPtr(T *const ptr)
Construct a reference pointer from a C pointer.