ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::SurfacePtrHolderImpl< S > Class Template Reference

#include <SurfaceHolderImpl.h>

Collaboration diagram for Trk::SurfacePtrHolderImpl< S >:

Public Member Functions

 SurfacePtrHolderImpl ()=default
 default ctor
 SurfacePtrHolderImpl (const S &s)
 ctor from const Surface ref.
 SurfacePtrHolderImpl (const S *s)
 ctor from const Surface ptr. Takes ownership
 SurfacePtrHolderImpl (const SurfacePtrHolderImpl &other)
 copy ctor
 SurfacePtrHolderImpl (SurfacePtrHolderImpl &&other) noexcept
 Move constructor we just steal the resource and leave other to point to nullptr.
SurfacePtrHolderImploperator= (const SurfacePtrHolderImpl &other)
 copy assingmemnt if surface is free we clone/copy.
SurfacePtrHolderImploperator= (SurfacePtrHolderImpl &&other) noexcept
 Move assignement we just steal the resource and leave other to point to nullptr.
void destroySurface () noexcept
 destroySurface deletes the ptr if not null and the surface isFree Usefull also for testing
const S * surfacePtr ()
 return the ptr we hold useful for tests
const S * release () noexcept
 release ala unique_ptr release

Static Public Member Functions

static const S * cloneHelper (const S *input)
 Helper for cloning or not when we need depending on if the surface isFree.

Protected Member Functions

 ~SurfacePtrHolderImpl ()

Protected Attributes

const S * m_associatedSurface = nullptr

Detailed Description

template<typename S>
class Trk::SurfacePtrHolderImpl< S >

Definition at line 55 of file SurfaceHolderImpl.h.

Constructor & Destructor Documentation

◆ SurfacePtrHolderImpl() [1/5]

template<typename S>
Trk::SurfacePtrHolderImpl< S >::SurfacePtrHolderImpl ( )
default

default ctor

◆ SurfacePtrHolderImpl() [2/5]

template<typename S>
Trk::SurfacePtrHolderImpl< S >::SurfacePtrHolderImpl ( const S & s)
inlineexplicit

ctor from const Surface ref.

Definition at line 61 of file SurfaceHolderImpl.h.

63 {}
static const S * cloneHelper(const S *input)
Helper for cloning or not when we need depending on if the surface isFree.

◆ SurfacePtrHolderImpl() [3/5]

template<typename S>
Trk::SurfacePtrHolderImpl< S >::SurfacePtrHolderImpl ( const S * s)
inlineexplicit

ctor from const Surface ptr. Takes ownership

Definition at line 65 of file SurfaceHolderImpl.h.

67 {}

◆ SurfacePtrHolderImpl() [4/5]

template<typename S>
Trk::SurfacePtrHolderImpl< S >::SurfacePtrHolderImpl ( const SurfacePtrHolderImpl< S > & other)
inline

copy ctor

Definition at line 69 of file SurfaceHolderImpl.h.

◆ SurfacePtrHolderImpl() [5/5]

template<typename S>
Trk::SurfacePtrHolderImpl< S >::SurfacePtrHolderImpl ( SurfacePtrHolderImpl< S > && other)
inlinenoexcept

Move constructor we just steal the resource and leave other to point to nullptr.

Definition at line 74 of file SurfaceHolderImpl.h.

75 {
76 // tranfer ownership and leave other nullptr
78 other.m_associatedSurface = nullptr;
79 }

◆ ~SurfacePtrHolderImpl()

template<typename S>
Trk::SurfacePtrHolderImpl< S >::~SurfacePtrHolderImpl ( )
inlineprotected

Definition at line 133 of file SurfaceHolderImpl.h.

133{ destroySurface(); };
void destroySurface() noexcept
destroySurface deletes the ptr if not null and the surface isFree Usefull also for testing

Member Function Documentation

◆ cloneHelper()

template<typename S>
const S * Trk::SurfacePtrHolderImpl< S >::cloneHelper ( const S * input)
inlinestatic

Helper for cloning or not when we need depending on if the surface isFree.

Definition at line 124 of file SurfaceHolderImpl.h.

125 {
126 return (input && input->isFree() ? input->clone() : input);
127 }

◆ destroySurface()

template<typename S>
void Trk::SurfacePtrHolderImpl< S >::destroySurface ( )
inlinenoexcept

destroySurface deletes the ptr if not null and the surface isFree Usefull also for testing

Definition at line 105 of file SurfaceHolderImpl.h.

106 {
107 if (m_associatedSurface && m_associatedSurface->isFree()) {
108 delete m_associatedSurface;
109 }
110 //
111 m_associatedSurface = nullptr;
112 }

◆ operator=() [1/2]

template<typename S>
SurfacePtrHolderImpl & Trk::SurfacePtrHolderImpl< S >::operator= ( const SurfacePtrHolderImpl< S > & other)
inline

copy assingmemnt if surface is free we clone/copy.

If not we just point to the one owned by detector geometry

Definition at line 82 of file SurfaceHolderImpl.h.

83 {
84 if (this != &other) {
85 destroySurface(); // clean up ourselves
87 }
88 return *this;
89 }

◆ operator=() [2/2]

template<typename S>
SurfacePtrHolderImpl & Trk::SurfacePtrHolderImpl< S >::operator= ( SurfacePtrHolderImpl< S > && other)
inlinenoexcept

Move assignement we just steal the resource and leave other to point to nullptr.

Definition at line 93 of file SurfaceHolderImpl.h.

94 {
95 // destroy current surface
97 // steal payload of other and leave it to nullptr
99 other.m_associatedSurface = nullptr;
100 return *this;
101 }

◆ release()

template<typename S>
const S * Trk::SurfacePtrHolderImpl< S >::release ( )
inlinenoexcept

release ala unique_ptr release

Definition at line 116 of file SurfaceHolderImpl.h.

117 {
118 const S* tmp = m_associatedSurface;
119 m_associatedSurface = nullptr;
120 return tmp;
121 }

◆ surfacePtr()

template<typename S>
const S * Trk::SurfacePtrHolderImpl< S >::surfacePtr ( )
inline

return the ptr we hold useful for tests

Definition at line 114 of file SurfaceHolderImpl.h.

114{ return m_associatedSurface; }

Member Data Documentation

◆ m_associatedSurface

template<typename S>
const S* Trk::SurfacePtrHolderImpl< S >::m_associatedSurface = nullptr
protected

Definition at line 130 of file SurfaceHolderImpl.h.


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