ATLAS Offline Software
Loading...
Searching...
No Matches
TPCnvList.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5/**
6 * @file AthenaPoolCnvSvc/TPCnvList.icc
7 * @author scott snyder <snyder@bnl.gov>
8 * @date Jan, 2016
9 * @brief Helper for calling TP converters from an Athena converter.
10 */
11
12
13namespace AthenaPoolCnvSvc {
14
15
16/**
17 * @brief Read the persistent object and convert it to transient.
18 * @param parent The top-level pool converter object.
19 * @param key The SG key of the object being read.
20 * @param msg MsgStream for error reporting.
21 *
22 * Returns a newly-allocated object.
23 * If the type of the persistent object on the file does not match the
24 * the type of any of our TP converters, return nullptr.
25 * Other errors are reported by raising exceptions.
26 */
27template <class CNV, class TRANS, class ... TPCNVS>
28std::unique_ptr<TRANS>
29TPCnvList<CNV, TRANS, TPCNVS...>::createTransient (CNV& parent,
30 const Token* token,
31 const std::string& key,
32 MsgStream& msg)
33{
34 // Try createTransient on each TPCnv; stop when one succeeds.
35 std::unique_ptr<TRANS> result;
36 std::apply([&](auto& ... elt) {
37 (void)(... || (result = elt.createTransient(parent, token, key, msg)));
38 }, m_list);
39 return result;
40}
41
42
43/**
44 * @brief Read the persistent object and convert it to transient.
45 * @param parent The top-level pool converter object.
46 * @param trans The transient object to modify.
47 * @param key The SG key of the object being read.
48 * @param msg MsgStream for error reporting.
49 *
50 * Overwrites the provided transient object.
51 * If the type of the persistent object on the file does not match the
52 * the type of any of our TP converters, return false.
53 * Other errors are reported by raising exceptions.
54 */
55template <class CNV, class TRANS, class ... TPCNVS>
56bool TPCnvList<CNV, TRANS, TPCNVS...>::persToTrans (CNV& parent,
57 TRANS* trans,
58 const Token* token,
59 const std::string& key,
60 MsgStream& msg)
61{
62 // Try persToTrans on each TPCnv; stop when one succeeds.
63 bool found = false;
64 std::apply([&](auto& ... elt) {
65 (void)(... || (found = elt.persToTrans(parent, trans, token, key, msg)));
66 }, m_list);
67 return found;
68}
69
70
71} // namespace AthenaPoolCnvSvc