2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 /** @file NavigableCnv_p1.icc
6 * @brief This file contains the implementation for the NavigableCnv_p1 template methods.
7 * @author Marcin.Nowak@cern.ch
12 #include "Navigation/Navigable.h"
13 #include "AthenaKernel/getThinningCache.h"
18 //#define NAV_P1_DEBUG
21 template <typename NAV, typename RPAR>
23 NavigableCnv_p1<NAV, RPAR>::transToPers(const Navigable_t& trans,
24 PersNavigable_t& pers,
25 const SG::ThinningCache* cache,
28 pers.m_parameters.clear();
30 // collect all element links into a temporary vector
31 ElementLinkVect_t elv;
32 elv.reserve(trans.size());
33 /// FIXME: should we also reserve some space for pers->m_parameters ?!?
34 //pers.m_parameters.reserve( pers.m_parameters.size() + link_coll.size() );
36 typename NAV::object_iter iter = trans.begin();
37 typename NAV::object_iter end = trans.end();
39 while( iter != end ) {
41 msg << MSG::DEBUG << "NavigableCnv_p1::transToPers(): Weight["
42 << pers.m_parameters.size()-1 <<"]="
43 << pers.m_parameters[pers.m_parameters.size()-1] << endmsg;
45 elv.push_back( iter.getElement() );
46 pers.m_parameters.push_back( iter.getParameter() );
49 // this is not needed (and might actually crash if thinning occurred!)
50 // as this is done by the ELVCnv::transToPers
53 // convert the link vector to persistent
54 m_linkCnv.transToPers(elv, pers.m_links, cache, msg);
58 template <typename NAV, typename RPAR>
60 NavigableCnv_p1<NAV, RPAR>::transToPers(const Navigable_t& trans,
61 PersNavigable_t& pers,
64 transToPers (trans, pers,
65 SG::getThinningCache(),
70 template <typename NAV, typename RPAR >
71 void NavigableCnv_p1<NAV, RPAR >::persToTrans(const PersNavigable_t& pers,
75 // create a temporary link vector from persistent
76 ElementLinkVect_t elv;
77 m_linkCnv.persToTrans(pers.m_links, elv, msg);
80 // copy from link vector into navigable
81 size_t size = elv.size();
83 for( size_t i = 0; i < size; ++i ) {
84 trans.insertElement (elv[i], pers.m_parameters[i], size);
86 msg << MSG::DEBUG << "NavigableCnv_p1::PersToTrans(): Weight[" <<i <<"]="
87 << pers.m_parameters[i] << endmsg;
93 template <typename NAV, typename RPAR>
96 NavigableCnv_p1<NAV, RPAR>
97 ::transToPers(const Navigable_t* trans, PersNavigable_t* pers, MsgStream& msg) const
99 this->transToPers(*trans, *pers, msg);
103 template <typename NAV, typename RPAR >
106 NavigableCnv_p1<NAV, RPAR >
107 ::persToTrans(const PersNavigable_t* pers, Navigable_t* trans, MsgStream& msg) const
109 this->persToTrans(*pers, *trans, msg);
113 //-----------------------------------------------------
114 // Specialized version of the converter for Navigables without weight parameters
117 template <typename NAV >
119 NavigableCnv_p1<NAV, NavigationDefaults::DefaultWeight >
120 ::transToPers(const Navigable_t& trans,
121 PersNavigable_t& pers,
122 const SG::ThinningCache* cache,
123 MsgStream& msg) const
125 // collect all element links into a temporary vector
126 ElementLinkVect_t elv;
127 elv.reserve(trans.size());
128 /// FIXME: should we also reserve some space for pers->m_parameters ?!?
129 //pers.m_parameters.reserve( pers.m_parameters.size() + link_coll.size() );
131 typename NAV::object_iter iter = trans.begin();
132 typename NAV::object_iter end = trans.end();
134 while( iter != end ) {
135 elv.push_back( iter.getElement() );
138 // this is not needed (and might actually crash if thinning occurred!)
139 // as this is done by the ELVCnv::transToPers
140 //elv.toPersistent();
142 // convert the link vector to persistent
143 m_linkCnv.transToPers(elv, pers.m_links, cache, msg);
147 template <typename NAV >
149 NavigableCnv_p1<NAV, NavigationDefaults::DefaultWeight >
150 ::transToPers(const Navigable_t& trans,
151 PersNavigable_t& pers,
152 MsgStream& msg) const
154 transToPers (trans, pers,
155 SG::getThinningCache(),
160 template <typename NAV >
163 NavigableCnv_p1<NAV, NavigationDefaults::DefaultWeight >
164 ::transToPers(const Navigable_t* trans, PersNavigable_t* pers, MsgStream& msg) const
166 this->transToPers(*trans, *pers, msg);
170 //-------------------- persToTrans() ----------------------------------
172 template <typename NAV >
174 NavigableCnv_p1<NAV, NavigationDefaults::DefaultWeight >
175 ::persToTrans(const PersNavigable_t& pers,
177 MsgStream& msg) const
179 // create a temporary link vector from persistent
180 ElementLinkVect_t elv;
181 m_linkCnv.persToTrans(pers.m_links, elv, msg);
184 // copy from link vector into navigable
185 size_t size = elv.size();
187 for( size_t i = 0; i < size; ++i ) {
188 trans.insertElement (elv[i], NavigationDefaults::DefaultWeight(), size);
193 template <typename NAV >
196 NavigableCnv_p1<NAV, NavigationDefaults::DefaultWeight >
197 ::persToTrans(const PersNavigable_t* pers, Navigable_t* trans, MsgStream& msg) const
199 this->persToTrans(*pers, *trans, msg);