2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file AthContainers/PackedParameters.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Describe how the contents of a @c PackedContainer are to be saved.
18 * @brief Initialize with default packing parameters for type @c T.
20 * For integer types, the number of bits and signedness is set to match @c T.
21 * For floating types, nbits is set to 32, nmantissa to 23, isSigned to true,
22 * and the scale is cleared.
25 PackedParameters::PackedParameters (T /*val*/)
26 : m_nbits(8 * sizeof(uint32_t)),
31 if (std::numeric_limits<T>::is_signed)
34 if (std::numeric_limits<T>::is_integer)
35 setNbits (8*sizeof(T));
42 * @brief The number of bits used to store each element.
45 uint8_t PackedParameters::nbits() const
52 * @brief The number of bits used for the mantissa portion of a float-point
53 * representation, excluding a sign bit (if any).
55 * If there are at least two bits left over after accounting
56 * for the mantissa and sign bits, then numbers will be saved
57 * in a floating-point format; otherwise, fixed-point.
60 uint8_t PackedParameters::nmantissa() const
67 * @brief Additional flags describing the packing.
69 * (This should really only be used by converters.)
72 uint8_t PackedParameters::flags() const
79 * @brief Return the scale for floating-point numbers.
81 * If enabled, float-point numbers will be divided by this value
82 * before being saved. If not enabled, this may return 0.
85 float PackedParameters::scale() const
92 * @brief Are elements being written as signed numbers?
95 bool PackedParameters::isSigned() const
97 return m_flags & FLAG_IS_SIGNED;
102 * @brief Are elements being written as floating-point numbers?
105 bool PackedParameters::isFloat() const
107 return m_flags & FLAG_IS_FLOAT;
112 * @brief Should floats be rescaled before writing?
115 bool PackedParameters::hasScale() const
117 return m_flags & FLAG_HAS_SCALE;
122 * @brief Should floats be rounded during writing?
125 bool PackedParameters::rounding() const
127 return m_flags & FLAG_ROUNDING;