1#ifndef DATAMODEL_DATAPTR_H
2#define DATAMODEL_DATAPTR_H
21 cout <<
typeid( *this ).name() <<
" DEBUG: "
22 <<
"default constructor called on " <<
this <<
"->" <<
ptr() <<
" use_count "
32 cout <<
typeid( *this ).name() <<
" DEBUG: "
33 <<
"pointer constructor called on " <<
this <<
"->" <<
ptr() <<
" input " << pointer
39 DataPtr(
const DataPtr& rhs ) : m_pointer( rhs.m_pointer ), p_count( rhs.p_count ) {
42 cout <<
typeid( *this ).name() <<
" DEBUG: "
43 <<
"copy constructor called on " <<
this <<
"->" <<
ptr() <<
" input " << rhs.
ptr()
51 cout <<
typeid( *this ).name() <<
" DEBUG: "
52 <<
"destructor called on " <<
this <<
"->" <<
ptr() <<
" use_count " <<
use_count()
57 assert( m_pointer == 0 );
60 else if ( *p_count == 1 )
73 operator T*()
const {
return ptr(); }
76 T*
ptr()
const {
return m_pointer; }
83 cout <<
typeid( *this ).name() <<
" DEBUG: "
84 <<
"equal operator called on " <<
this <<
"->" <<
ptr() <<
" input " << rhs.
ptr()
95 cout <<
typeid( *this ).name() <<
" DEBUG: "
96 <<
"convert equal operator called on " <<
this <<
"->" <<
ptr() <<
" input "
104 std::swap( m_pointer, rhs.m_pointer );
105 std::swap( p_count, rhs.p_count );
107 cout <<
typeid( *this ).name() <<
" DEBUG: "
108 <<
"swap called on " <<
this <<
"->" <<
ptr() <<
" input " << rhs.
ptr()
117 cout <<
typeid( *this ).name() <<
" DEBUG: "
118 <<
"reset called on " <<
this <<
"->" <<
ptr() <<
" use_count " <<
use_count()
137 return ( lhs.
ptr() == rhs.
ptr() );
145 return !( lhs == rhs );
bool operator==(const DataPtr< T > &lhs, const DataPtr< T > &rhs)
bool operator!=(const DataPtr< T > &lhs, const DataPtr< T > &rhs)
T DataPtr_type
A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.
long use_count() const
returns number of objects using the shared_ptr. Slow!
DataPtr & operator=(const DataPtr &rhs)
assignment operator, protect against self-assignment and exceptions
DataPtr(const DataPtr &rhs)
copy contructor: makes a copy of the pointer in rhs and of its count ptr
void reset()
reset contents
unsigned short counter_type
DataPtr()
default constructor
T * ptr() const
explicit pointer accessors (sometimes necessary to help the compiler)
DataPtr & operator=(const DataPtr< U > &rhs)
assignment from a Convertible DataPtr
~DataPtr()
the destructor will delete the object pointed to
void swap(DataPtr &rhs)
swap contents
T & operator*() const
dereference operators: