ATLAS Offline Software
Loading...
Searching...
No Matches
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$
14
15
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
29namespace AthenaPoolCnvSvc {
30
31
35template <class CNV, class TRANS, class ... TPCNVS>
37{
39 template <class TPCNV>
41 {
43 };
44
45
49 {
50 do_create_transient (CNV& parent, const Token* token, 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
59 const Token* m_token;
60 const std::string& m_key;
61 MsgStream& m_msg;
62 };
63
64
68 {
69 do_pers_to_trans (CNV& parent, TRANS* trans, const Token* token, const std::string& key, MsgStream& msg);
70
71 template <class ELT>
72 bool operator() (bool found, ELT& elt);
73
75 TRANS* m_trans;
76 const Token* m_token;
77 const std::string& m_key;
78 MsgStream& m_msg;
79 };
80
81
82public:
83 // Coverity fails to compile this correctly.
84#ifndef __COVERITY__
85 // Convert the list of TP converters <T1, T2, ...> to a boost fusion vector
86 // of converters wrapped by TPCnvElt:
87 // boost::fusion::vector<TPCnvElt<T1>, TPCnvElt<T2>, ...>
88 // We can create in instance of this vector to get an object that holds
89 // all the TP converter instances.
90 typedef boost::mpl::vector<TPCNVS...> vec_t;
91 typedef typename boost::mpl::transform<vec_t, wrap_tpcnv<boost::mpl::_1> >::type list_mpl_t;
92 typedef typename boost::fusion::result_of::as_vector<list_mpl_t>::type list_t;
93#endif
94
95
107 std::unique_ptr<TRANS>
108 createTransient (CNV& parent, const Token* token, const std::string& key, MsgStream& msg);
109
110
123 bool persToTrans (CNV& parent, TRANS* trans, const Token* token, const std::string& key, MsgStream& msg);
124
125
126private:
127#ifndef __COVERITY__
130#endif
131};
132
133
134} // namespace AthenaPoolCnvSvc
135
136
138
139
140#endif // not ATHENAPOOLCNVSVC_TPCNVLIST_H
141
142
Helper for calling a TP converter from an Athena converter.
Helper for calling a TP converter from an Athena converter.
Definition TPCnvElt.h:62
Helper for calling TP converters from an Athena converter.
Definition TPCnvList.h:37
boost::mpl::vector< TPCNVS... > vec_t
Definition TPCnvList.h:90
std::unique_ptr< TRANS > createTransient(CNV &parent, const Token *token, const std::string &key, MsgStream &msg)
Read the persistent object and convert it to transient.
boost::mpl::transform< vec_t, wrap_tpcnv< boost::mpl::_1 > >::type list_mpl_t
Definition TPCnvList.h:91
list_t m_list
List of TP converter instances, wrapped by TPCnvElt.
Definition TPCnvList.h:129
bool persToTrans(CNV &parent, TRANS *trans, const Token *token, const std::string &key, MsgStream &msg)
Read the persistent object and convert it to transient.
boost::fusion::result_of::as_vector< list_mpl_t >::type list_t
Definition TPCnvList.h:92
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:21
ELT::Trans_t * operator()(typename ELT::Trans_t *p, ELT &elt)
do_create_transient(CNV &parent, const Token *token, const std::string &key, MsgStream &msg)
do_pers_to_trans(CNV &parent, TRANS *trans, const Token *token, const std::string &key, MsgStream &msg)
Metafunction to wrap a TP converter in TPCnvElt.
Definition TPCnvList.h:41
MsgStream & msg
Definition testRead.cxx:32