CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
CaloCellGeometryMayOwnPtr Class Reference

#include "Geometry/CaloGeometry/interface/CaloCellGeometryMayOwnPtr.h"

Classes

struct  no_delete
 

Public Member Functions

 CaloCellGeometryMayOwnPtr (std::unique_ptr< CaloCellGeometry const > iPtr) noexcept
 
 CaloCellGeometryMayOwnPtr (CaloCellGeometryPtr const &iPtr) noexcept
 
 CaloCellGeometryMayOwnPtr () noexcept=default
 
 CaloCellGeometryMayOwnPtr (const CaloCellGeometryMayOwnPtr &iPtr) noexcept
 
 CaloCellGeometryMayOwnPtr (CaloCellGeometryMayOwnPtr &&iPtr) noexcept
 
CaloCellGeometry const * get () const
 
 operator CaloCellGeometry const * () const
 
CaloCellGeometry const & operator* () const
 
CaloCellGeometry const * operator-> () const
 
CaloCellGeometryMayOwnPtroperator= (CaloCellGeometryMayOwnPtr const &iPtr) noexcept
 
CaloCellGeometryMayOwnPtroperator= (CaloCellGeometryMayOwnPtr &&iPtr) noexcept
 
 ~CaloCellGeometryMayOwnPtr () noexcept
 

Private Attributes

bool own_ = false
 
const CaloCellGeometryptr_ = nullptr
 

Detailed Description

Description: Type to hold pointer to CaloCellGeometry with possible ownership

Usage: Used to either have single ownership or no ownership of the CaloCellGeometry

Definition at line 30 of file CaloCellGeometryMayOwnPtr.h.

Constructor & Destructor Documentation

◆ CaloCellGeometryMayOwnPtr() [1/5]

CaloCellGeometryMayOwnPtr::CaloCellGeometryMayOwnPtr ( std::unique_ptr< CaloCellGeometry const >  iPtr)
inlineexplicitnoexcept

Definition at line 32 of file CaloCellGeometryMayOwnPtr.h.

33  : ptr_{iPtr.release()}, own_{ptr_ != nullptr} {
34  if (own_) {
35  ptr_->increment();
36  }
37  }
const CaloCellGeometry * ptr_
void increment() const

◆ CaloCellGeometryMayOwnPtr() [2/5]

CaloCellGeometryMayOwnPtr::CaloCellGeometryMayOwnPtr ( CaloCellGeometryPtr const &  iPtr)
inlineexplicitnoexcept

Definition at line 38 of file CaloCellGeometryMayOwnPtr.h.

38 : ptr_{iPtr.get()}, own_{false} {}
const CaloCellGeometry * ptr_

◆ ~CaloCellGeometryMayOwnPtr()

CaloCellGeometryMayOwnPtr::~CaloCellGeometryMayOwnPtr ( )
inlinenoexcept

Definition at line 40 of file CaloCellGeometryMayOwnPtr.h.

References CaloCellGeometry::decrement(), own_, and ptr_.

40  {
41  if (own_ and ptr_->decrement()) {
42  delete ptr_;
43  }
44  }
const CaloCellGeometry * ptr_
bool decrement() const

◆ CaloCellGeometryMayOwnPtr() [3/5]

CaloCellGeometryMayOwnPtr::CaloCellGeometryMayOwnPtr ( )
defaultnoexcept

◆ CaloCellGeometryMayOwnPtr() [4/5]

CaloCellGeometryMayOwnPtr::CaloCellGeometryMayOwnPtr ( const CaloCellGeometryMayOwnPtr iPtr)
inlinenoexcept

Definition at line 46 of file CaloCellGeometryMayOwnPtr.h.

46  : ptr_{iPtr.ptr_}, own_{iPtr.own_} {
47  if (own_) {
48  ptr_->increment();
49  }
50  }
const CaloCellGeometry * ptr_
void increment() const

◆ CaloCellGeometryMayOwnPtr() [5/5]

CaloCellGeometryMayOwnPtr::CaloCellGeometryMayOwnPtr ( CaloCellGeometryMayOwnPtr &&  iPtr)
inlinenoexcept

Definition at line 51 of file CaloCellGeometryMayOwnPtr.h.

51  : ptr_{iPtr.ptr_}, own_{iPtr.own_} {
52  iPtr.ptr_ = nullptr;
53  iPtr.own_ = false;
54  }
const CaloCellGeometry * ptr_

Member Function Documentation

◆ get()

CaloCellGeometry const* CaloCellGeometryMayOwnPtr::get ( ) const
inline

◆ operator CaloCellGeometry const *()

CaloCellGeometryMayOwnPtr::operator CaloCellGeometry const * ( ) const
inline

Definition at line 83 of file CaloCellGeometryMayOwnPtr.h.

References ptr_.

83 { return ptr_; }
const CaloCellGeometry * ptr_

◆ operator*()

CaloCellGeometry const& CaloCellGeometryMayOwnPtr::operator* ( void  ) const
inline

Definition at line 81 of file CaloCellGeometryMayOwnPtr.h.

References ptr_.

81 { return *ptr_; }
const CaloCellGeometry * ptr_

◆ operator->()

CaloCellGeometry const* CaloCellGeometryMayOwnPtr::operator-> ( ) const
inline

Definition at line 79 of file CaloCellGeometryMayOwnPtr.h.

References ptr_.

79 { return ptr_; }
const CaloCellGeometry * ptr_

◆ operator=() [1/2]

CaloCellGeometryMayOwnPtr& CaloCellGeometryMayOwnPtr::operator= ( CaloCellGeometryMayOwnPtr const &  iPtr)
inlinenoexcept

Definition at line 55 of file CaloCellGeometryMayOwnPtr.h.

References CaloCellGeometry::increment(), eostools::move(), own_, ptr_, and groupFilesInBlocks::temp.

55  {
56  //Even if someone does `foo = foo` this will work
57  auto tmpPtr = iPtr.ptr_;
58  auto tmpOwn = iPtr.own_;
60  ptr_ = tmpPtr;
61  own_ = tmpOwn;
62  if (own_) {
63  ptr_->increment();
64  }
65  return *this;
66  }
const CaloCellGeometry * ptr_
void increment() const
def move(src, dest)
Definition: eostools.py:511

◆ operator=() [2/2]

CaloCellGeometryMayOwnPtr& CaloCellGeometryMayOwnPtr::operator= ( CaloCellGeometryMayOwnPtr &&  iPtr)
inlinenoexcept

Definition at line 67 of file CaloCellGeometryMayOwnPtr.h.

References eostools::move(), own_, ptr_, and groupFilesInBlocks::temp.

67  {
68  if (&iPtr != this) {
70 
71  ptr_ = iPtr.ptr_;
72  own_ = iPtr.own_;
73  iPtr.ptr_ = nullptr;
74  iPtr.own_ = false;
75  }
76  return *this;
77  }
const CaloCellGeometry * ptr_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ own_

bool CaloCellGeometryMayOwnPtr::own_ = false
private

Definition at line 91 of file CaloCellGeometryMayOwnPtr.h.

Referenced by operator=(), and ~CaloCellGeometryMayOwnPtr().

◆ ptr_

const CaloCellGeometry* CaloCellGeometryMayOwnPtr::ptr_ = nullptr
private