pointer with built-in initialization, deletion, deep copying More...
#include <ShadowPtr.h>
Inherited by utl::InitializedShadowPtr< ns1::Foo >, utl::InitializedShadowPtr< utl::FFTDataContainer >, utl::InitializedShadowPtr< utl::MultiTabulatedFunctionErrors >, utl::InitializedShadowPtr< utl::MultiTimeDistributionD >, utl::InitializedShadowPtr< utl::MultiTimeDistributionI >, utl::InitializedShadowPtr< utl::MultiTraceD >, utl::InitializedShadowPtr< utl::MultiTraceI >, utl::InitializedShadowPtr< utl::TraceV3D >, and utl::InitializedShadowPtr< T, DereferenceCheck >.
Public Member Functions | |
T * | Get () |
const T * | Get () const |
operator bool () const | |
bool | operator!= (const ShadowPtr &sp) const |
bool | operator!= (const T *const p) const |
T & | operator* () |
const T & | operator* () const |
T * | operator-> () |
const T * | operator-> () const |
ShadowPtr & | operator= (const ShadowPtr &sp) |
ShadowPtr & | operator= (ShadowPtr &&sp) |
ShadowPtr & | operator= (T *const p) |
shallow assignment: transfer ownership More... | |
bool | operator== (const ShadowPtr &sp) const |
bool | operator== (const T *const p) const |
ShadowPtr () | |
ShadowPtr (T *const p) | |
ShadowPtr (const ShadowPtr &sp) | |
ShadowPtr (ShadowPtr &&sp) noexcept | |
void | Swap (ShadowPtr &sp) |
~ShadowPtr () noexcept | |
Protected Member Functions | |
void | DeepCopy (const T *const p) |
Protected Attributes | |
T * | fPtr = nullptr |
Private Member Functions | |
void | Delete () noexcept |
pointer with built-in initialization, deletion, deep copying
This class should behave exactly as a simple pointer to a phantom class T except in this cases: -> empty ctor initializes it to nullptr -> dtor deletes phantom -> operator= deletes current phantom and makes a deep copy of the phantom argument
Motivation: In Offline the event hierarchy (evt::Event) has a simple tree-like structure with data leaves and optional branches containing additional substructures (e.g. starting at the top, evt::Event contains header data evt::Header and several branches (sevt::SEvent, fevt::FEvent etc.)). In general an event may not contain all the branches. For instance, a pure SD event will not contain any of the FD parts. That is why in the parent class the branches are implemented as pointers to the child classes, (should be) initialized to zero if the specific part of the event is missing. Although this is the best of the possible solutions, having pointers in the body of the parent class introduces several drawbacks:
operator=
(and move ctor and op=) have to be coded by handSet/Get
methods)To remedy this highly unmanageable code bloat a templated ShadowPtr class is wrapped around the bare C++ pointers. The InitializedShadowPtr variant also initializes the pointer with new
copy of the object by calling the default constructor. Ensuring that the Offline classes contain only data members and shadow pointers there is no need to write default constructors, copy constructors, and operator=
. In this way we get rid of a lot of highly unmaintainable and error-prone code that repeats itself only with slight variations in all of the Offline classes. Based on the template definition of the ShadowPtr the compiler will (usually more correctly) generate it for free.
Definition at line 163 of file ShadowPtr.h.
|
inline |
Definition at line 166 of file ShadowPtr.h.
|
inlineexplicit |
Definition at line 169 of file ShadowPtr.h.
|
inline |
Definition at line 172 of file ShadowPtr.h.
|
inlinenoexcept |
Definition at line 174 of file ShadowPtr.h.
|
inlinenoexcept |
Definition at line 176 of file ShadowPtr.h.
|
inlineprotected |
Definition at line 223 of file ShadowPtr.h.
Referenced by utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator=(), and utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::ShadowPtr().
|
inlineprivatenoexcept |
Definition at line 220 of file ShadowPtr.h.
Referenced by utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator=(), and utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::~ShadowPtr().
|
inline |
Definition at line 201 of file ShadowPtr.h.
Referenced by atm::MeasuredDBMieModel::ToggleVAODPtr().
|
inline |
Definition at line 202 of file ShadowPtr.h.
|
inlineexplicit |
Definition at line 215 of file ShadowPtr.h.
|
inline |
Definition at line 211 of file ShadowPtr.h.
|
inline |
Definition at line 213 of file ShadowPtr.h.
|
inline |
Definition at line 204 of file ShadowPtr.h.
|
inline |
Definition at line 205 of file ShadowPtr.h.
|
inline |
Definition at line 207 of file ShadowPtr.h.
|
inline |
Definition at line 208 of file ShadowPtr.h.
|
inline |
Definition at line 180 of file ShadowPtr.h.
|
inline |
Definition at line 190 of file ShadowPtr.h.
|
inline |
shallow assignment: transfer ownership
Definition at line 199 of file ShadowPtr.h.
|
inline |
Definition at line 210 of file ShadowPtr.h.
|
inline |
Definition at line 212 of file ShadowPtr.h.
|
inline |
Definition at line 217 of file ShadowPtr.h.
Referenced by utl::swap().
|
protected |
Definition at line 225 of file ShadowPtr.h.
Referenced by utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::DeepCopy(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::Delete(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::Get(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator bool(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator!=(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator*(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator->(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator=(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::operator==(), utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::ShadowPtr(), and utl::ShadowPtr< evt::evt::VGaisserHillasParameter >::Swap().