19 #ifndef LUNCHBOX_REFPTR_H 20 #define LUNCHBOX_REFPTR_H 22 #include <lunchbox/debug.h> 42 typedef T*
RefPtr::*bool_t;
127 operator bool_t()
const {
return _ptr == 0 ? 0 : &RefPtr::_ptr; }
144 bool operator==(
const T* ptr)
const {
return (_ptr == ptr); }
149 bool operator!=(
const T* ptr)
const {
return (_ptr != ptr); }
176 T*
get() {
return _ptr; }
178 const T*
get()
const {
return _ptr; }
199 if (_ptr->unref(
this))
208 inline std::ostream& operator<<(std::ostream& os, RefPtr<T> rp)
210 const T* p = rp.get();
212 return os <<
"RP[ 0:NULL ]";
214 os <<
disableFlush <<
"RP[" << p->getRefCount() <<
":" << *p <<
"]";
226 #include <boost/serialization/split_free.hpp> 230 namespace serialization
232 template <
class Archive,
class T>
236 const T* ptr = t.
get();
240 template <
class Archive,
class T>
249 template <
class Archive,
class T>
251 const unsigned int version)
253 boost::serialization::split_free(ar, t, version);
258 #endif // LUNCHBOX_REFPTR_H std::ostream & enableFlush(std::ostream &os)
Re-enable flushing of the Log stream.
std::string className(const T &object)
Print the RTTI name of the given class.
const T * operator->() const
Access the held object.
RefPtr & operator=(const RefPtr &rhs)
Assign another RefPtr to this reference pointer.
RefPtr()
Construct a new, empty reference pointer.
bool operator==(const RefPtr &rhs) const
bool operator>(const RefPtr &rhs) const
T & operator*()
Access the held object.
bool operator==(const T *ptr) const
RefPtr(const RefPtr &from)
Construct a copy of a reference pointer.
T * operator->()
Access the held object.
~RefPtr()
Destruct this reference pointer.
Abstraction layer and common utilities for multi-threaded programming.
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.
bool operator!=(const T *ptr) const
const T & operator*() const
Access the held object.
bool operator!=(const RefPtr &rhs) const
RefPtr & operator=(T *ptr)
Assign a C pointer to this reference pointer.
RefPtr(T *const ptr)
Construct a reference pointer from a C pointer.
std::ostream & disableFlush(std::ostream &os)
Disable flushing of the Log stream.