ATLAS Offline Software
CaloClusterNavigable.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
11 
12 #include <algorithm>
13 //#include <iostream>
14 
16  : m_ownLinkStore(false)
17 { }
18 
20  CaloCellLink* pLink)
21  : m_ownLinkStore(false)
22 {
24  pLink,
25  m_cellLink);
26 }
27 
29  : m_ownLinkStore(true)
30 {
31  m_cellLink.setElement(pLink);
32 }
33 
35 {
36  // If we own the store, the link holds the pointer directly.
37  if ( m_ownLinkStore ) delete m_cellLink.cachedElement();
38 }
39 
41 {
42  if ( m_ownLinkStore )
43  {
44  if ( *m_cellLink == nullptr ) m_cellLink.setElement(new CaloCellLink());
45  // Ok, because this happens only if we own the pointer.
46  CaloCellLink* link ATLAS_THREAD_SAFE = const_cast<CaloCellLink*>(*m_cellLink);
47  return link;
48  }
49  else
50  {
51  return (CaloCellLink*)nullptr;
52  }
53 
54  // check if local pointer to store
55  // if ( m_cellLinkPointer != 0 ) { return m_cellLinkPointer;}
56  // check if linked pointer to store
57  // if ( m_cellLink.isValid() && *m_cellLink != 0 )
58  // {
59  // FIXME
60  // CaloCellLink* pLink = const_cast<CaloCellLink*>(*m_cellLink);
61  // return pLink;
62  // }
63  // create a new local store/
64  // m_cellLinkPointer = new CaloCellLink();
65  // return m_cellLinkPointer;
66 }
67 
68 const CaloCellLink*
70 {
71  // return *m_cellLink;
72 
73  // if ( m_cellLinkPointer != 0 )
74  // {
75  // std::cout << "[CaloClusterNavigable@" << this << "] return "
76  // << "cell link @" << m_cellLinkPointer << std::endl;
77  // return m_cellLinkPointer;
78  // }
79  // if ( *m_cellLink == 0 )
80  // {
81  // std::cout << "[CaloClusterNavigable@" << this << "] problem with "
82  // << "cell link store, unexpected pointer = "
83  // << *m_cellLink << std::endl;
84  // }
85  return m_cellLink.isValid() ? *m_cellLink : nullptr;
86 }
CaloClusterNavigable.h
CaloClusterLinkTemplate.h
CaloClusterNavigable::CaloClusterNavigable
CaloClusterNavigable()
default constructor
Definition: CaloClusterNavigable.cxx:15
CaloClusterNavigable::m_cellLink
cell_link_type m_cellLink
Local pointer to cell store.
Definition: CaloClusterNavigable.h:186
CaloClusterLinkTemplate::setLink
static bool setLink(CONT *pCont, DOBJ *pDat, ELEM &rElm)
Definition: CaloClusterLinkTemplate.h:26
CaloClusterNavigable::getCellLink
CaloCellLink * getCellLink()
Definition: CaloClusterNavigable.cxx:40
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
CaloClusterNavigable::m_ownLinkStore
bool m_ownLinkStore
Definition: CaloClusterNavigable.h:178
CaloClusterNavigable::~CaloClusterNavigable
virtual ~CaloClusterNavigable()
destructor
Definition: CaloClusterNavigable.cxx:34