SG::PackedParameters Class Reference

Describe how the contents of a PackedContainer are to be saved. More...

#include <PackedParameters.h>

List of all members.

Public Types

enum  { FLAG_IS_SIGNED = (1<<0), FLAG_IS_FLOAT = (1<<1), FLAG_HAS_SCALE = (1<<2), FLAG_ROUNDING = (1<<3) }

Public Member Functions

 PackedParameters ()
 Default constructor.
 PackedParameters (uint8_t nbits, uint8_t flags)
 Constructor from nbits and flags.
template<class T >
 PackedParameters (T)
 Initialize with default packing parameters for type T.
uint8_t nbits () const
 The number of bits used to store each element.
uint8_t nmantissa () const
 The number of bits used for the mantissa portion of a float-point representation, excluding a sign bit (if any).
uint8_t flags () const
 Additional flags describing the packing.
float scale () const
 Return the scale for floating-point numbers.
bool isSigned () const
 Are elements being written as signed numbers?
bool isFloat () const
 Are elements being written as floating-point numbers?
bool hasScale () const
 Should floats be rescaled before writing?
bool rounding () const
 Should floats be rounded during writing?
bool setNbits (uint8_t nbits)
 Set the number of bits to be used for each element.
bool setNmantissa (uint8_t nmantissa)
 Set the number of mantissa bits used in the packed representation.
bool setScale (float scale)
 Set the scale to use when packing floating-point data.
bool setSigned (bool flag)
 Set the signedness flag for the packed representation.
bool setRounding (bool flag)
 Set the rounding mode.
bool setFloat (bool flag)
 Set the floating-point flag.
bool setOption (const AuxDataOption &option)
 Set a packing option. option The option to set.

Static Public Member Functions

static bool isValidOption (const AuxDataOption &option)
 Test to see if option is a recognized packing option.

Detailed Description

Describe how the contents of a PackedContainer are to be saved.

When a PackedContainer is saved to a root file, the contents may be stored with reduced precision. How this packing is done is described by the parameters held in this structure. These include:

The remaining parameters are only used when elements are being saved as floating-point.

User code will should usually not interact with this class directly. Use the setOption interfaces instead.


Member Enumeration Documentation

anonymous enum

Define bit assignments for the flags field. Existing flag assignments should never be changed, as the persistent format may depend on them.


Constructor & Destructor Documentation

SG::PackedParameters::PackedParameters (  ) 

Default constructor.

Set up to write unsigned integers with 32 bits.

SG::PackedParameters::PackedParameters ( uint8_t  nbits,
uint8_t  flags 
)

Constructor from nbits and flags.

Parameters:
nbits The number of bits for each element.
flags Extra flags describing the packing.

Additionally nmantissa is set to correspond to a fixed-point representation and the scale is cleared.

This is meant to be used by the read converter.

template<class T >
SG::PackedParameters::PackedParameters ( T   )  [inline]

Initialize with default packing parameters for type T.

For integer types, the number of bits and signedness is set to match T. For floating types, nbits is set to 32, nmantissa to 23, isSigned to true, and the scale is cleared.


Member Function Documentation

uint8_t SG::PackedParameters::flags (  )  const [inline]

Additional flags describing the packing.

(This should really only be used by converters.)

bool SG::PackedParameters::isValidOption ( const AuxDataOption option  )  [static]

Test to see if option is a recognized packing option.

Parameters:
option The option to test.

Returns true if the name of option is recognized as a valid packing option; false otherwise.

uint8_t SG::PackedParameters::nmantissa (  )  const [inline]

The number of bits used for the mantissa portion of a float-point representation, excluding a sign bit (if any).

If there are at least two bits left over after accounting for the mantissa and sign bits, then numbers will be saved in a floating-point format; otherwise, fixed-point.

float SG::PackedParameters::scale (  )  const [inline]

Return the scale for floating-point numbers.

If enabled, float-point numbers will be divided by this value before being saved. If not enabled, this may return 0.

bool SG::PackedParameters::setFloat ( bool  flag  ) 

Set the floating-point flag.

Parameters:
flag Should numbers be written as floating-point?

If true, numbers will be written in a floating/fixed point representation; otherwise, they will be written as integers.

Returns true to indicate success.

bool SG::PackedParameters::setNbits ( uint8_t  nbits  ) 

Set the number of bits to be used for each element.

nbits The desired number of bits. nbits must be in the range 1-32 for unsigned numbers, 2-32 for signed numbers.

If necessary, nmantissa will be adjusted so that it still fits within the requested number of bits.

Returns true if successful, false otherwise.

bool SG::PackedParameters::setNmantissa ( uint8_t  nmantissa  ) 

Set the number of mantissa bits used in the packed representation.

nmantissa The desired number of mantissa bits. This has an effect only when saving floating-point types.

nmantissa must fit within the requested number of bits. nmantissa does not include the sign bit. If there are at least two bits left over, then numbers will be saved in a floating-point format; otherwise, fixed point will be used.

Returns true if successful, false otherwise.

bool SG::PackedParameters::setOption ( const AuxDataOption option  ) 

Set a packing option. option The option to set.

Recognized options are `nbits', `nmantissa', `scale', `signed', `rounding', and `float'. See the setter functions above for details on their semantics.

Returns true on success; false otherwise.

bool SG::PackedParameters::setRounding ( bool  flag  ) 

Set the rounding mode.

Parameters:
flag Should numbers be rounded when being written?

This has an effect only when saving floating-point types.

Returns true to indicate success.

bool SG::PackedParameters::setScale ( float  scale  ) 

Set the scale to use when packing floating-point data.

Parameters:
scale The new scale, or 0 to disable.

This has an effect only when saving floating-point types.

If set to something non-zero, then floating-point numbers will be divided by this value before being written.

Returns true to indicate success.

bool SG::PackedParameters::setSigned ( bool  flag  ) 

Set the signedness flag for the packed representation.

Parameters:
flag Should elements be saved as signed numbers?

If the flag is false (unsigned), this always succeeds. If the flag is true (signed), then this fails if nbits is 1. nmantissa will be adjusted if there are now insufficient bits for it.

Returns true if successful, false otherwise.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 15 Apr 2017 for RootCore Packages by  doxygen 1.6.1