#include <DaqFormatFromBytes.h>
Collaboration diagram for DybDaq::DaqFormatFromBytes:
Public Member Functions | |
DaqFormatFromBytes () | |
Create an instance of this class. | |
virtual | ~DaqFormatFromBytes () |
Destroy this instance of the class. | |
unsigned int | additionalCapacity () |
Returns the additional number of bytes needed to read the next FileBuffer. | |
const FileBuffer * | createFileBuffer (const ByteBuffer *buffer) |
Create the next FileBuffer in the supplied buffer. | |
Private Member Functions | |
DaqFormatFromBytes (DaqFormatFromBytes &rhs) | |
Suppress default. | |
DaqFormatFromBytes & | operator= (DaqFormatFromBytes &rhs) |
Suppress default. | |
const FileBuffer * | processMarker (const ByteBuffer *buffer, unsigned int marker) |
Processes the supplied byte, dependent on the marker provided. | |
Private Attributes | |
const FileTraits * | m_traits |
The FileTraits instance used to parse the raw file. | |
unsigned int | m_additionalCapacity |
The additional number of bytes needed to read the next FileBuffer. |
Definition at line 19 of file DaqFormatFromBytes.h.
DaqFormatFromBytes::DaqFormatFromBytes | ( | ) |
Create an instance of this class.
Definition at line 35 of file DaqFormatFromBytes.cc.
00035 : 00036 m_traits(&FileTraits::defaultTraits()), 00037 m_additionalCapacity(0) { 00038 }
DaqFormatFromBytes::~DaqFormatFromBytes | ( | ) | [virtual] |
DybDaq::DaqFormatFromBytes::DaqFormatFromBytes | ( | DaqFormatFromBytes & | rhs | ) | [private] |
Suppress default.
unsigned int DaqFormatFromBytes::additionalCapacity | ( | ) |
Returns the additional number of bytes needed to read the next FileBuffer.
Definition at line 108 of file DaqFormatFromBytes.cc.
00108 { 00109 return m_additionalCapacity; 00110 }
const FileBuffer * DaqFormatFromBytes::createFileBuffer | ( | const ByteBuffer * | buffer | ) |
Create the next FileBuffer in the supplied buffer.
Definition at line 112 of file DaqFormatFromBytes.cc.
00112 { 00113 unsigned int remaining = buffer->remaining(); 00114 if (MINIMUM_CAPACITY > remaining) { 00115 m_additionalCapacity = MINIMUM_CAPACITY - remaining; 00116 return 0; 00117 } 00118 00119 unsigned int size = buffer->readUnsignedInt(buffer->position() + ByteBuffer::BYTES_IN_INT); 00120 unsigned int lengthInBytes = size * ByteBuffer::BYTES_IN_INT; 00121 if (lengthInBytes > remaining) { 00122 m_additionalCapacity = lengthInBytes - remaining; 00123 return 0; 00124 } 00125 00126 return processMarker(buffer, 00127 buffer->readUnsignedInt(buffer->position())); 00128 }
DaqFormatFromBytes& DybDaq::DaqFormatFromBytes::operator= | ( | DaqFormatFromBytes & | rhs | ) | [private] |
Suppress default.
const FileBuffer * DaqFormatFromBytes::processMarker | ( | const ByteBuffer * | buffer, | |
unsigned int | marker | |||
) | [private] |
Processes the supplied byte, dependent on the marker provided.
Definition at line 43 of file DaqFormatFromBytes.cc.
00044 { 00045 if (0 == m_traits || marker == m_traits->marker(FileTraits::kFileStartRecord)) { 00046 FileStartRecord* result = new FileStartRecord(*buffer, 00047 *m_traits); 00048 buffer->release(); 00049 const FileTraits* otherTraits = &(result->fileTraits()); 00050 if (m_traits != otherTraits) { 00051 if (0 == otherTraits) { 00052 delete result; 00053 m_additionalCapacity = 0; 00054 return 0; 00055 } 00056 m_traits = otherTraits; 00057 } 00058 return result; 00059 } 00060 if (marker == m_traits->marker(FileTraits::kFileNameStrings)) { 00061 const FileBuffer* result = new FileNameStrings(*buffer, 00062 *m_traits); 00063 buffer->release(); 00064 return result; 00065 } 00066 if (marker == m_traits->marker(FileTraits::kMetadataStrings)) { 00067 const FileBuffer* result = new MetadataStrings(*buffer, 00068 *m_traits); 00069 buffer->release(); 00070 return result; 00071 } 00072 if (marker == m_traits->marker(FileTraits::kRunParametersRecord)) { 00073 const FileBuffer* result = new RunParametersRecord(*buffer, 00074 *m_traits); 00075 buffer->release(); 00076 return result; 00077 } 00078 if (marker == m_traits->marker(FileTraits::kCalibrationParametersRecord)) { 00079 const FileBuffer* result = new CalibrationParametersRecord(*buffer, 00080 *m_traits); 00081 buffer->release(); 00082 return result; 00083 } 00084 if (marker == m_traits->marker(FileTraits::kDataSeparatorRecord)) { 00085 DataSeparatorRecord* result = new DataSeparatorRecord(*buffer, 00086 *m_traits); 00087 unsigned int length = result->blockLength(); 00088 if (length > buffer->remaining()) { 00089 m_additionalCapacity = length - buffer->remaining(); 00090 delete result; 00091 return 0; 00092 } 00093 const EventReadout* dataBlock = new EventReadout(*buffer); 00094 buffer->release(); 00095 result->setBlock(dataBlock); 00096 return result; 00097 } 00098 if (marker == m_traits->marker(FileTraits::kFileEndRecord)) { 00099 const FileBuffer* result = new FileEndRecord(*buffer, 00100 *m_traits); 00101 buffer->release(); 00102 return result; 00103 } 00104 m_additionalCapacity = 0; 00105 return 0; 00106 }
const FileTraits* DybDaq::DaqFormatFromBytes::m_traits [private] |
The FileTraits instance used to parse the raw file.
Definition at line 65 of file DaqFormatFromBytes.h.
unsigned int DybDaq::DaqFormatFromBytes::m_additionalCapacity [private] |
The additional number of bytes needed to read the next FileBuffer.
Definition at line 70 of file DaqFormatFromBytes.h.