BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DataPtr< T > Class Template Reference

#include <DataPtr.h>

Public Types

typedef T DataPtr_type
 A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.
typedef unsigned short counter_type
typedef T DataPtr_type
 A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.
typedef unsigned short counter_type
typedef T DataPtr_type
 A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.
typedef unsigned short counter_type

Public Member Functions

 DataPtr ()
 default constructor
template<typename Y>
 DataPtr (Y *pointer)
 DataPtr (const DataPtr &rhs)
 copy contructor: makes a copy of the pointer in rhs and of its count ptr
 ~DataPtr ()
 the destructor will delete the object pointed to
T & operator* () const
 dereference operators:
T * operator-> () const
 operator T* () const
T * ptr () const
 explicit pointer accessors (sometimes necessary to help the compiler)
DataPtroperator= (const DataPtr &rhs)
 assignment operator, protect against self-assignment and exceptions
template<typename U>
DataPtroperator= (const DataPtr< U > &rhs)
 assignment from a Convertible DataPtr
void swap (DataPtr &rhs)
 swap contents
void reset ()
 reset contents
long use_count () const
 returns number of objects using the shared_ptr. Slow!
 DataPtr ()
 default constructor
template<typename Y>
 DataPtr (Y *pointer)
 DataPtr (const DataPtr &rhs)
 copy contructor: makes a copy of the pointer in rhs and of its count ptr
 ~DataPtr ()
 the destructor will delete the object pointed to
T & operator* () const
 dereference operators:
T * operator-> () const
 operator T* () const
T * ptr () const
 explicit pointer accessors (sometimes necessary to help the compiler)
DataPtroperator= (const DataPtr &rhs)
 assignment operator, protect against self-assignment and exceptions
template<typename U>
DataPtroperator= (const DataPtr< U > &rhs)
 assignment from a Convertible DataPtr
void swap (DataPtr &rhs)
 swap contents
void reset ()
 reset contents
long use_count () const
 returns number of objects using the shared_ptr. Slow!
 DataPtr ()
 default constructor
template<typename Y>
 DataPtr (Y *pointer)
 DataPtr (const DataPtr &rhs)
 copy contructor: makes a copy of the pointer in rhs and of its count ptr
 ~DataPtr ()
 the destructor will delete the object pointed to
T & operator* () const
 dereference operators:
T * operator-> () const
 operator T* () const
T * ptr () const
 explicit pointer accessors (sometimes necessary to help the compiler)
DataPtroperator= (const DataPtr &rhs)
 assignment operator, protect against self-assignment and exceptions
template<typename U>
DataPtroperator= (const DataPtr< U > &rhs)
 assignment from a Convertible DataPtr
void swap (DataPtr &rhs)
 swap contents
void reset ()
 reset contents
long use_count () const
 returns number of objects using the shared_ptr. Slow!

Detailed Description

template<typename T>
class DataPtr< T >

Definition at line 12 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

Member Typedef Documentation

◆ counter_type [1/3]

template<typename T>
typedef unsigned short DataPtr< T >::counter_type

◆ counter_type [2/3]

template<typename T>
typedef unsigned short DataPtr< T >::counter_type

◆ counter_type [3/3]

template<typename T>
typedef unsigned short DataPtr< T >::counter_type

◆ DataPtr_type [1/3]

template<typename T>
typedef T DataPtr< T >::DataPtr_type

A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.

Definition at line 15 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

◆ DataPtr_type [2/3]

template<typename T>
typedef T DataPtr< T >::DataPtr_type

A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.

Definition at line 15 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

◆ DataPtr_type [3/3]

template<typename T>
typedef T DataPtr< T >::DataPtr_type

A wrapper around boost shared_ptr. Adds automatic conversion to/from T*.

Definition at line 15 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

Constructor & Destructor Documentation

◆ DataPtr() [1/9]

template<typename T>
DataPtr< T >::DataPtr ( )
inline

default constructor

Definition at line 19 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

19 : m_pointer( 0 ), p_count( new counter_type( 0 ) ) {
20#ifdef DATAPTR_DEBUG
21 cout << typeid( *this ).name() << " DEBUG: "
22 << "default constructor called on " << this << "->" << ptr() << " use_count "
23 << use_count() << endl;
24#endif
25 }
long use_count() const
returns number of objects using the shared_ptr. Slow!
T * ptr() const
explicit pointer accessors (sometimes necessary to help the compiler)

◆ DataPtr() [2/9]

template<typename T>
template<typename Y>
DataPtr< T >::DataPtr ( Y * pointer)
inline

constructor from ptr: stores a copy of pointer Y must be convertible to a T*

Definition at line 30 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

30 : m_pointer( pointer ), p_count( new counter_type( 1 ) ) {
31#ifdef DATAPTR_DEBUG
32 cout << typeid( *this ).name() << " DEBUG: "
33 << "pointer constructor called on " << this << "->" << ptr() << " input " << pointer
34 << " use_count " << use_count() << endl;
35#endif
36 }

◆ DataPtr() [3/9]

template<typename T>
DataPtr< T >::DataPtr ( const DataPtr< T > & rhs)
inline

copy contructor: makes a copy of the pointer in rhs and of its count ptr

Definition at line 39 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

39 : m_pointer( rhs.m_pointer ), p_count( rhs.p_count ) {
40 ++( *p_count );
41#ifdef DATAPTR_DEBUG
42 cout << typeid( *this ).name() << " DEBUG: "
43 << "copy constructor called on " << this << "->" << ptr() << " input " << rhs.ptr()
44 << " use_count " << use_count() << endl;
45#endif
46 }

◆ ~DataPtr() [1/3]

template<typename T>
DataPtr< T >::~DataPtr ( )
inline

the destructor will delete the object pointed to

Definition at line 49 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

49 {
50#ifdef DATAPTR_DEBUG
51 cout << typeid( *this ).name() << " DEBUG: "
52 << "destructor called on " << this << "->" << ptr() << " use_count " << use_count()
53 << endl;
54#endif
55 if ( *p_count == 0 )
56 {
57 assert( m_pointer == 0 );
58 delete p_count;
59 }
60 else if ( *p_count == 1 )
61 {
62 delete p_count;
63 delete m_pointer;
64 }
65 else --( *p_count );
66 }

◆ DataPtr() [4/9]

template<typename T>
DataPtr< T >::DataPtr ( )
inline

default constructor

Definition at line 19 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

19 : m_pointer( 0 ), p_count( new counter_type( 0 ) ) {
20#ifdef DATAPTR_DEBUG
21 cout << typeid( *this ).name() << " DEBUG: "
22 << "default constructor called on " << this << "->" << ptr() << " use_count "
23 << use_count() << endl;
24#endif
25 }

◆ DataPtr() [5/9]

template<typename T>
template<typename Y>
DataPtr< T >::DataPtr ( Y * pointer)
inline

constructor from ptr: stores a copy of pointer Y must be convertible to a T*

Definition at line 30 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

30 : m_pointer( pointer ), p_count( new counter_type( 1 ) ) {
31#ifdef DATAPTR_DEBUG
32 cout << typeid( *this ).name() << " DEBUG: "
33 << "pointer constructor called on " << this << "->" << ptr() << " input " << pointer
34 << " use_count " << use_count() << endl;
35#endif
36 }

◆ DataPtr() [6/9]

template<typename T>
DataPtr< T >::DataPtr ( const DataPtr< T > & rhs)
inline

copy contructor: makes a copy of the pointer in rhs and of its count ptr

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

39 : m_pointer( rhs.m_pointer ), p_count( rhs.p_count ) {
40 ++( *p_count );
41#ifdef DATAPTR_DEBUG
42 cout << typeid( *this ).name() << " DEBUG: "
43 << "copy constructor called on " << this << "->" << ptr() << " input " << rhs.ptr()
44 << " use_count " << use_count() << endl;
45#endif
46 }

◆ ~DataPtr() [2/3]

template<typename T>
DataPtr< T >::~DataPtr ( )
inline

the destructor will delete the object pointed to

Definition at line 49 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

49 {
50#ifdef DATAPTR_DEBUG
51 cout << typeid( *this ).name() << " DEBUG: "
52 << "destructor called on " << this << "->" << ptr() << " use_count " << use_count()
53 << endl;
54#endif
55 if ( *p_count == 0 )
56 {
57 assert( m_pointer == 0 );
58 delete p_count;
59 }
60 else if ( *p_count == 1 )
61 {
62 delete p_count;
63 delete m_pointer;
64 }
65 else --( *p_count );
66 }

◆ DataPtr() [7/9]

template<typename T>
DataPtr< T >::DataPtr ( )
inline

default constructor

Definition at line 19 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

19 : m_pointer( 0 ), p_count( new counter_type( 0 ) ) {
20#ifdef DATAPTR_DEBUG
21 cout << typeid( *this ).name() << " DEBUG: "
22 << "default constructor called on " << this << "->" << ptr() << " use_count "
23 << use_count() << endl;
24#endif
25 }

◆ DataPtr() [8/9]

template<typename T>
template<typename Y>
DataPtr< T >::DataPtr ( Y * pointer)
inline

constructor from ptr: stores a copy of pointer Y must be convertible to a T*

Definition at line 30 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

30 : m_pointer( pointer ), p_count( new counter_type( 1 ) ) {
31#ifdef DATAPTR_DEBUG
32 cout << typeid( *this ).name() << " DEBUG: "
33 << "pointer constructor called on " << this << "->" << ptr() << " input " << pointer
34 << " use_count " << use_count() << endl;
35#endif
36 }

◆ DataPtr() [9/9]

template<typename T>
DataPtr< T >::DataPtr ( const DataPtr< T > & rhs)
inline

copy contructor: makes a copy of the pointer in rhs and of its count ptr

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

39 : m_pointer( rhs.m_pointer ), p_count( rhs.p_count ) {
40 ++( *p_count );
41#ifdef DATAPTR_DEBUG
42 cout << typeid( *this ).name() << " DEBUG: "
43 << "copy constructor called on " << this << "->" << ptr() << " input " << rhs.ptr()
44 << " use_count " << use_count() << endl;
45#endif
46 }

◆ ~DataPtr() [3/3]

template<typename T>
DataPtr< T >::~DataPtr ( )
inline

the destructor will delete the object pointed to

Definition at line 49 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

49 {
50#ifdef DATAPTR_DEBUG
51 cout << typeid( *this ).name() << " DEBUG: "
52 << "destructor called on " << this << "->" << ptr() << " use_count " << use_count()
53 << endl;
54#endif
55 if ( *p_count == 0 )
56 {
57 assert( m_pointer == 0 );
58 delete p_count;
59 }
60 else if ( *p_count == 1 )
61 {
62 delete p_count;
63 delete m_pointer;
64 }
65 else --( *p_count );
66 }

Member Function Documentation

◆ operator T*() [1/3]

template<typename T>
DataPtr< T >::operator T* ( ) const
inline

Definition at line 73 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

73{ return ptr(); }

◆ operator T*() [2/3]

template<typename T>
DataPtr< T >::operator T* ( ) const
inline

Definition at line 73 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

73{ return ptr(); }

◆ operator T*() [3/3]

template<typename T>
DataPtr< T >::operator T* ( ) const
inline

Definition at line 73 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

73{ return ptr(); }

◆ operator*() [1/3]

template<typename T>
T & DataPtr< T >::operator* ( ) const
inline

dereference operators:

Definition at line 69 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

69{ return *ptr(); }

◆ operator*() [2/3]

template<typename T>
T & DataPtr< T >::operator* ( ) const
inline

dereference operators:

Definition at line 69 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

69{ return *ptr(); }

◆ operator*() [3/3]

template<typename T>
T & DataPtr< T >::operator* ( ) const
inline

dereference operators:

Definition at line 69 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

69{ return *ptr(); }

◆ operator->() [1/3]

template<typename T>
T * DataPtr< T >::operator-> ( ) const
inline

Definition at line 70 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

70{ return ptr(); }

◆ operator->() [2/3]

template<typename T>
T * DataPtr< T >::operator-> ( ) const
inline

Definition at line 70 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

70{ return ptr(); }

◆ operator->() [3/3]

template<typename T>
T * DataPtr< T >::operator-> ( ) const
inline

Definition at line 70 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

70{ return ptr(); }

◆ operator=() [1/6]

template<typename T>
DataPtr & DataPtr< T >::operator= ( const DataPtr< T > & rhs)
inline

assignment operator, protect against self-assignment and exceptions

Definition at line 79 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

79 {
81 swap( temp );
82#ifdef DATAPTR_DEBUG
83 cout << typeid( *this ).name() << " DEBUG: "
84 << "equal operator called on " << this << "->" << ptr() << " input " << rhs.ptr()
85 << " use_count " << use_count() << endl;
86#endif
87 return *this;
88 }
void swap(DataPtr &rhs)
swap contents

◆ operator=() [2/6]

template<typename T>
DataPtr & DataPtr< T >::operator= ( const DataPtr< T > & rhs)
inline

assignment operator, protect against self-assignment and exceptions

Definition at line 79 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

79 {
81 swap( temp );
82#ifdef DATAPTR_DEBUG
83 cout << typeid( *this ).name() << " DEBUG: "
84 << "equal operator called on " << this << "->" << ptr() << " input " << rhs.ptr()
85 << " use_count " << use_count() << endl;
86#endif
87 return *this;
88 }

◆ operator=() [3/6]

template<typename T>
DataPtr & DataPtr< T >::operator= ( const DataPtr< T > & rhs)
inline

assignment operator, protect against self-assignment and exceptions

Definition at line 79 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

79 {
81 swap( temp );
82#ifdef DATAPTR_DEBUG
83 cout << typeid( *this ).name() << " DEBUG: "
84 << "equal operator called on " << this << "->" << ptr() << " input " << rhs.ptr()
85 << " use_count " << use_count() << endl;
86#endif
87 return *this;
88 }

◆ operator=() [4/6]

template<typename T>
template<typename U>
DataPtr & DataPtr< T >::operator= ( const DataPtr< U > & rhs)
inline

assignment from a Convertible DataPtr

Definition at line 91 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

91 {
93 swap( temp );
94#ifdef DATAPTR_DEBUG
95 cout << typeid( *this ).name() << " DEBUG: "
96 << "convert equal operator called on " << this << "->" << ptr() << " input "
97 << rhs.ptr() << " use_count " << use_count() << endl;
98#endif
99 return *this;
100 }

◆ operator=() [5/6]

template<typename T>
template<typename U>
DataPtr & DataPtr< T >::operator= ( const DataPtr< U > & rhs)
inline

assignment from a Convertible DataPtr

Definition at line 91 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

91 {
93 swap( temp );
94#ifdef DATAPTR_DEBUG
95 cout << typeid( *this ).name() << " DEBUG: "
96 << "convert equal operator called on " << this << "->" << ptr() << " input "
97 << rhs.ptr() << " use_count " << use_count() << endl;
98#endif
99 return *this;
100 }

◆ operator=() [6/6]

template<typename T>
template<typename U>
DataPtr & DataPtr< T >::operator= ( const DataPtr< U > & rhs)
inline

assignment from a Convertible DataPtr

Definition at line 91 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

91 {
93 swap( temp );
94#ifdef DATAPTR_DEBUG
95 cout << typeid( *this ).name() << " DEBUG: "
96 << "convert equal operator called on " << this << "->" << ptr() << " input "
97 << rhs.ptr() << " use_count " << use_count() << endl;
98#endif
99 return *this;
100 }

◆ ptr() [1/3]

◆ ptr() [2/3]

template<typename T>
T * DataPtr< T >::ptr ( ) const
inline

explicit pointer accessors (sometimes necessary to help the compiler)

Definition at line 76 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

76{ return m_pointer; }

◆ ptr() [3/3]

template<typename T>
T * DataPtr< T >::ptr ( ) const
inline

explicit pointer accessors (sometimes necessary to help the compiler)

Definition at line 76 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

76{ return m_pointer; }

◆ reset() [1/3]

template<typename T>
void DataPtr< T >::reset ( )
inline

reset contents

Definition at line 114 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

114 {
115 swap( DataPtr<T>(), this );
116#ifdef DATAPTR_DEBUG
117 cout << typeid( *this ).name() << " DEBUG: "
118 << "reset called on " << this << "->" << ptr() << " use_count " << use_count()
119 << endl;
120#endif
121 }

◆ reset() [2/3]

template<typename T>
void DataPtr< T >::reset ( )
inline

reset contents

Definition at line 114 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

114 {
115 swap( DataPtr<T>(), this );
116#ifdef DATAPTR_DEBUG
117 cout << typeid( *this ).name() << " DEBUG: "
118 << "reset called on " << this << "->" << ptr() << " use_count " << use_count()
119 << endl;
120#endif
121 }

◆ reset() [3/3]

template<typename T>
void DataPtr< T >::reset ( )
inline

reset contents

Definition at line 114 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

114 {
115 swap( DataPtr<T>(), this );
116#ifdef DATAPTR_DEBUG
117 cout << typeid( *this ).name() << " DEBUG: "
118 << "reset called on " << this << "->" << ptr() << " use_count " << use_count()
119 << endl;
120#endif
121 }

◆ swap() [1/3]

template<typename T>
void DataPtr< T >::swap ( DataPtr< T > & rhs)
inline

swap contents

Definition at line 103 of file Event/GeneratorObject/include/DataModel/DataPtr.h.

103 {
104 std::swap( m_pointer, rhs.m_pointer );
105 std::swap( p_count, rhs.p_count );
106#ifdef DATAPTR_DEBUG
107 cout << typeid( *this ).name() << " DEBUG: "
108 << "swap called on " << this << "->" << ptr() << " input " << rhs.ptr()
109 << " use_count " << use_count() << endl;
110#endif
111 }

Referenced by DataPtr_type *< T >::operator=(), DataPtr_type *< T >::operator=(), and DataPtr_type *< T >::reset().

◆ swap() [2/3]

template<typename T>
void DataPtr< T >::swap ( DataPtr< T > & rhs)
inline

swap contents

Definition at line 103 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

103 {
104 std::swap( m_pointer, rhs.m_pointer );
105 std::swap( p_count, rhs.p_count );
106#ifdef DATAPTR_DEBUG
107 cout << typeid( *this ).name() << " DEBUG: "
108 << "swap called on " << this << "->" << ptr() << " input " << rhs.ptr()
109 << " use_count " << use_count() << endl;
110#endif
111 }

◆ swap() [3/3]

template<typename T>
void DataPtr< T >::swap ( DataPtr< T > & rhs)
inline

swap contents

Definition at line 103 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

103 {
104 std::swap( m_pointer, rhs.m_pointer );
105 std::swap( p_count, rhs.p_count );
106#ifdef DATAPTR_DEBUG
107 cout << typeid( *this ).name() << " DEBUG: "
108 << "swap called on " << this << "->" << ptr() << " input " << rhs.ptr()
109 << " use_count " << use_count() << endl;
110#endif
111 }

◆ use_count() [1/3]

template<typename T>
long DataPtr< T >::use_count ( ) const
inline

◆ use_count() [2/3]

template<typename T>
long DataPtr< T >::use_count ( ) const
inline

returns number of objects using the shared_ptr. Slow!

Definition at line 124 of file InstallArea/x86_64-el9-gcc13-dbg/include/DataModel/DataPtr.h.

124 {
125 assert( p_count );
126 return *p_count;
127 }

◆ use_count() [3/3]

template<typename T>
long DataPtr< T >::use_count ( ) const
inline

returns number of objects using the shared_ptr. Slow!

Definition at line 124 of file InstallArea/x86_64-el9-gcc13-opt/include/DataModel/DataPtr.h.

124 {
125 assert( p_count );
126 return *p_count;
127 }

The documentation for this class was generated from the following files: