ATLAS Offline Software
NavWrapper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef NAVIGATION_NAVWRAPPER_H
6 #define NAVIGATION_NAVWRAPPER_H
7 
10 
11 #include <any>
12 
13 template<class NAVIMPL>
14 class NavWrapper
15 {
16 public:
17 
19  typedef NAVIMPL navimpl_t;
20  // /*!{ \brief Publish important types from \a Navigable, new style */
21  // typedef typename navimpl::container_t container_t;
22  // typedef typename navimpl::constituent_t constituent_t;
23  // typedef typename navimpl::parameter_t parameter_t;
24  // typedef typename navimpl::object_iter_t object_iter_t;
25  // typedef typename navimpl::external_index_t external_index_t;
40  NavWrapper(const navimpl_t& theNav) : m_nav(theNav) { };
42  virtual ~NavWrapper() { };
43 
44  // common interface with Navigable FIXME improve code organization
45 
50  virtual void fillToken(INavigationToken& navToken) const
51  { m_nav.fillToken(navToken); }
52 
57  virtual void fillToken(INavigationToken& navToken,
58  const std::any& parentParameter) const
59  { m_nav.fillToken(navToken, parentParameter); }
60 
62  // Add data objects or elements //
64 
69  void putElement(const container_type* pCont,
70  const constituent_type* pObj,
71  const parameter_type& oPar = parameter_type(),
72  size_t sizeHint = 0)
73  { m_nav.putElement(pCont,pObj,oPar,sizeHint); }
75  void putElement(const container_type* pCont,
76  external_index_type& iObj,
77  const parameter_type& oPar = parameter_type(),
78  size_t sizeHint = 0)
79  { m_nav.putElement(pCont,iObj,oPar,sizeHint); }
81  void insertElement(const container_type* pCont,
82  const constituent_type* pObj,
83  const parameter_type& oPar = parameter_type(),
84  size_t sizeHint = 0)
85  { m_nav.insertElement(pCont,pObj,oPar,sizeHint); }
87  void insertElement(const container_type* pCont,
88  external_index_type& iObj,
89  const parameter_type& oPar = parameter_type(),
90  size_t sizeHint = 0)
91  { m_nav.insertElement(pCont,iObj,oPar,sizeHint); }
92 
94  // Data manipulation //
96 
97  // re-weight (overwrite old weight)
98  void reweight(const constituent_type* pObj,
99  const parameter_type& oPar = parameter_type())
100  { m_nav.reweight(pObj,oPar); }
101  void reweight(const container_type* pCont,
102  external_index_type& iObj,
103  const parameter_type& oPar = parameter_type())
104  { m_nav.reweight(pCont,iObj,oPar); }
105  void reweight(object_iter& oIter,
106  const parameter_type& oPar = parameter_type())
107  { m_nav.reweight(oIter,oPar); }
108 
109  // remove object from the Navigable
110  bool remove(const constituent_type* pObj)
111  { return m_nav.remove(pObj); }
112  bool remove(const container_type* pCont, external_index_type& iObj)
113  { return m_nav.remove(pCont,iObj); }
114  bool removeAll() { return m_nav.removeAll(); }
115 
116  // check if constituent is already there
117  bool contains(const constituent_type* pObj) const
118  { return m_nav.contains(pObj); }
119  bool contains(const container_type* pCont,
120  external_index_type& iObj) const
121  { return m_nav.contains(pCont,iObj); }
122 
124  // Access to Constituents //
126 
127  // public object access: iterators, sizes etc.
128  virtual object_iter begin() const { return m_nav.begin(); }
129  virtual object_iter end() const { return m_nav.end(); }
130  virtual size_t size() const { return size_t(m_nav.size()); }
131 
132  // public container access: relational parameter retrieval
134  { return m_nav.getParameter(pObj); }
136  external_index_type& iObj) const
137  { return m_nav.getParameter(pCont,iObj); }
139  { return m_nav.getParameter(oIter); }
140 
141  // public container access: retrieve ElementLink for given object pointer
142  const container_type* getContainer(const constituent_type* pObj) const
143  { return m_nav.getContainer(pObj); }
144  // const container_type* getContainer(constituent_const_iter oIter) const
145  // { return m_nav.getContainer(oIter); }
147  { return m_nav.getContainer(oIter); }
148 
149  // get index of child in original container
150  bool getIndex(const constituent_type* pObj,
151  external_index_type& iObj) const
152  { return m_nav.getIndex(pObj,iObj); }
153  // bool getIndex(constituent_const_iter anIter,
154  // external_index_type& iObj) const;
155  bool getIndex(object_iter oIter,
156  external_index_type& iObj) const
157  { return m_nav.getIndex(oIter,iObj); }
158 
159  protected:
160 
161  navimpl_t& getNavImpl() { return m_nav; }
162  const navimpl_t& getNavImpl() const { return m_nav; }
163 
164  private:
167 };
186 //class NavigableTerminalNode
187 //{
188 //public:
189 //};
198 template<>
200 {
201 public:
202 
204  NavWrapper() { };
206  virtual ~NavWrapper() { };
207 
209  virtual void fillToken(INavigationToken& /*rToken*/) const { };
210  virtual void fillToken(INavigationToken& /*rToken*/,
211  const std::any& /*rPar*/ ) const { };
213 };
225 #endif
NavWrapper::getParameter
parameter_type getParameter(object_iter &oIter) const
Definition: NavWrapper.h:138
INavigationToken.h
NavWrapper::contains
bool contains(const container_type *pCont, external_index_type &iObj) const
Definition: NavWrapper.h:119
NavWrapper::getNavImpl
navimpl_t & getNavImpl()
Definition: NavWrapper.h:161
NavWrapper::reweight
void reweight(const container_type *pCont, external_index_type &iObj, const parameter_type &oPar=parameter_type())
Definition: NavWrapper.h:101
Navigable< DataVector< INavigable4Momentum >, double, std::vector< std::pair< ElementLink< DataVector< INavigable4Momentum > >, double > > >::external_index_type
SG::GenerateIndexingPolicy< DataVector< INavigable4Momentum > >::type::index_type external_index_type
Definition: Navigable.h:156
NavWrapper::insertElement
void insertElement(const container_type *pCont, external_index_type &iObj, const parameter_type &oPar=parameter_type(), size_t sizeHint=0)
Insert element into Navigable store.
Definition: NavWrapper.h:87
NavWrapper< NavigableTerminalNode >::NavWrapper
NavWrapper()
Default constructor.
Definition: NavWrapper.h:204
NavWrapper::reweight
void reweight(object_iter &oIter, const parameter_type &oPar=parameter_type())
Definition: NavWrapper.h:105
NavWrapper< NavigableTerminalNode >::fillToken
virtual void fillToken(INavigationToken &, const std::any &) const
Definition: NavWrapper.h:210
NavigableTerminalNode
Dummy type needed fro specialized implementation.
Definition: NavigableTerminalNode.h:19
NavWrapper::reweight
void reweight(const constituent_type *pObj, const parameter_type &oPar=parameter_type())
Definition: NavWrapper.h:98
NavWrapper::fillToken
virtual void fillToken(INavigationToken &navToken) const
Visitor handler without relational parameter.
Definition: NavWrapper.h:50
NavWrapper::external_index_type
navimpl_t::external_index_type external_index_type
Definition: NavWrapper.h:34
NavWrapper::object_iter
navimpl_t::object_iter object_iter
Definition: NavWrapper.h:33
NavWrapper::constituent_type
navimpl_t::constituent_type constituent_type
Definition: NavWrapper.h:31
NavWrapper::getParameter
parameter_type getParameter(const constituent_type *pObj) const
Definition: NavWrapper.h:133
NavigableIterator
Definition: NavigableIterator.h:24
NavWrapper::begin
virtual object_iter begin() const
Definition: NavWrapper.h:128
NavWrapper::parameter_type
navimpl_t::parameter_type parameter_type
Definition: NavWrapper.h:32
NavWrapper::NavWrapper
NavWrapper(const navimpl_t &theNav)
Optional constructor: construct from Navigable.
Definition: NavWrapper.h:40
Navigable< DataVector< INavigable4Momentum >, double, std::vector< std::pair< ElementLink< DataVector< INavigable4Momentum > >, double > > >::parameter_type
double parameter_type
\ brief Relational parameter type
Definition: Navigable.h:112
Navigable< DataVector< INavigable4Momentum >, double, std::vector< std::pair< ElementLink< DataVector< INavigable4Momentum > >, double > > >::constituent_type
CONT::base_value_type constituent_type
Definition: Navigable.h:149
NavWrapper::navimpl_t
NAVIMPL navimpl_t
Publish navigation implementation type.
Definition: NavWrapper.h:19
NavWrapper::remove
bool remove(const constituent_type *pObj)
Definition: NavWrapper.h:110
NavWrapper::getNavImpl
const navimpl_t & getNavImpl() const
Definition: NavWrapper.h:162
NavWrapper::getIndex
bool getIndex(const constituent_type *pObj, external_index_type &iObj) const
Definition: NavWrapper.h:150
NavWrapper::size
virtual size_t size() const
Definition: NavWrapper.h:130
NavWrapper::contains
bool contains(const constituent_type *pObj) const
Definition: NavWrapper.h:117
NavWrapper::insertElement
void insertElement(const container_type *pCont, const constituent_type *pObj, const parameter_type &oPar=parameter_type(), size_t sizeHint=0)
Insert element into Navigable store.
Definition: NavWrapper.h:81
INavigationToken
Definition: INavigationToken.h:24
NavWrapper::getIndex
bool getIndex(object_iter oIter, external_index_type &iObj) const
Definition: NavWrapper.h:155
NavWrapper::container_type
navimpl_t::container_type container_type
{
Definition: NavWrapper.h:30
NavWrapper::getContainer
const container_type * getContainer(object_iter oIter) const
Definition: NavWrapper.h:146
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
NavWrapper
Wrapper for Navigable implementation.
Definition: NavWrapper.h:15
NavigableTerminalNode.h
NavWrapper::~NavWrapper
virtual ~NavWrapper()
Base class destructor.
Definition: NavWrapper.h:42
Navigable< DataVector< INavigable4Momentum >, double, std::vector< std::pair< ElementLink< DataVector< INavigable4Momentum > >, double > > >
NavWrapper::putElement
void putElement(const container_type *pCont, external_index_type &iObj, const parameter_type &oPar=parameter_type(), size_t sizeHint=0)
Add element to the Navigable store.
Definition: NavWrapper.h:75
NavWrapper< NavigableTerminalNode >::fillToken
virtual void fillToken(INavigationToken &) const
{
Definition: NavWrapper.h:209
NavWrapper::NavWrapper
NavWrapper()
}
Definition: NavWrapper.h:38
NavWrapper< NavigableTerminalNode >::~NavWrapper
virtual ~NavWrapper()
Base class destructor.
Definition: NavWrapper.h:206
NavWrapper::fillToken
virtual void fillToken(INavigationToken &navToken, const std::any &parentParameter) const
Visitor handler including a relational parameter.
Definition: NavWrapper.h:57
NavWrapper::removeAll
bool removeAll()
Definition: NavWrapper.h:114
NavWrapper::getParameter
parameter_type getParameter(const container_type *pCont, external_index_type &iObj) const
Definition: NavWrapper.h:135
NavWrapper::putElement
void putElement(const container_type *pCont, const constituent_type *pObj, const parameter_type &oPar=parameter_type(), size_t sizeHint=0)
Add element to Navigable store.
Definition: NavWrapper.h:69
NavWrapper::end
virtual object_iter end() const
Definition: NavWrapper.h:129
NavWrapper::m_nav
navimpl_t m_nav
Wrapped Navigable implementation.
Definition: NavWrapper.h:166
NavWrapper::remove
bool remove(const container_type *pCont, external_index_type &iObj)
Definition: NavWrapper.h:112
NavWrapper::getContainer
const container_type * getContainer(const constituent_type *pObj) const
Definition: NavWrapper.h:142