ATLAS Offline Software
Loading...
Searching...
No Matches
SG::PackedConverter Class Reference

Helper for packing/unpacking a PackedContainer to/from a stream. More...

#include <PackedConverter.h>

Collaboration diagram for SG::PackedConverter:

Public Member Functions

 PackedConverter (const PackedParameters &parms)
 Constructor.
template<class U, class ALLOC, class STREAM>
void write (size_t nelt, const std::vector< U, ALLOC > &vec, STREAM &stream)
 Pack a vector to the stream.
template<class U, class ALLOC1, class ALLOC2, class STREAM>
void write (size_t nelt, const std::vector< std::vector< U, ALLOC1 >, ALLOC2 > &vec, STREAM &stream)
 Pack a nested vector to the stream.
template<class U, class ALLOC, class STREAM>
void read (size_t nelt, std::vector< U, ALLOC > &vec, STREAM &stream)
 Unpack a vector from the stream.
template<class U, class ALLOC1, class ALLOC2, class STREAM>
void read (size_t nelt, std::vector< std::vector< U, ALLOC1 >, ALLOC2 > &vec, STREAM &stream)
 Unpack a nested vector from the stream.

Private Member Functions

template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void writeUnsigned (size_t nelt, const std::vector< U, ALLOC > &vec, STREAM &stream)
 Pack a vector of unsigned values to the stream.
template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void writeSigned (size_t nelt, const std::vector< U, ALLOC > &vec, STREAM &stream)
 Pack a vector of signed values to the stream.
template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void writeFloat (size_t nelt, const std::vector< U, ALLOC > &vec, STREAM &stream)
 Pack a vector of float values to the stream.
template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void readUnsigned (size_t nelt, std::vector< U, ALLOC > &vec, STREAM &stream)
 Unpack a vector of unsigned values from the stream.
template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void readSigned (size_t nelt, std::vector< U, ALLOC > &vec, STREAM &stream)
 Unpack a vector of signed values from the stream.
template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void readFloat (size_t nelt, std::vector< U, ALLOC > &vec, STREAM &stream)
 Unpack a vector of floating-point values from the stream.

Private Attributes

PackedParameters m_parms
 The parameters to use for the packing.
CxxUtils::FloatPacker m_packer
 Object to pack/unpack floating-point values.

Detailed Description

Helper for packing/unpacking a PackedContainer to/from a stream.

This object should be created with the packing parameters to use. After that, call the read or write methods. These are all templated methods taking a vector as input; this should be the vector contained within the PackedContainer. Additional overloads are supplied taking vector<vector >. These read/write the element count, then call read/write for each element of the vector. This should allow for arbitrary vector nesting.

The methods are also templated on the input/output stream. This should support operator<< and operator>> for a uint32_t; a ROOT TBuffer will satisfy this.

Definition at line 43 of file PackedConverter.h.

Constructor & Destructor Documentation

◆ PackedConverter()

SG::PackedConverter::PackedConverter ( const PackedParameters & parms)

Constructor.

Parameters
parmsThe parameters describing the packed data.

Definition at line 24 of file PackedConverter.cxx.

25 : m_parms (parms),
26 m_packer (parms.nbits(),
27 parms.nmantissa() + (parms.isSigned()?1:0),
28 parms.scale(),
29 parms.isSigned(),
30 parms.rounding())
31{
32}
CxxUtils::FloatPacker m_packer
Object to pack/unpack floating-point values.
PackedParameters m_parms
The parameters to use for the packing.

Member Function Documentation

◆ read() [1/2]

template<class U, class ALLOC1, class ALLOC2, class STREAM>
void SG::PackedConverter::read ( size_t nelt,
std::vector< std::vector< U, ALLOC1 >, ALLOC2 > & vec,
STREAM & stream )

Unpack a nested vector from the stream.

Parameters
neltNumber of elements to unpack.
vecVector to receive the unpacked elements.
streamSource stream.

◆ read() [2/2]

template<class U, class ALLOC, class STREAM>
void SG::PackedConverter::read ( size_t nelt,
std::vector< U, ALLOC > & vec,
STREAM & stream )

Unpack a vector from the stream.

Parameters
neltNumber of elements to unpack.
vecVector to receive the unpacked elements.
streamSource stream.

◆ readFloat()

template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::readFloat ( size_t nelt,
std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Unpack a vector of floating-point values from the stream.

Parameters
neltNumber of elements to unpack.
vecVector to receive the unpacked elements.
streamSource stream.

◆ readSigned()

template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::readSigned ( size_t nelt,
std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Unpack a vector of signed values from the stream.

Parameters
neltNumber of elements to unpack.
vecVector to receive the unpacked elements.
streamSource stream.

◆ readUnsigned()

template<template< class > class UNPACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::readUnsigned ( size_t nelt,
std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Unpack a vector of unsigned values from the stream.

Parameters
neltNumber of elements to unpack.
vecVector to receive the unpacked elements.
streamSource stream.

◆ write() [1/2]

template<class U, class ALLOC1, class ALLOC2, class STREAM>
void SG::PackedConverter::write ( size_t nelt,
const std::vector< std::vector< U, ALLOC1 >, ALLOC2 > & vec,
STREAM & stream )

Pack a nested vector to the stream.

Parameters
neltNumber of elements to pack.
vecVector of elements to pack.
streamDestination stream.

◆ write() [2/2]

template<class U, class ALLOC, class STREAM>
void SG::PackedConverter::write ( size_t nelt,
const std::vector< U, ALLOC > & vec,
STREAM & stream )

Pack a vector to the stream.

Parameters
neltNumber of elements to pack.
vecVector of elements to pack.
streamDestination stream.

◆ writeFloat()

template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::writeFloat ( size_t nelt,
const std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Pack a vector of float values to the stream.

Parameters
neltNumber of elements to pack.
vecVector of elements to pack.
streamDestination stream.

◆ writeSigned()

template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::writeSigned ( size_t nelt,
const std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Pack a vector of signed values to the stream.

Parameters
neltNumber of elements to pack.
vecVector of elements to pack.
streamDestination stream.

◆ writeUnsigned()

template<template< class > class PACKER, class U, class ALLOC, class STREAM>
void SG::PackedConverter::writeUnsigned ( size_t nelt,
const std::vector< U, ALLOC > & vec,
STREAM & stream )
private

Pack a vector of unsigned values to the stream.

Parameters
neltNumber of elements to pack.
vecVector of elements to pack.
streamDestination stream.

Member Data Documentation

◆ m_packer

CxxUtils::FloatPacker SG::PackedConverter::m_packer
private

Object to pack/unpack floating-point values.

Definition at line 178 of file PackedConverter.h.

◆ m_parms

PackedParameters SG::PackedConverter::m_parms
private

The parameters to use for the packing.

Definition at line 175 of file PackedConverter.h.


The documentation for this class was generated from the following files: