ATLAS Offline Software
CaloClusterNavigable.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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 ( m_ownLinkStore && *m_cellLink != nullptr ) delete *m_cellLink;
37 }
38 
40 {
41  if ( m_ownLinkStore )
42  {
43  if ( *m_cellLink == nullptr ) m_cellLink.setElement(new CaloCellLink());
44  // Ok, because this happens only if we own the pointer.
45  CaloCellLink* link ATLAS_THREAD_SAFE = const_cast<CaloCellLink*>(*m_cellLink);
46  return link;
47  }
48  else
49  {
50  return (CaloCellLink*)nullptr;
51  }
52 
53  // check if local pointer to store
54  // if ( m_cellLinkPointer != 0 ) { return m_cellLinkPointer;}
55  // check if linked pointer to store
56  // if ( m_cellLink.isValid() && *m_cellLink != 0 )
57  // {
58  // FIXME
59  // CaloCellLink* pLink = const_cast<CaloCellLink*>(*m_cellLink);
60  // return pLink;
61  // }
62  // create a new local store/
63  // m_cellLinkPointer = new CaloCellLink();
64  // return m_cellLinkPointer;
65 }
66 
67 const CaloCellLink*
69 {
70  // return *m_cellLink;
71 
72  // if ( m_cellLinkPointer != 0 )
73  // {
74  // std::cout << "[CaloClusterNavigable@" << this << "] return "
75  // << "cell link @" << m_cellLinkPointer << std::endl;
76  // return m_cellLinkPointer;
77  // }
78  // if ( *m_cellLink == 0 )
79  // {
80  // std::cout << "[CaloClusterNavigable@" << this << "] problem with "
81  // << "cell link store, unexpected pointer = "
82  // << *m_cellLink << std::endl;
83  // }
84  return m_cellLink.isValid() ? *m_cellLink : nullptr;
85 }
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:39
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