HepMC event record
SmartPointer< T > Class Template Reference

Detailed Description

template<class T>
class HepMC::SmartPointer< T >

Smart pointer for HepMC objects.

Uses shared_ptr to manage the object memory

Note
SmartPointer can be created from raw pointer. This allows for implicit conversions when passing raw pointer as argument to the constructors or other functions in HepMC classes for backward compatibility. SmartPointer ensures only one shared_ptr manages the object in such conversions. Note, however, that use of such conversion is deprecated.
Requires managed class to have member field weah_ptr<T> m_this used to keep track of shared pointer created to manage the object
Examples:
basic_tree.cc, and LHEF_example_cat.cc.

Definition at line 49 of file build/outputs/include/HepMC/Data/SmartPointer.h.

#include <SmartPointer.h>

Public Member Functions

Constructors
 SmartPointer ()
 Default constructor (NULL pointer) More...
 
 SmartPointer (const SmartPointer< T > &rhs)
 Copy constructor. More...
 
 SmartPointer (const shared_ptr< T > &rhs)
 
 SmartPointer (T *raw_pointer)
 Constructor creating shared pointer from raw pointer. More...
 
 SmartPointer ()
 Default constructor (NULL pointer) More...
 
 SmartPointer (const SmartPointer< T > &rhs)
 Copy constructor. More...
 
 SmartPointer (const shared_ptr< T > &rhs)
 
 SmartPointer (T *raw_pointer)
 Constructor creating shared pointer from raw pointer. More...
 
Accessors
SmartPointeroperator= (const SmartPointer &rhs)
 Assignment. More...
 
bool operator== (const SmartPointer &rhs) const
 Equality test. More...
 
bool operator!= (const SmartPointer &rhs) const
 Inequality test. More...
 
bool operator< (const SmartPointer &rhs) const
 Less-than comparison. More...
 
const shared_ptr< T > operator-> ()
 Non-const access to the contained shared_ptr, with non-const contained type. More...
 
T & operator* ()
 Non-const dereferencing to a reference of the contained type. More...
 
const shared_ptr< const T > operator-> () const
 
const T & operator* () const
 Const dereferencing to a const reference of the contained type. More...
 
 operator bool () const
 
SmartPointeroperator= (const SmartPointer &rhs)
 Assignment. More...
 
bool operator== (const SmartPointer &rhs) const
 Equality test. More...
 
bool operator!= (const SmartPointer &rhs) const
 Inequality test. More...
 
bool operator< (const SmartPointer &rhs) const
 Less-than comparison. More...
 
const shared_ptr< T > operator-> ()
 Non-const access to the contained shared_ptr, with non-const contained type. More...
 
T & operator* ()
 Non-const dereferencing to a reference of the contained type. More...
 
const shared_ptr< const T > operator-> () const
 
const T & operator* () const
 Const dereferencing to a const reference of the contained type. More...
 
 operator bool () const
 
Deprecated functions
 operator T* ()
 
 operator bool ()
 Cast to bool. More...
 
 operator T* ()
 
 operator bool ()
 Cast to bool. More...
 

Private Attributes

Fields
shared_ptr< T > m_data
 Shared pointer. More...
 

Constructor & Destructor Documentation

◆ SmartPointer() [1/8]

Default constructor (NULL pointer)

◆ SmartPointer() [2/8]

SmartPointer ( const SmartPointer< T > &  rhs)

Copy constructor.

◆ SmartPointer() [3/8]

SmartPointer ( const shared_ptr< T > &  rhs)

Construct SmartPointer using shared pointer

Note
It's advised not to use shared_ptr<T> when using SmartPointer
This constructor should be used only in combination with make_shared<T>

◆ SmartPointer() [4/8]

SmartPointer ( T *  raw_pointer)

Constructor creating shared pointer from raw pointer.

◆ SmartPointer() [5/8]

Default constructor (NULL pointer)

◆ SmartPointer() [6/8]

SmartPointer ( const SmartPointer< T > &  rhs)

Copy constructor.

◆ SmartPointer() [7/8]

SmartPointer ( const shared_ptr< T > &  rhs)

Construct SmartPointer using shared pointer

Note
It's advised not to use shared_ptr<T> when using SmartPointer
This constructor should be used only in combination with make_shared<T>

◆ SmartPointer() [8/8]

SmartPointer ( T *  raw_pointer)

Constructor creating shared pointer from raw pointer.

Member Function Documentation

◆ operator bool() [1/4]

operator bool ( ) const
inline

Bool cast operator

Note
This should ideally use the 'safe bool idiom' in C++98 – in C++11 an implicit explicit cast / contextual conversion with the new 'explicit' keyword will be used for safety

Definition at line 103 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator bool() [2/4]

operator bool ( ) const
inline

Bool cast operator

Note
This should ideally use the 'safe bool idiom' in C++98 – in C++11 an implicit explicit cast / contextual conversion with the new 'explicit' keyword will be used for safety

Definition at line 103 of file include/HepMC/Data/SmartPointer.h.

◆ operator bool() [3/4]

operator bool ( )
inline

Cast to bool.

Definition at line 119 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator bool() [4/4]

operator bool ( )
inline

Cast to bool.

Definition at line 119 of file include/HepMC/Data/SmartPointer.h.

◆ operator T*() [1/2]

operator T* ( )
inline

Cast to raw pointer

Deprecated:
Should not be used at all

Definition at line 116 of file include/HepMC/Data/SmartPointer.h.

References SmartPointer< T >::m_data.

◆ operator T*() [2/2]

operator T* ( )
inline

Cast to raw pointer

Deprecated:
Should not be used at all

Definition at line 116 of file build/outputs/include/HepMC/Data/SmartPointer.h.

References SmartPointer< T >::m_data.

◆ operator!=() [1/2]

bool operator!= ( const SmartPointer< T > &  rhs) const
inline

Inequality test.

Definition at line 82 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator!=() [2/2]

bool operator!= ( const SmartPointer< T > &  rhs) const
inline

Inequality test.

Definition at line 82 of file include/HepMC/Data/SmartPointer.h.

◆ operator*() [1/4]

T& operator* ( )
inline

Non-const dereferencing to a reference of the contained type.

Definition at line 89 of file include/HepMC/Data/SmartPointer.h.

◆ operator*() [2/4]

T& operator* ( )
inline

Non-const dereferencing to a reference of the contained type.

Definition at line 89 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator*() [3/4]

const T& operator* ( ) const
inline

Const dereferencing to a const reference of the contained type.

Definition at line 95 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator*() [4/4]

const T& operator* ( ) const
inline

Const dereferencing to a const reference of the contained type.

Definition at line 95 of file include/HepMC/Data/SmartPointer.h.

◆ operator->() [1/4]

const shared_ptr<T> operator-> ( )
inline

Non-const access to the contained shared_ptr, with non-const contained type.

Definition at line 87 of file include/HepMC/Data/SmartPointer.h.

◆ operator->() [2/4]

const shared_ptr<T> operator-> ( )
inline

Non-const access to the contained shared_ptr, with non-const contained type.

Definition at line 87 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator->() [3/4]

const shared_ptr<const T> operator-> ( ) const
inline

Const access to the contained shared_ptr, with const contained type

Note
Hurrah for trickery!

Definition at line 93 of file include/HepMC/Data/SmartPointer.h.

◆ operator->() [4/4]

const shared_ptr<const T> operator-> ( ) const
inline

Const access to the contained shared_ptr, with const contained type

Note
Hurrah for trickery!

Definition at line 93 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator<() [1/2]

bool operator< ( const SmartPointer< T > &  rhs) const
inline

Less-than comparison.

Definition at line 84 of file include/HepMC/Data/SmartPointer.h.

◆ operator<() [2/2]

bool operator< ( const SmartPointer< T > &  rhs) const
inline

Less-than comparison.

Definition at line 84 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator=() [1/2]

SmartPointer& operator= ( const SmartPointer< T > &  rhs)
inline

Assignment.

Definition at line 77 of file include/HepMC/Data/SmartPointer.h.

◆ operator=() [2/2]

SmartPointer& operator= ( const SmartPointer< T > &  rhs)
inline

Assignment.

Definition at line 77 of file build/outputs/include/HepMC/Data/SmartPointer.h.

◆ operator==() [1/2]

bool operator== ( const SmartPointer< T > &  rhs) const
inline

Equality test.

Definition at line 80 of file include/HepMC/Data/SmartPointer.h.

◆ operator==() [2/2]

bool operator== ( const SmartPointer< T > &  rhs) const
inline

Equality test.

Definition at line 80 of file build/outputs/include/HepMC/Data/SmartPointer.h.

Field Documentation

◆ m_data

shared_ptr< T > m_data
private

Shared pointer.

Definition at line 131 of file build/outputs/include/HepMC/Data/SmartPointer.h.


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