#include <FileNameStrings.h>
Inheritance diagram for DybDaq::FileNameStrings:
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 | |
FileNameStrings (const std::string application, const std::string fileBase, const FileTraits &traits) | |
FileNameStrings (const ByteBuffer &byteBuffer, const FileTraits &traits) | |
Create an instance of this class using the supplied buffer. | |
virtual | ~FileNameStrings () |
Destroy this instance of the class. | |
virtual bool | isMarked (unsigned int marker) const |
Returns true if this object contains the specified marker. | |
std::string | application () const |
Returns the application used to create this file. | |
std::string | fileBase () const |
Returns the base from which to build the file's name. | |
virtual unsigned int | gather (OutputBufferList &outputBuffers) const |
Adds to the supplied list the OutputBuffers that contain the DAQ format of this object's content, returning the total number of bytes in the added buffers. | |
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 const DaqTraits & | daqTraits () 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 | |
FileNameStrings () | |
Suppress default. | |
FileNameStrings (FileNameStrings &rhs) | |
Suppress default. | |
FileNameStrings & | operator= (FileNameStrings &rhs) |
Suppress default. | |
void | setNameStrings (const std::string application, const std::string fileBase) |
Sets the application used to create this file and the base from which to build the file's name. | |
unsigned int | firstLength () const |
Static Private Member Functions | |
static std::string | readString (const char *buffer) |
Reads string from binary representation. | |
static unsigned int | calculateStringsLength (const std::string application, const std::string fileBase) |
Calculates, in bytes, the length os the totoal binary representation. | |
static unsigned int | writeString (const std::string &value, char *buffer) |
Reads string into binary representation. | |
Private Attributes | |
const std::string * | m_application |
const std::string * | m_fileBase |
char * | m_stringBuffer |
The buffer used to hold binary bytes of the metadata strings. |
Definition at line 18 of file FileNameStrings.h.
FileNameStrings::FileNameStrings | ( | const std::string | application, | |
const std::string | fileBase, | |||
const FileTraits & | traits | |||
) |
Definition at line 20 of file FileNameStrings.cc.
00022 : 00023 FileBuffer(new char[traits.recordSize(FileTraits::kFileNameStrings) * kBytesInInt], 00024 traits, 00025 FileTraits::kFileNameStrings), 00026 m_application(0), 00027 m_fileBase(0), 00028 m_stringBuffer(0) { 00029 setNameStrings(application, 00030 fileBase); 00031 }
FileNameStrings::FileNameStrings | ( | const ByteBuffer & | byteBuffer, | |
const FileTraits & | traits | |||
) |
Create an instance of this class using the supplied buffer.
Definition at line 35 of file FileNameStrings.cc.
00036 : 00037 FileBuffer(byteBuffer, 00038 traits), 00039 m_application(0), 00040 m_fileBase(0), 00041 m_stringBuffer(0) { 00042 }
FileNameStrings::~FileNameStrings | ( | ) | [virtual] |
Destroy this instance of the class.
Definition at line 44 of file FileNameStrings.cc.
00044 { 00045 if (0 != m_stringBuffer) { 00046 delete m_stringBuffer; 00047 } 00048 if (0 != m_fileBase) { 00049 delete m_fileBase; 00050 } 00051 if (0 != m_application) { 00052 delete m_application; 00053 } 00054 }
DybDaq::FileNameStrings::FileNameStrings | ( | ) | [private] |
Suppress default.
DybDaq::FileNameStrings::FileNameStrings | ( | FileNameStrings & | rhs | ) | [private] |
Suppress default.
bool FileNameStrings::isMarked | ( | unsigned int | marker | ) | const [virtual] |
Returns true if this object contains the specified marker.
Implements DybDaq::FileBuffer.
Definition at line 56 of file FileNameStrings.cc.
00056 { 00057 return FileTraits::kFileNameStrings == marker; 00058 }
string FileNameStrings::application | ( | ) | const |
Returns the application used to create this file.
Definition at line 68 of file FileNameStrings.cc.
00068 { 00069 if (0 == m_application) { 00070 const char* start; 00071 if (hasByteBuffer()) { 00072 start = buffer() + (fileTraits().firstNameLengthOffset() * kBytesInInt); 00073 } else { 00074 start = m_stringBuffer; 00075 } 00076 m_application = new string(readString(start)); 00077 00078 unsigned int appLength = m_application->size(); 00079 unsigned int paddedAppLength = appLength + (kBytesInInt - 1) - ((appLength - 1) % kBytesInInt ); 00080 start += paddedAppLength + kBytesInInt; 00081 m_fileBase = new string(readString(start)); 00082 } 00083 return *m_application; 00084 }
string FileNameStrings::fileBase | ( | ) | const |
Returns the base from which to build the file's name.
Definition at line 86 of file FileNameStrings.cc.
00086 { 00087 if (0 == m_application) { 00088 application(); 00089 } 00090 return *m_fileBase; 00091 }
unsigned int FileNameStrings::gather | ( | OutputBufferList & | outputBuffers | ) | const [virtual] |
Adds to the supplied list the OutputBuffers that contain the DAQ format of this object's content, returning the total number of bytes in the added buffers.
Definition at line 93 of file FileNameStrings.cc.
00093 { 00094 if (hasByteBuffer()) { 00095 return FileBuffer::gather(outputBuffers); 00096 } 00097 const unsigned int fixedLength = fileTraits().recordSize(FileTraits::kFileNameStrings) * kBytesInInt; 00098 outputBuffers.push_back(OutputBuffer(buffer(), 00099 fixedLength)); 00100 unsigned int stringsLength = (size() * kBytesInInt) - fixedLength; 00101 outputBuffers.push_back(OutputBuffer(m_stringBuffer, 00102 stringsLength)); 00103 return fixedLength + stringsLength; 00104 }
unsigned int FileNameStrings::formatComponent | ( | ) | const [protected, virtual] |
Returns the component with the format of this buffer.
Reimplemented from DybDaq::DaqBuffer.
Definition at line 64 of file FileNameStrings.cc.
00064 { 00065 return FileTraits::kFileNameStrings; 00066 }
FileNameStrings& DybDaq::FileNameStrings::operator= | ( | FileNameStrings & | rhs | ) | [private] |
Suppress default.
void DybDaq::FileNameStrings::setNameStrings | ( | const std::string | application, | |
const std::string | fileBase | |||
) | [private] |
Sets the application used to create this file and the base from which to build the file's name.
string FileNameStrings::readString | ( | const char * | buffer | ) | [static, private] |
Reads string from binary representation.
Definition at line 130 of file FileNameStrings.cc.
00130 { 00131 unsigned int length = *((unsigned int*)(buffer)); 00132 char* base = new char[length + 1]; 00133 memcpy(base, 00134 buffer + kBytesInInt, 00135 length); 00136 base[length] = 0; 00137 string result(base); 00138 delete base; 00139 return result; 00140 }
static unsigned int DybDaq::FileNameStrings::calculateStringsLength | ( | const std::string | application, | |
const std::string | fileBase | |||
) | [static, private] |
Calculates, in bytes, the length os the totoal binary representation.
static unsigned int DybDaq::FileNameStrings::writeString | ( | const std::string & | value, | |
char * | buffer | |||
) | [static, private] |
Reads string into binary representation.
unsigned int FileNameStrings::firstLength | ( | ) | const [private] |
Definition at line 60 of file FileNameStrings.cc.
00060 { 00061 return readUnsignedInt(FileTraits::kFirstNameLength); 00062 }
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 std::string* DybDaq::FileNameStrings::m_application [mutable, private] |
Definition at line 105 of file FileNameStrings.h.
const std::string* DybDaq::FileNameStrings::m_fileBase [mutable, private] |
Definition at line 107 of file FileNameStrings.h.
char* DybDaq::FileNameStrings::m_stringBuffer [private] |
The buffer used to hold binary bytes of the metadata strings.
Definition at line 112 of file FileNameStrings.h.