/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
DybDaq::FileNameStrings Class Reference

#include <FileNameStrings.h>

Inheritance diagram for DybDaq::FileNameStrings:
Inheritance graph
[legend]
Collaboration diagram for DybDaq::FileNameStrings:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::pair< const char
*, unsigned int > 
OutputBuffer
typedef std::vector< OutputBufferOutputBufferList
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 FileTraitsfileTraits () 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 DaqTraitsdaqTraits () 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 ByteBufferbyteBuffer () 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.
FileNameStringsoperator= (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.

Detailed Description

Definition at line 18 of file FileNameStrings.h.


Constructor & Destructor Documentation

FileNameStrings::FileNameStrings ( const std::string  application,
const std::string  fileBase,
const FileTraits traits 
)
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.

                                                                                           :
FileBuffer(byteBuffer,
                   traits),
m_application(0),
m_fileBase(0),
m_stringBuffer(0) {
}
FileNameStrings::~FileNameStrings ( ) [virtual]

Destroy this instance of the class.

Definition at line 44 of file FileNameStrings.cc.

                                  {
    if (0 != m_stringBuffer) {
        delete m_stringBuffer;
    }
    if (0 != m_fileBase) {
        delete m_fileBase;
    }
    if (0 != m_application) {
        delete m_application;
    }
}
DybDaq::FileNameStrings::FileNameStrings ( ) [private]

Suppress default.

DybDaq::FileNameStrings::FileNameStrings ( FileNameStrings rhs) [private]

Suppress default.


Member Function Documentation

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.

string FileNameStrings::application ( ) const

Returns the application used to create this file.

Definition at line 68 of file FileNameStrings.cc.

                                          {
    if (0 == m_application) {
        const char* start;
        if (hasByteBuffer()) {
            start = buffer() + (fileTraits().firstNameLengthOffset() * kBytesInInt);
        } else {
            start = m_stringBuffer;
        }
        m_application = new string(readString(start));
        
        unsigned int appLength = m_application->size();
        unsigned int paddedAppLength = appLength + (kBytesInInt - 1) - ((appLength - 1) % kBytesInInt );
        start += paddedAppLength + kBytesInInt;
        m_fileBase = new string(readString(start));
    }
    return *m_application;
}
string FileNameStrings::fileBase ( ) const

Returns the base from which to build the file's name.

Definition at line 86 of file FileNameStrings.cc.

                                       {
    if (0 == m_application) {
        application();
    }
    return *m_fileBase;
}
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.

Reimplemented from DybDaq::DaqBuffer.

Definition at line 93 of file FileNameStrings.cc.

                                                                          {
    if (hasByteBuffer()) {
        return FileBuffer::gather(outputBuffers);
    }
    const unsigned int fixedLength = fileTraits().recordSize(FileTraits::kFileNameStrings) * kBytesInInt;
    outputBuffers.push_back(OutputBuffer(buffer(),
                                         fixedLength));
    unsigned int stringsLength = (size() * kBytesInInt) - fixedLength;
    outputBuffers.push_back(OutputBuffer(m_stringBuffer,
                                         stringsLength));
    return fixedLength + stringsLength;
}
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.

FileNameStrings& DybDaq::FileNameStrings::operator= ( FileNameStrings rhs) [private]

Suppress default.

void 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.

Definition at line 106 of file FileNameStrings.cc.

                                                            {
    unsigned int stringsLength = calculateStringsLength(application,
                                                        fileBase);
    if (0 != m_stringBuffer) {
        delete m_stringBuffer;
    }
    m_stringBuffer = new char[stringsLength];
    setSize(fileTraits().recordSize(FileTraits::kFileNameStrings) + (stringsLength / kBytesInInt));
    char* start = m_stringBuffer;
    start += writeString(application,
                         start);
    writeString(fileBase,
                start);
    if (0 != m_fileBase) {
        delete m_fileBase;
        m_fileBase = 0;
    }
    if (0 != m_application) {
        delete m_application;
        m_application = 0;
    }
}
string FileNameStrings::readString ( const char *  buffer) [static, private]

Reads string from binary representation.

Definition at line 130 of file FileNameStrings.cc.

                                                     {
    unsigned int length = *((unsigned int*)(buffer));
    char* base = new char[length + 1];
    memcpy(base,
           buffer + kBytesInInt,
           length);
    base[length] = 0;
    string result(base);
    delete base;
    return result;
}
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.

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.

                                               {
    return dynamic_cast<const FileTraits&>(daqTraits());
}
unsigned int FileBuffer::marker ( ) const [inherited]

Returns the marker for this FileBuffer.

Definition at line 44 of file FileBuffer.cc.

unsigned int FileBuffer::size ( ) const [inherited]

Returns the length of this record in 4-byte words.

Definition at line 48 of file FileBuffer.cc.

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.

                                          {
    return size();
}
void FileBuffer::setMarker ( const unsigned int  marker) [protected, inherited]

Sets the marker for this FileBuffer.

Definition at line 56 of file FileBuffer.cc.

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.


Member Data Documentation

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.

The buffer used to hold binary bytes of the metadata strings.

Definition at line 112 of file FileNameStrings.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:23 for FileReadoutFormat by doxygen 1.7.4