2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 /** @file NavigableCnv_p2.icc
6 * @brief This file contains the implementation for the NavigableCnv_p2 template methods.
7 * @author Marcin.Nowak@cern.ch
12 #include "Navigation/Navigable.h"
13 #include "AthenaKernel/getThinningCache.h"
17 //#define NAV_P2_DEBUG
20 template <typename NAV, typename RPAR>
22 NavigableCnv_p2<NAV, RPAR>
23 ::transToPers(const Navigable_t& trans,
24 PersNavigable_t& pers,
25 const SG::ThinningCache* cache,
28 // collect all element links into a temporary vector
29 ElementLinkVect_t elv;
30 pers.m_parameters.clear();
31 elv.reserve( trans.size() );
32 pers.m_parameters.reserve( trans.size() );
34 typename NAV::object_iter iter = trans.begin();
35 typename NAV::object_iter end = trans.end();
37 while( iter != end ) {
39 msg << MSG::DEBUG << "NavigableCnv_p2::transToPers(): Weight["
40 << pers.m_parameters.size()-1 <<"]="
41 << pers.m_parameters[pers.m_parameters.size()-1] << endmsg;
43 elv.push_back( iter.getElement() );
44 pers.m_parameters.push_back( iter.getParameter() );
47 // convert the link vector to persistent
48 m_linkCnv.transToPers(elv, pers.m_links, cache, msg);
52 template <typename NAV, typename RPAR>
54 NavigableCnv_p2<NAV, RPAR>
55 ::transToPers(const Navigable_t& trans,
56 PersNavigable_t& pers,
59 transToPers (trans, pers,
60 SG::getThinningCache(),
65 template <typename NAV, typename RPAR >
66 void NavigableCnv_p2<NAV, RPAR >::persToTrans(const PersNavigable_t& pers,
70 // create a temporary link vector from persistent
71 ElementLinkVect_t elv;
72 m_linkCnv.persToTrans(pers.m_links, elv, msg);
74 // copy from link vector into navigable
75 size_t size = elv.size();
77 for( size_t i = 0; i < size; ++i ) {
78 trans.insertElement (elv[i], pers.m_parameters[i], size);
80 msg << MSG::DEBUG << "NavigableCnv_p2::PersToTrans(): Weight[" <<i <<"]="
81 << pers.m_parameters[i] << endmsg;
87 template <typename NAV, typename RPAR>
90 NavigableCnv_p2<NAV, RPAR>
91 ::transToPers(const Navigable_t* trans, PersNavigable_t* pers, MsgStream& msg) const
93 this->transToPers(*trans, *pers, msg);
97 template <typename NAV, typename RPAR >
100 NavigableCnv_p2<NAV, RPAR >
101 ::persToTrans(const PersNavigable_t* pers, Navigable_t* trans, MsgStream& msg) const
103 this->persToTrans(*pers, *trans, msg);
107 //-----------------------------------------------------
108 // Specialized version of the converter for Navigables without weight parameters
111 template <typename NAV >
113 NavigableCnv_p2<NAV, NavigationDefaults::DefaultWeight >
114 ::transToPers(const Navigable_t& trans,
115 PersNavigable_t& pers,
116 const SG::ThinningCache* cache,
117 MsgStream& msg) const
119 // collect all element links into a temporary vector
120 ElementLinkVect_t elv;
121 elv.reserve( trans.size() );
123 typename NAV::object_iter iter = trans.begin();
124 typename NAV::object_iter end = trans.end();
126 while( iter != end ) {
127 elv.push_back( iter.getElement() );
130 // convert the link vector to persistent
131 m_linkCnv.transToPers(elv, pers.m_links, cache, msg);
135 template <typename NAV >
137 NavigableCnv_p2<NAV, NavigationDefaults::DefaultWeight >
138 ::transToPers(const Navigable_t& trans,
139 PersNavigable_t& pers,
140 MsgStream& msg) const
142 transToPers (trans, pers,
143 SG::getThinningCache(),
148 template <typename NAV >
151 NavigableCnv_p2<NAV, NavigationDefaults::DefaultWeight >
152 ::transToPers(const Navigable_t* trans, PersNavigable_t* pers, MsgStream& msg) const
154 this->transToPers(*trans, *pers, msg);
158 //-------------------- persToTrans() ----------------------------------
160 template <typename NAV >
162 NavigableCnv_p2<NAV, NavigationDefaults::DefaultWeight >
163 ::persToTrans(const PersNavigable_t& pers,
165 MsgStream& msg) const
167 // create a temporary link vector from persistent
168 ElementLinkVect_t elv;
169 m_linkCnv.persToTrans(pers.m_links, elv, msg);
171 // copy from link vector into navigable
173 size_t size = elv.size();
174 for( size_t i = 0; i < size; ++i ) {
175 trans.insertElement(elv[i], NavigationDefaults::DefaultWeight(), size);
180 template <typename NAV >
183 NavigableCnv_p2<NAV, NavigationDefaults::DefaultWeight >
184 ::persToTrans(const PersNavigable_t* pers, Navigable_t* trans, MsgStream& msg) const
186 this->persToTrans(*pers, *trans, msg);