ATLAS Offline Software
Loading...
Searching...
No Matches
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
12namespace 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 */
21template <class T>
22struct inner_type
23{
24 typedef T type;
25};
26template <class T, class ALLOC>
27struct 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 */
39template <class T, class ALLOC>
40inline
41PackedContainer<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 */
55template <class T, class ALLOC>
56inline
57bool 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 */
72template <class T, class ALLOC>
73inline
74bool 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 */
89template <class T, class ALLOC>
90inline
91bool 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 */
106template <class T, class ALLOC>
107inline
108bool 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 */
117template <class T, class ALLOC>
118inline
119const 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 */
129template <class T, class ALLOC>
130inline
131void PackedContainer<T, ALLOC>::setParms (const PackedParameters& parms)
132{
133 m_parms = parms;
134}
135
136
137} // namespace SG