ATLAS Offline Software
SGELVRef.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHLINKS_TOOLS_SGELVREF_H
6 #define ATHLINKS_TOOLS_SGELVREF_H
7 
8 #include "AthLinks/DataLink.h"
9 #include "AthLinks/ElementLink.h"
10 #include <algorithm>
11 #include <exception>
12 #include <functional>
13 #include <vector>
14 #include <boost/iterator_adaptors.hpp>
15 
16 
17 
18 template <typename DOBJ>
19 class ElementLinkVector;
20 
27 namespace SG {
28  template <typename DOBJ>
29  class ELVRef
30  {
31  public:
32  typedef typename std::vector< DataLink<DOBJ> > DataLinkVector;
37  typedef typename ElemLink::index_type index_type;
39  typedef typename ElemLink::ID_type ID_type;
40 
42  ELVRef(const ELVRef& rhs);
44  ELVRef& operator=(const ELVRef& rhs);
46  ELVRef(const ElemLink& link=ElemLink());
48  ELVRef(typename DataLinkVector::size_type hostIndex,
50  const ElemLinkVec& owner);
52  ID_type dataID() const;
56  ElementConstPointer cptr() const { return m_link.cptr(); }
57 
59  const ElemLink& elementLink() const { return m_link; }
60 
62 
63  bool operator == (const ELVRef& rhs) const {
64  return ( (index() == rhs.index()) && (dataID() == rhs.dataID()) );
65  }
66  bool operator < (const ELVRef& rhs) const {
67  return ( (index() < rhs.index()) ||
68  ( (index() == rhs.index()) && (dataID() < rhs.dataID()) ) );
69  }
71 
73  bool toPersistent(const ElemLinkVec& owner);
74  bool toPersistent(const ElemLinkVec& owner,
75  typename DataLinkVector::size_type& shortref);
76  bool toTransient(const ElemLinkVec& owner);
77  bool doRemap();
78 
79  const stored_index_type& index() const
80  {
81  return m_index;
82  }
83 
84  private:
85 
86  //Transient members only.
88 
89  // Persistent members:
90  typename DataLinkVector::size_type m_shortRef;
91 
93  };
94 }
95 #endif // not ATHLINKS_TOOLS_SGELVREF_H
SG::ELVRef::ElemLinkVec
ElementLinkVector< DOBJ > ElemLinkVec
Definition: SGELVRef.h:33
SG::ELVRef::operator==
bool operator==(const ELVRef &rhs) const
Definition: SGELVRef.h:63
SG::ELVRef::m_link
ElemLink m_link
Definition: SGELVRef.h:87
SG::ELVRef::ElemLink
ElementLink< DOBJ > ElemLink
Definition: SGELVRef.h:34
SG::ELVRef::doRemap
bool doRemap()
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ELVRef::operator=
ELVRef & operator=(const ELVRef &rhs)
STL required.
SG::ELVRef::ELVRef
ELVRef(typename DataLinkVector::size_type hostIndex, index_type elementIndex, const ElemLinkVec &owner)
Constructor from indices.
index
Definition: index.py:1
SG::ELVRef::index
const stored_index_type & index() const
Definition: SGELVRef.h:79
SG::ELVRef::ELVRef
ELVRef(const ELVRef &rhs)
STL required.
SG::ELVRef::stored_index_type
ElemLink::stored_index_type stored_index_type
Definition: SGELVRef.h:38
SG::ELVRef::toTransient
bool toTransient(const ElemLinkVec &owner)
SG::ELVRef::toPersistent
bool toPersistent(const ElemLinkVec &owner)
called by handlers to change state:
SG::ELVRef::ElementConstPointer
ElemLink::ElementConstPointer ElementConstPointer
Definition: SGELVRef.h:36
SG::ELVRef
a short ref to an ElementLink into an ElementLinkVector. Used to be an internal class of ElementLinkV...
Definition: SGELVRef.h:30
SG::ELVRef::toPersistent
bool toPersistent(const ElemLinkVec &owner, typename DataLinkVector::size_type &shortref)
SG::ELVRef::m_index
stored_index_type m_index
! index of the host dobj
Definition: SGELVRef.h:92
SG::ELVRef::ELVRef
ELVRef(const ElemLink &link=ElemLink())
standard constructor
SG::ELVRef::cptr
ElementConstPointer cptr() const
element pointer in ElementLink
Definition: SGELVRef.h:56
SG::ELVRef::ID_type
ElemLink::ID_type ID_type
Definition: SGELVRef.h:39
SG::GenericElementLinkBase::stored_index_type
INDEXING_POLICY::stored_index_type stored_index_type
The type of the index as it is stored internally.
Definition: GenericElementLinkBase.h:92
ElementLinkVector
ElementLinkVector implementation for standalone ROOT.
Definition: AthLinks/ElementLinkVector.h:27
SG::ELVRef::dataID
ID_type dataID() const
dataID of the host
SG::ELVRef::elementIndex
index_type elementIndex() const
index into container (non-const, calculates and sets on demand):
SG::ELVRef::m_shortRef
DataLinkVector::size_type m_shortRef
! the element pointer
Definition: SGELVRef.h:90
SG::ELVRef::DataLinkVector
std::vector< DataLink< DOBJ > > DataLinkVector
Definition: SGELVRef.h:32
SG::ELVRef::operator<
bool operator<(const ELVRef &rhs) const
Definition: SGELVRef.h:66
SG::ELVRef::IndexingPolicy
ElemLink::IndexingPolicy IndexingPolicy
Definition: SGELVRef.h:35
SG::ELVRef::index_type
ElemLink::index_type index_type
Definition: SGELVRef.h:37
SG::ELVRef::elementLink
const ElemLink & elementLink() const
get the corresponding ElementLink. O(1)
Definition: SGELVRef.h:59