ATLAS Offline Software
PackedContainer.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 /**
5  * @file AthContainers/PackedContainer.icc
6  * @author scott snyder <snyder@bnl.gov>
7  * @date Sep, 2014
8  * @brief Container to hold aux data to be stored in a packed form.
9  */
10 
11 
12 namespace SG {
13 
14 
15 /**
16  * @brief Metafunction to extract the innermost element type
17  * from a nested vector type.
18  *
19  * I.e., vector<vector<... <T> > should yield T.
20  */
21 template <class T>
22 struct inner_type
23 {
24  typedef T type;
25 };
26 template <class T, class ALLOC>
27 struct inner_type<std::vector<T, ALLOC> >
28 {
29  typedef typename inner_type<T>::type type;
30 };
31 
32 
33 /**
34  * @brief Constructor.
35  *
36  * The packing parameters will be initialized to defaults appropriate
37  * for type @c T. (See @c PackedParameters.)
38  */
39 template <class T, class ALLOC>
40 inline
41 PackedContainer<T, ALLOC>::PackedContainer()
42  : m_parms (static_cast<typename inner_type<T>::type>(0))
43 {
44 }
45 
46 
47 /**
48  * @brief Set a packing option.
49  * @param option The option to set.
50  *
51  * Returns true on success, false otherwise.
52  *
53  * See @c PackedParameters::setOptions for details.
54  */
55 template <class T, class ALLOC>
56 inline
57 bool PackedContainer<T, ALLOC>::setOption (const AuxDataOption& option)
58 {
59  return m_parms.setOption (option);
60 }
61 
62 
63 /**
64  * @brief Set a packing option.
65  * @param name The option name.
66  * @param val The option value.
67  *
68  * Returns true on success, false otherwise.
69  *
70  * See @c PackedParameters::setOptions for details.
71  */
72 template <class T, class ALLOC>
73 inline
74 bool PackedContainer<T, ALLOC>::setOption (const std::string& name, int val)
75 {
76  return this->setOption (SG::AuxDataOption (name, val));
77 }
78 
79 
80 /**
81  * @brief Set a packing option.
82  * @param name The option name.
83  * @param val The option value.
84  *
85  * Returns true on success, false otherwise.
86  *
87  * See @c PackedParameters::setOptions for details.
88  */
89 template <class T, class ALLOC>
90 inline
91 bool PackedContainer<T, ALLOC>::setOption (const std::string& name, float val)
92 {
93  return this->setOption (SG::AuxDataOption (name, val));
94 }
95 
96 
97 /**
98  * @brief Set a packing option.
99  * @param name The option name.
100  * @param val The option value.
101  *
102  * Returns true on success, false otherwise.
103  *
104  * See @c PackedParameters::setOptions for details.
105  */
106 template <class T, class ALLOC>
107 inline
108 bool PackedContainer<T, ALLOC>::setOption (const std::string& name, double val)
109 {
110  return this->setOption (SG::AuxDataOption (name, val));
111 }
112 
113 
114 /**
115  * @brief Return the packing parameters for this container.
116  */
117 template <class T, class ALLOC>
118 inline
119 const PackedParameters& PackedContainer<T, ALLOC>::parms() const
120 {
121  return m_parms;
122 }
123 
124 
125 /**
126  * @brief Set the packing parameters.
127  * @param parms The new packing parameters.
128  */
129 template <class T, class ALLOC>
130 inline
131 void PackedContainer<T, ALLOC>::setParms (const PackedParameters& parms)
132 {
133  m_parms = parms;
134 }
135 
136 
137 } // namespace SG