#include <FileStartRecord.h>
Inheritance diagram for DybDaq::FileStartRecord:
Public Types | |
typedef std::pair< const char *, unsigned int > | OutputBuffer |
typedef std::vector< OutputBuffer > | OutputBufferList |
typedef std::vector< ByteInspector * > | Bytes |
typedef std::vector< BitsInspector * > | Bits |
Public Member Functions | |
FileStartRecord (const unsigned int fileNumber, const FileTraits::FileDateTime &dateTime, const unsigned int dataBlockLimit, const unsigned int megabyteLimit, const FileTraits &traits) | |
FileStartRecord (const ByteBuffer &byteBuffer, const FileTraits &traits) | |
Creates an instance of this class from the supplied buffer. | |
virtual | ~FileStartRecord () |
Destroys this instance of the class. | |
virtual const DaqTraits & | daqTraits () const |
Returns the DaqTraits instance used to parse this object's buffer. | |
virtual bool | isMarked (unsigned int marker) const |
Returns true if this object contains the specified marker. | |
unsigned int | majorVersion () const |
Returns the majorVersion of the event format. | |
unsigned int | minorVersion () const |
Returns the minorVersion of the event format. | |
unsigned int | fileNumber () const |
Returns the number of the file in the run. | |
FileTraits::FileDateTime | dateTime () const |
Returns time when file was opened, as HHMMSS. | |
unsigned int | dataBlockLimit () const |
Returns the maximum number of data blocks allowed in file. | |
unsigned int | megabyteLimit () const |
Returns the maimum file size in MB. | |
unsigned int | date () const |
unsigned int | time () const |
Returns time when file was opened, as HHMMSS. | |
const FileTraits & | fileTraits () const |
Returns the FileTraits instance used to parse this object's buffer. | |
unsigned int | marker () const |
Returns the marker for this FileBuffer. | |
unsigned int | size () const |
Returns the length of this record in 4-byte words. | |
virtual unsigned int | bufferSize () const |
Returns the size, in 4-bytes,, of this object's contents in the buffer. | |
bool | hasDaqTraits () const |
virtual unsigned int | gather (OutputBufferList &outputBuffers) const |
virtual unsigned int | inspect (DaqBuffer::Bytes &inspectors) const |
Static Public Attributes | |
static const unsigned int | kBytesInInt |
static const unsigned int | kUndefinedFormatComponent |
Protected Member Functions | |
virtual unsigned int | formatComponent () const |
Returns the component with the format of this buffer. | |
void | setMarker (const unsigned int marker) |
Sets the marker for this FileBuffer. | |
void | setSize (const unsigned int size) |
Sets the size, in 4-bytes,, of this object's contents in the buffer. | |
const char * | buffer () const |
char * | buffer () |
bool | hasByteBuffer () const |
const ByteBuffer & | byteBuffer () const |
unsigned int | fillInspectors (DaqBuffer::Bytes &inspectors, unsigned int component, unsigned int cursor) const |
virtual bool | readBool (const unsigned int field) const |
virtual int | readInt (const unsigned int field) const |
virtual unsigned char | readUnsignedChar (const unsigned int field) const |
virtual unsigned int | readUnsignedInt (const unsigned int field) const |
virtual void | writeField (const bool value, const unsigned int field) |
virtual void | writeField (const int value, const unsigned int field) |
virtual void | writeField (const unsigned int value, const unsigned int field) |
Private Member Functions | |
FileStartRecord () | |
Suppress default. | |
FileStartRecord (FileStartRecord &rhs) | |
Suppress default. | |
FileStartRecord & | operator= (FileStartRecord &rhs) |
Suppress default. | |
void | setMajorVersion (const unsigned int majorVersion) |
Sets the majorVersion of the event format. | |
void | setMinorVersion (const unsigned int minorVersion) |
Sets the minorVersion of the event format. | |
void | setHeaderSize (const unsigned int headerSize) |
Sets the length of this head in the buffer in 4-byte words. | |
void | setTotalSize (const unsigned int totalSize) |
Sets the total size of the event in the buffer in 4-byte words. | |
void | setFileNumber (const unsigned int fileNumber) |
Sets the number of the file in the run. | |
void | setDateTime (const FileTraits::FileDateTime &dateTime) |
Sets time when file was opened, as HHMMSS. | |
void | setDataBlockLimit (const unsigned int dataBlockLimit) |
Sets the maximum number of data blocks allowed in file. | |
void | setMegabyteLimit (const unsigned int megabyteLimit) |
Sets the maimum file size in MB. | |
void | setDate (const unsigned int date) |
void | setTime (const unsigned int time) |
Sets time when file was opened, as HHMMSS. | |
Private Attributes | |
const FileTraits * | m_traits |
The FileTraits instance used to parse this object's buffer. |
Definition at line 18 of file FileStartRecord.h.
FileStartRecord::FileStartRecord | ( | const unsigned int | fileNumber, | |
const FileTraits::FileDateTime & | dateTime, | |||
const unsigned int | dataBlockLimit, | |||
const unsigned int | megabyteLimit, | |||
const FileTraits & | traits | |||
) |
Definition at line 21 of file FileStartRecord.cc.
00025 : 00026 FileBuffer(new char[traits.recordSize(FileTraits::kFileStartRecord) * kBytesInInt], 00027 traits, 00028 FileTraits::kFileStartRecord) { 00029 m_traits = &traits; 00030 setMajorVersion(traits.majorVersion()); 00031 setMinorVersion(traits.minorVersion()); 00032 setFileNumber(fileNumber); 00033 setDateTime(dateTime); 00034 setDataBlockLimit(dataBlockLimit); 00035 setMegabyteLimit(megabyteLimit); 00036 }
FileStartRecord::FileStartRecord | ( | const ByteBuffer & | byteBuffer, | |
const FileTraits & | traits | |||
) |
Creates an instance of this class from the supplied buffer.
Definition at line 39 of file FileStartRecord.cc.
00040 : 00041 FileBuffer(byteBuffer, 00042 traits) { 00043 m_traits = &traits; 00044 const char* buffer = byteBuffer.cursor() - (size() * kBytesInInt); 00045 m_traits = FileTraits::readTraits(buffer); 00046 }
FileStartRecord::~FileStartRecord | ( | ) | [virtual] |
DybDaq::FileStartRecord::FileStartRecord | ( | ) | [private] |
Suppress default.
DybDaq::FileStartRecord::FileStartRecord | ( | FileStartRecord & | rhs | ) | [private] |
Suppress default.
const DaqTraits & FileStartRecord::daqTraits | ( | ) | const [virtual] |
Returns the DaqTraits instance used to parse this object's buffer.
Reimplemented from DybDaq::DaqBuffer.
Definition at line 51 of file FileStartRecord.cc.
00051 { 00052 return *m_traits; 00053 }
bool FileStartRecord::isMarked | ( | unsigned int | marker | ) | const [virtual] |
Returns true if this object contains the specified marker.
Implements DybDaq::FileBuffer.
Definition at line 55 of file FileStartRecord.cc.
00055 { 00056 return FileTraits::kFileStartRecord == marker; 00057 }
unsigned int FileStartRecord::majorVersion | ( | ) | const |
Returns the majorVersion of the event format.
Definition at line 59 of file FileStartRecord.cc.
00059 { 00060 return readUnsignedInt(FileTraits::kMajorVersion); 00061 }
unsigned int FileStartRecord::minorVersion | ( | ) | const |
Returns the minorVersion of the event format.
Definition at line 63 of file FileStartRecord.cc.
00063 { 00064 return readUnsignedInt(FileTraits::kMinorVersion); 00065 }
unsigned int FileStartRecord::fileNumber | ( | ) | const |
Returns the number of the file in the run.
Definition at line 67 of file FileStartRecord.cc.
00067 { 00068 return readUnsignedInt(FileTraits::kFileNumber); 00069 }
FileTraits::FileDateTime FileStartRecord::dateTime | ( | ) | const |
Returns time when file was opened, as HHMMSS.
Definition at line 71 of file FileStartRecord.cc.
00071 { 00072 const unsigned int openDate = date(); 00073 const unsigned int openTime = time(); 00074 struct tm tmStruct; 00075 tmStruct.tm_sec = openTime % 100U;; 00076 tmStruct.tm_min = (openTime /100U) % 100U; 00077 tmStruct.tm_hour = (openTime /10000U) % 100U; 00078 tmStruct.tm_mday = (openDate / 1000000U) % 100U; 00079 tmStruct.tm_mon = ((openDate / 10000U) % 100U) - 1; 00080 tmStruct.tm_year = (openDate % 10000U) - kTmBaseYear; 00081 tmStruct.tm_wday = 0; 00082 tmStruct.tm_yday = 0; 00083 tmStruct.tm_isdst = 0; 00084 return tmStruct; 00085 }
unsigned int FileStartRecord::dataBlockLimit | ( | ) | const |
Returns the maximum number of data blocks allowed in file.
Definition at line 87 of file FileStartRecord.cc.
00087 { 00088 return readUnsignedInt(FileTraits::kDataBlockLimit); 00089 }
unsigned int FileStartRecord::megabyteLimit | ( | ) | const |
Returns the maimum file size in MB.
Definition at line 91 of file FileStartRecord.cc.
00091 { 00092 return readUnsignedInt(FileTraits::kMegabyteLimit); 00093 }
unsigned int FileStartRecord::date | ( | ) | const |
Definition at line 95 of file FileStartRecord.cc.
00095 { 00096 return readUnsignedInt(FileTraits::kFileOpenDate); 00097 }
unsigned int FileStartRecord::time | ( | ) | const |
Returns time when file was opened, as HHMMSS.
Definition at line 99 of file FileStartRecord.cc.
00099 { 00100 return readUnsignedInt(FileTraits::kFileOpenTime); 00101 }
unsigned int FileStartRecord::formatComponent | ( | ) | const [protected, virtual] |
Returns the component with the format of this buffer.
Reimplemented from DybDaq::DaqBuffer.
Definition at line 103 of file FileStartRecord.cc.
00103 { 00104 return FileTraits::kFileStartRecord; 00105 }
FileStartRecord& DybDaq::FileStartRecord::operator= | ( | FileStartRecord & | rhs | ) | [private] |
Suppress default.
void FileStartRecord::setMajorVersion | ( | const unsigned int | majorVersion | ) | [private] |
Sets the majorVersion of the event format.
Definition at line 107 of file FileStartRecord.cc.
00107 { 00108 writeField(majorVersion, 00109 FileTraits::kMajorVersion); 00110 }
void FileStartRecord::setMinorVersion | ( | const unsigned int | minorVersion | ) | [private] |
Sets the minorVersion of the event format.
Definition at line 112 of file FileStartRecord.cc.
00112 { 00113 writeField(minorVersion, 00114 FileTraits::kMinorVersion); 00115 }
void DybDaq::FileStartRecord::setHeaderSize | ( | const unsigned int | headerSize | ) | [private] |
Sets the length of this head in the buffer in 4-byte words.
void DybDaq::FileStartRecord::setTotalSize | ( | const unsigned int | totalSize | ) | [private] |
Sets the total size of the event in the buffer in 4-byte words.
void FileStartRecord::setFileNumber | ( | const unsigned int | fileNumber | ) | [private] |
Sets the number of the file in the run.
Definition at line 117 of file FileStartRecord.cc.
00117 { 00118 writeField(fileNumber, 00119 FileTraits::kFileNumber); 00120 }
void FileStartRecord::setDateTime | ( | const FileTraits::FileDateTime & | dateTime | ) | [private] |
Sets time when file was opened, as HHMMSS.
Definition at line 122 of file FileStartRecord.cc.
00122 { 00123 setDate(dateTime.tm_year + kTmBaseYear 00124 + (dateTime.tm_mon + 1) * 10000 00125 + dateTime.tm_mday * 1000000); 00126 setTime(dateTime.tm_sec 00127 + dateTime.tm_min * 100 00128 + dateTime.tm_hour * 10000); 00129 }
void FileStartRecord::setDataBlockLimit | ( | const unsigned int | dataBlockLimit | ) | [private] |
Sets the maximum number of data blocks allowed in file.
Definition at line 131 of file FileStartRecord.cc.
00131 { 00132 writeField(dataBlockLimit, 00133 FileTraits::kDataBlockLimit); 00134 }
void FileStartRecord::setMegabyteLimit | ( | const unsigned int | megabyteLimit | ) | [private] |
Sets the maimum file size in MB.
Definition at line 136 of file FileStartRecord.cc.
00136 { 00137 writeField(megabyteLimit, 00138 FileTraits::kMegabyteLimit); 00139 }
void FileStartRecord::setDate | ( | const unsigned int | date | ) | [private] |
Definition at line 141 of file FileStartRecord.cc.
00141 { 00142 writeField(date, 00143 FileTraits::kFileOpenDate); 00144 }
void FileStartRecord::setTime | ( | const unsigned int | time | ) | [private] |
Sets time when file was opened, as HHMMSS.
Definition at line 146 of file FileStartRecord.cc.
00146 { 00147 writeField(time, 00148 FileTraits::kFileOpenTime); 00149 }
const FileTraits & FileBuffer::fileTraits | ( | ) | const [inherited] |
Returns the FileTraits instance used to parse this object's buffer.
Definition at line 40 of file FileBuffer.cc.
00040 { 00041 return dynamic_cast<const FileTraits&>(daqTraits()); 00042 }
unsigned int FileBuffer::marker | ( | ) | const [inherited] |
Returns the marker for this FileBuffer.
Definition at line 44 of file FileBuffer.cc.
00044 { 00045 return readUnsignedInt(FileTraits::kMarker); 00046 }
unsigned int FileBuffer::size | ( | ) | const [inherited] |
Returns the length of this record in 4-byte words.
Definition at line 48 of file FileBuffer.cc.
00048 { 00049 return readUnsignedInt(FileTraits::kRecordSize); 00050 }
unsigned int FileBuffer::bufferSize | ( | ) | const [virtual, inherited] |
Returns the size, in 4-bytes,, of this object's contents in the buffer.
Implements DybDaq::DaqBuffer.
Definition at line 52 of file FileBuffer.cc.
00052 { 00053 return size(); 00054 }
void FileBuffer::setMarker | ( | const unsigned int | marker | ) | [protected, inherited] |
Sets the marker for this FileBuffer.
Definition at line 56 of file FileBuffer.cc.
00056 { 00057 writeField(marker, 00058 FileTraits::kMarker); 00059 }
void FileBuffer::setSize | ( | const unsigned int | size | ) | [protected, inherited] |
Sets the size, in 4-bytes,, of this object's contents in the buffer.
Definition at line 61 of file FileBuffer.cc.
00061 { 00062 writeField(size, 00063 FileTraits::kRecordSize); 00064 }
const FileTraits* DybDaq::FileStartRecord::m_traits [private] |
The FileTraits instance used to parse this object's buffer.
This is set after construction, so can not use base class's.
Reimplemented from DybDaq::DaqBuffer.
Definition at line 168 of file FileStartRecord.h.