ATLAS Offline Software
TPCnvList.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #ifndef ATHENAPOOLCNVSVC_TPCNVLIST_H
17 #define ATHENAPOOLCNVSVC_TPCNVLIST_H
18 
19 
21 #include "boost/mpl/vector.hpp"
22 #include "boost/mpl/transform.hpp"
23 #include <boost/fusion/mpl.hpp>
24 #include "boost/fusion/container/vector.hpp"
25 #include "boost/fusion/container/vector/convert.hpp"
26 #include "boost/fusion/algorithm/iteration/accumulate.hpp"
27 
28 
29 namespace AthenaPoolCnvSvc {
30 
31 
35 template <class CNV, class TRANS, class ... TPCNVS>
36 class TPCnvList
37 {
39  template <class TPCNV>
40  struct wrap_tpcnv
41  {
43  };
44 
45 
49  {
50  do_create_transient (CNV& parent, const std::string& key, MsgStream& msg);
51 
52  // FIXME: It would be better to pass a unique_ptr through here.
53  // But that requires the resolution of DR2055, which g++ only implements
54  // with c++20.
55  template <class ELT>
56  typename ELT::Trans_t* operator() (typename ELT::Trans_t* p, ELT& elt);
57 
58  CNV& m_parent;
59  const std::string& m_key;
60  MsgStream& m_msg;
61  };
62 
63 
67  {
68  do_pers_to_trans (CNV& parent, TRANS* trans, const std::string& key, MsgStream& msg);
69 
70  template <class ELT>
71  bool operator() (bool found, ELT& elt);
72 
73  CNV& m_parent;
74  TRANS* m_trans;
75  const std::string& m_key;
76  MsgStream& m_msg;
77  };
78 
79 
80 public:
81  // Coverity fails to compile this correctly.
82 #ifndef __COVERITY__
83  // Convert the list of TP converters <T1, T2, ...> to a boost fusion vector
84  // of converters wrapped by TPCnvElt:
85  // boost::fusion::vector<TPCnvElt<T1>, TPCnvElt<T2>, ...>
86  // We can create in instance of this vector to get an object that holds
87  // all the TP converter instances.
88  typedef boost::mpl::vector<TPCNVS...> vec_t;
89  typedef typename boost::mpl::transform<vec_t, wrap_tpcnv<boost::mpl::_1> >::type list_mpl_t;
91 #endif
92 
93 
105  std::unique_ptr<TRANS>
106  createTransient (CNV& parent, const std::string& key, MsgStream& msg);
107 
108 
121  bool persToTrans (CNV& parent, TRANS* trans, const std::string& key, MsgStream& msg);
122 
123 
124 private:
125 #ifndef __COVERITY__
126  list_t m_list;
128 #endif
129 };
130 
131 
132 } // namespace AthenaPoolCnvSvc
133 
134 
136 
137 
138 #endif // not ATHENAPOOLCNVSVC_TPCNVLIST_H
139 
140 
AthenaPoolCnvSvc::TPCnvList::list_mpl_t
boost::mpl::transform< vec_t, wrap_tpcnv< boost::mpl::_1 > >::type list_mpl_t
Definition: TPCnvList.h:89
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::m_parent
CNV & m_parent
Definition: TPCnvList.h:73
AthenaPoolCnvSvc::TPCnvList::persToTrans
bool persToTrans(CNV &parent, TRANS *trans, const std::string &key, MsgStream &msg)
Read the persistent object and convert it to transient.
AthenaPoolCnvSvc::TPCnvList::do_create_transient::m_msg
MsgStream & m_msg
Definition: TPCnvList.h:60
AthenaPoolCnvSvc::TPCnvList::do_create_transient::m_key
const std::string & m_key
Definition: TPCnvList.h:59
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
AthenaPoolCnvSvc::TPCnvList::vec_t
boost::mpl::vector< TPCNVS... > vec_t
Definition: TPCnvList.h:88
AthenaPoolCnvSvc::TPCnvElt
Helper for calling a TP converter from an Athena converter.
Definition: TPCnvElt.h:61
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::m_key
const std::string & m_key
Definition: TPCnvList.h:75
AthenaPoolCnvSvc::TPCnvList::do_create_transient::do_create_transient
do_create_transient(CNV &parent, const std::string &key, MsgStream &msg)
AthenaPoolCnvSvc::TPCnvList::wrap_tpcnv::type
TPCnvElt< CNV, TPCNV > type
Definition: TPCnvList.h:42
AthenaPoolCnvSvc::TPCnvList::do_create_transient::m_parent
CNV & m_parent
Definition: TPCnvList.h:58
AthenaPoolCnvSvc::TPCnvList::list_t
boost::fusion::result_of::as_vector< list_mpl_t >::type list_t
Definition: TPCnvList.h:90
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans
Functional to iterate over TP converters and call persToTrans on each.
Definition: TPCnvList.h:67
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaPoolCnvSvc::TPCnvList
Helper for calling TP converters from an Athena converter.
Definition: TPCnvList.h:37
TPCnvList.icc
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::m_trans
TRANS * m_trans
Definition: TPCnvList.h:74
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::do_pers_to_trans
do_pers_to_trans(CNV &parent, TRANS *trans, const std::string &key, MsgStream &msg)
AthenaPoolCnvSvc::TPCnvList::do_create_transient::operator()
ELT::Trans_t * operator()(typename ELT::Trans_t *p, ELT &elt)
AthenaPoolCnvSvc::TPCnvList::do_create_transient
Functional to iterate over TP converters and call createTransient on each.
Definition: TPCnvList.h:49
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
AthenaPoolCnvSvc::TPCnvList::createTransient
std::unique_ptr< TRANS > createTransient(CNV &parent, const std::string &key, MsgStream &msg)
Read the persistent object and convert it to transient.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthenaPoolCnvSvc::TPCnvList::wrap_tpcnv
Metafunction to wrap a TP converter in TPCnvElt.
Definition: TPCnvList.h:41
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::m_msg
MsgStream & m_msg
Definition: TPCnvList.h:76
TPCnvElt.h
Helper for calling a TP converter from an Athena converter.
AthenaPoolCnvSvc::TPCnvList::do_pers_to_trans::operator()
bool operator()(bool found, ELT &elt)
AthenaPoolCnvSvc::TPCnvList::m_list
list_t m_list
List of TP converter instances, wrapped by TPCnvElt.
Definition: TPCnvList.h:127
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
AthenaPoolCnvSvc
Definition: Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/debug.h:26