ATLAS Offline Software
BlockFillerTool.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 /**
5  * @file D3PDMakerUtils/BlockFillerTool.h
6  * @author scott snyder <snyder@bnl.gov>
7  * @date Aug, 2009
8  * @brief Template definitions for BlockFillerTool.
9  */
10 
11 
12 namespace D3PD {
13 
14 
15 /**
16  * @brief Standard Gaudi tool constructor.
17  * @param type The name of the tool type.
18  * @param name The tool name.
19  * @param parent The tool's Gaudi parent.
20  */
21 template <class T>
22 BlockFillerTool<T>::BlockFillerTool (const std::string& type,
23  const std::string& name,
24  const IInterface* parent)
25  : BlockFillerToolImpl (type, name, parent)
26 {
27  // cppcheck-suppress missingReturn; false positive
28 }
29 
30 
31 /**
32  * @brief Configure during initialization: type-check.
33  * @param tree Our parent for tuple making.
34  * @param ti Gives the type of the object being passed to @c fillUntyped.
35  *
36  * @c configureD3PD should check that the type of the object coming as input
37  * is compatible with what it expects, and raise an error otherwise.
38  */
39 template <class T>
40 StatusCode
41 BlockFillerTool<T>::configureD3PD (IAddVariable* tree,
42  const std::type_info& ti)
43 {
44  return configureImpl (tree, ti, typeid(T));
45 }
46 
47 
48 /**
49  * @brief Fill one block.
50  * @param p The input object.
51  * @param again Set if this is a subsequent call requested by an AGAIN return
52  *
53  * This is called once per object. The type of the object at which @c p
54  * points is given by the @c ti argument to @c configureD3PD. The caller
55  * is responsible for arranging that all the pointers for booked variables
56  * are set appropriately upon entry.
57  *
58  * If the return status is the special code @c AGAIN (defined above),
59  * then this filler tool wants to make multiple entries.
60  * The parent should set up to capture a new `row' and run
61  * through the list of block filler
62  * tools again, but for this tool call @c fillAgainUntyped
63  * instead of @c fillUntyped. This should be repeated as long
64  * as @c fillAgainUntyped returns @c AGAIN.
65  *
66  * Once @c fillUntyped returns @c AGAIN, the parent should
67  * call @c fillUntyped with the same @a p argument and @c again
68  * set to @c true. This continues until @c fillUntyped returns something
69  * other than @c AGAIN.
70  *
71  * Not all parents may support this. In that case, returning
72  * @c AGAIN will be treated as an error.
73  */
74 template <class T>
75 StatusCode
76 BlockFillerTool<T>::fillUntyped (const void* p,
77  bool again /*= false*/)
78 {
79  if (!p) return StatusCode::SUCCESS;
80  StatusCode stat = convert (p);
81  if (stat.isFailure())
82  return stat;
83  if (again)
84  return fillAgain (*reinterpret_cast<const T*> (p));
85  return fill (*reinterpret_cast<const T*> (p));
86 }
87 
88 
89 
90 /**
91  * @brief Fill one block, after @c AGAIN has been returned (type-safe).
92  * @param p The input object.
93  *
94  * Once @c fill returns @c AGAIN, the parent should
95  * call @c fillAgain with the same arguments.
96  * This continues until @c fillAgain returns something
97  * other than @c AGAIN.
98  *
99  * By default, this just calls @c fill().
100  */
101 template <class T>
102 StatusCode BlockFillerTool<T>::fillAgain (const T& p)
103 {
104  return this->fill (p);
105 }
106 
107 
108 } // namespace D3PD