evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::EvioSwap Class Reference

Class to hold static methods used to swap evio data. More...

#include <EvioSwap.h>

Static Public Member Functions

static void swapEvent (uint32_t *buf, int tolocal, uint32_t *dest)
 Method to swap the endianness of an evio event (bank). More...
 
static void swapBank (uint32_t *buf, bool toLocal, uint32_t *dest)
 Routine to swap the endianness of an evio bank. More...
 
static void swapSegment (uint32_t *buf, bool toLocal, uint32_t *dest)
 Routine to swap the endianness of an evio segment. More...
 
static void swapTagsegment (uint32_t *buf, bool toLocal, uint32_t *dest)
 Routine to swap the endianness of an evio tagsegment. More...
 
static void swapLeafData (DataType const &type, std::shared_ptr< ByteBuffer > &srcBuf, std::shared_ptr< ByteBuffer > &destBuf, size_t srcPos, size_t destPos, size_t len)
 This method swaps the data of an evio leaf structure. More...
 
static void swapLeafData (DataType const &type, ByteBuffer &srcBuf, ByteBuffer &destBuf, size_t srcPos, size_t destPos, size_t len)
 This method swaps the data of an evio leaf structure. More...
 
static void swapData (uint32_t *src, uint32_t type, uint32_t length, bool toLocal, uint32_t *dst)
 Routine to swap any type of evio data. More...
 
static void swapData (std::shared_ptr< BaseStructure > strc)
 Routine to swap the endianness of an evio structure's (bank, seg, tagseg) data in place, including descendants' data. More...
 

Detailed Description

Class to hold static methods used to swap evio data.

Date
7/17/2020
Author
timmer

Member Function Documentation

static void evio::EvioSwap::swapBank ( uint32_t *  buf,
bool  toLocal,
uint32_t *  dest 
)
inlinestatic

Routine to swap the endianness of an evio bank.

Null buf argument does nothing.

Author
: Elliott Wolin, 21-nov-2003
: Carl Timmer, jan-2012
Parameters
bufbuffer of evio bank data to be swapped.
toLocalif false buf contains data of same endian as local host, else buf has data of opposite endian.
destbuffer to place swapped data into. If this is null, then dest = buf.

References evio::ByteOrder::byteSwap32(), and swapData().

Referenced by swapData(), and swapEvent().

static void evio::EvioSwap::swapData ( uint32_t *  src,
uint32_t  type,
uint32_t  length,
bool  toLocal,
uint32_t *  dst 
)
inlinestatic

Routine to swap any type of evio data.

This only swaps data associated with an evio structure; i.e. it completely ignores the header associated with it. If this data consists of structures like banks & segments, it will swap them completely. Null src argument does nothing.

Author
: Elliott Wolin, 21-nov-2003
: Carl Timmer, jan-2012
Parameters
srcsource of evio data to be swapped (after evio header).
typetype of evio data.
lengthlength of evio data in 32 bit words
toLocalif false data is of same endian as local host, else data is of opposite endian.
dstdestination of swapped data. If this is null, then dst = src.

References evio::ByteOrder::byteNoSwap32(), evio::ByteOrder::byteSwap16(), evio::ByteOrder::byteSwap32(), evio::ByteOrder::byteSwap64(), evio::CompositeData::swapAll(), swapBank(), swapSegment(), and swapTagsegment().

Referenced by swapBank(), swapData(), swapSegment(), and swapTagsegment().

static void evio::EvioSwap::swapData ( std::shared_ptr< BaseStructure strc)
inlinestatic

Routine to swap the endianness of an evio structure's (bank, seg, tagseg) data in place, including descendants' data.

The endianness of the given structure, obtained through BaseStructure#getByteOrder(), does NOT change. The caller must explicitly call BaseStructure#setByteOrder() to do that.

If this structure contains Composite data, and since it is stored as a vector of shared pointers to CompositeData objects, it is only serialized into bytes when written out. Thus the only way to switch it's endianness is for the user to call BaseStructure#setByteOrder() before writing it out as bytes. In other words, this method does NOT swap Composite data.

Parameters
strcevio structure in which to swap all data.
Author
: Carl Timmer, 7/28/2020

References evio::ByteOrder::byteSwap16(), evio::ByteOrder::byteSwap32(), evio::ByteOrder::byteSwap64(), evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::DataType::INT32, evio::DataType::LONG64, evio::DataType::SHORT16, swapData(), evio::DataType::UINT32, evio::DataType::ULONG64, and evio::DataType::USHORT16.

static void evio::EvioSwap::swapEvent ( uint32_t *  buf,
int  tolocal,
uint32_t *  dest 
)
inlinestatic

Method to swap the endianness of an evio event (bank).

Author
: Elliott Wolin, 21-nov-2003
: Carl Timmer, jan-2012
Parameters
bufbuffer of evio event data to be swapped
tolocalif 0 buf contains data of same endian as local host, else buf has data of opposite endian.
destbuffer to place swapped data into. If this is null, then dest = buf.

References swapBank().

static void evio::EvioSwap::swapLeafData ( DataType const &  type,
std::shared_ptr< ByteBuffer > &  srcBuf,
std::shared_ptr< ByteBuffer > &  destBuf,
size_t  srcPos,
size_t  destPos,
size_t  len 
)
inlinestatic

This method swaps the data of an evio leaf structure.

In other words the structure being swapped does not contain evio structures. It does nothing for container types.

Parameters
typetype of data being swapped
srcBufbuffer containing data to be swapped
destBufbuffer in which to place swapped data
srcPosposition in srcBuffer to start reading data
destPosposition in destBuffer to start writing swapped data
lenlength of data in 32 bit words
Exceptions
EvioExceptionif srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos;
static void evio::EvioSwap::swapLeafData ( DataType const &  type,
ByteBuffer srcBuf,
ByteBuffer destBuf,
size_t  srcPos,
size_t  destPos,
size_t  len 
)
inlinestatic

This method swaps the data of an evio leaf structure.

In other words the structure being swapped does not contain evio structures. It does nothing for container types.

Parameters
typetype of data being swapped
srcBufbuffer containing data to be swapped
destBufbuffer in which to place swapped data
srcPosposition in srcBuffer to start reading data
destPosposition in destBuffer to start writing swapped data
lenlength of data in 32 bit words
Exceptions
EvioExceptionif srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos;

References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::ByteBuffer::getByte(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::getShort(), evio::DataType::INT32, evio::DataType::LONG64, evio::ByteBuffer::put(), evio::ByteBuffer::putInt(), evio::ByteBuffer::putLong(), evio::ByteBuffer::putShort(), evio::DataType::SHORT16, evio::CompositeData::swapAll(), evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, evio::DataType::UNKNOWN32, and evio::DataType::USHORT16.

static void evio::EvioSwap::swapSegment ( uint32_t *  buf,
bool  toLocal,
uint32_t *  dest 
)
inlinestatic

Routine to swap the endianness of an evio segment.

Null buf argument does nothing.

Author
: Elliott Wolin, 21-nov-2003
: Carl Timmer, jan-2012
Parameters
bufbuffer of evio segment data to be swapped
toLocalif false buf contains data of same endian as local host, else buf has data of opposite endian
destbuffer to place swapped data into. If this is NULL, then dest = buf.

References evio::ByteOrder::byteSwap32(), and swapData().

Referenced by swapData().

static void evio::EvioSwap::swapTagsegment ( uint32_t *  buf,
bool  toLocal,
uint32_t *  dest 
)
inlinestatic

Routine to swap the endianness of an evio tagsegment.

Null buf argument does nothing.

Author
: Elliott Wolin, 21-nov-2003
: Carl Timmer, jan-2012
Parameters
bufbuffer of evio tagsegment data to be swapped
toLocalif false buf contains data of same endian as local host, else buf has data of opposite endian
destbuffer to place swapped data into. If this is NULL, then dest = buf.

References evio::ByteOrder::byteSwap32(), and swapData().

Referenced by swapData().


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