/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::MetadataStrings Class Reference

#include <MetadataStrings.h>

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

List of all members.

Public Types

typedef std::pair< std::string,
std::string > 
MetadataString
typedef std::vector< const
MetadataString * > 
MetadataStringPtrList
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

 MetadataStrings (const MetadataStringPtrList &metadataStrings, const FileTraits &traits)
 Create an instance of this class.
 MetadataStrings (const DybDaq::ByteBuffer &byteBuffer, const FileTraits &traits)
 Create an instance of this class.
virtual ~MetadataStrings ()
 Destroy this instance of the class.
virtual bool isMarked (unsigned int marker) const
 Returns true if this object contains the specified marker.
const MetadataStringPtrListmetadataStrings () const
 Returns the list of pointers to metadata strings.
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

 MetadataStrings ()
 Suppress default.
 MetadataStrings (MetadataStrings &rhs)
 Suppress default.
MetadataStringsoperator= (MetadataStrings &rhs)
 Suppress default.
void setMetadataStrings (const MetadataStringPtrList &metadataStrings)
 Sets the list of pointers to metadata strings.

Static Private Member Functions

static std::string readString (const char *buffer)
 Reads string from binary representation.
static unsigned int calculateStringsLength (const MetadataStringPtrList &metadataStrings)
 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

MetadataStringPtrListm_strings
 The tag/value pairs of the metadata strings.
char * m_stringBuffer
 The buffer used to hold binary bytes of the metadata strings.

Detailed Description

Definition at line 19 of file MetadataStrings.h.


Member Typedef Documentation

typedef std::pair<std::string, std::string> DybDaq::MetadataStrings::MetadataString

Definition at line 23 of file MetadataStrings.h.

Definition at line 24 of file MetadataStrings.h.


Constructor & Destructor Documentation

MetadataStrings::MetadataStrings ( const MetadataStringPtrList metadataStrings,
const FileTraits traits 
)

Create an instance of this class.

Definition at line 21 of file MetadataStrings.cc.

MetadataStrings::MetadataStrings ( const DybDaq::ByteBuffer byteBuffer,
const FileTraits traits 
)

Create an instance of this class.

Definition at line 31 of file MetadataStrings.cc.

                                                                                           :
FileBuffer(byteBuffer,
                   traits),
m_strings(0),
m_stringBuffer(0) {
}
MetadataStrings::~MetadataStrings ( ) [virtual]

Destroy this instance of the class.

Definition at line 39 of file MetadataStrings.cc.

                                  {
    if (0 != m_stringBuffer) {
        delete m_stringBuffer;
    }
        if (0 != m_strings) {
                MetadataStringPtrList::const_iterator entry;
                for (entry = m_strings->begin();
                         entry != m_strings->end();
                         ++entry) {
                        delete const_cast<MetadataString*>(*entry);
                }
                delete m_strings;
        }
}
DybDaq::MetadataStrings::MetadataStrings ( ) [private]

Suppress default.

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

Suppress default.


Member Function Documentation

bool MetadataStrings::isMarked ( unsigned int  marker) const [virtual]

Returns true if this object contains the specified marker.

Implements DybDaq::FileBuffer.

Definition at line 54 of file MetadataStrings.cc.

const MetadataStrings::MetadataStringPtrList & MetadataStrings::metadataStrings ( ) const

Returns the list of pointers to metadata strings.

Definition at line 58 of file MetadataStrings.cc.

                                                                                   {
    if (0 == m_strings) {
        m_strings = new MetadataStringPtrList();
        const unsigned int finished = readUnsignedInt(FileTraits::kMetadataCount);
        const char* start;
        if (hasByteBuffer()) {
            start = buffer() + (fileTraits().firstMetadataLengthOffset() * kBytesInInt);
        } else {
            start = m_stringBuffer;
        }
        for (unsigned int metadata = 0;
             metadata != finished ;
             ++metadata) {
            string entry = readString(start);
            const unsigned int length = entry.size();
            const unsigned int paddedLength = length + (kBytesInInt - 1) - ((length - 1) % kBytesInInt );
            start += paddedLength + kBytesInInt;
            size_t found = entry.find('=');
            if (found != string::npos) {
                string first = entry.substr(0,
                                            found);
                string second = entry.substr(found + 1, length - (found + 1));
                m_strings->push_back(new MetadataString(first,
                                                        second));
            }
        }
    }
        return *m_strings;
}
unsigned int MetadataStrings::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 88 of file MetadataStrings.cc.

                                                                          {
    if (hasByteBuffer()) {
        return FileBuffer::gather(outputBuffers);
    }
    const unsigned int fixedLength = fileTraits().recordSize(FileTraits::kMetadataStrings) * 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 MetadataStrings::formatComponent ( ) const [protected, virtual]

Returns the component with the format of this buffer.

Reimplemented from DybDaq::DaqBuffer.

Definition at line 101 of file MetadataStrings.cc.

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

Suppress default.

void MetadataStrings::setMetadataStrings ( const MetadataStringPtrList metadataStrings) [private]

Sets the list of pointers to metadata strings.

Definition at line 105 of file MetadataStrings.cc.

                                                                                     {
    if (0 != m_stringBuffer) {
        delete m_stringBuffer;
    }
    unsigned int stringsLength = calculateStringsLength(metadataStrings);
    setSize(fileTraits().recordSize(FileTraits::kMetadataStrings) + (stringsLength / kBytesInInt));
    m_stringBuffer = new char[stringsLength];
    char* start = m_stringBuffer;
    MetadataStrings::MetadataStringPtrList::const_iterator metadata;
    for (metadata = metadataStrings.begin();
         metadata != metadataStrings.end();
         ++metadata) {
        const string entry = (*metadata)->first + "=" + (*metadata)->second;
        start += writeString(entry,
                             start);
    }
    writeField((unsigned int)(metadataStrings.size()),
               FileTraits::kMetadataCount);
    if (0 != m_strings) {
        delete m_strings;
        m_strings = 0;
    }
}
string MetadataStrings::readString ( const char *  buffer) [static, private]

Reads string from binary representation.

Definition at line 129 of file MetadataStrings.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;
}
unsigned int MetadataStrings::calculateStringsLength ( const MetadataStringPtrList metadataStrings) [static, private]

Calculates, in bytes, the length os the totoal binary representation.

Definition at line 142 of file FileNameStrings.cc.

                                                                            {
    unsigned int result = 0;
    unsigned int length = application.size();
    unsigned int paddedLength = length + (kBytesInInt - 1) - ((length - 1) % kBytesInInt );
    result += paddedLength + kBytesInInt;        
    length = fileBase.size();
    paddedLength = length + (kBytesInInt - 1) - ((length - 1) % kBytesInInt );
    result += paddedLength + kBytesInInt;        
    return result;
}
unsigned int MetadataStrings::writeString ( const std::string &  value,
char *  buffer 
) [static, private]

Reads string into binary representation.

Definition at line 154 of file FileNameStrings.cc.

                                                        {
    unsigned int length = value.size();
    char* start = buffer;
    *((unsigned int*)(start)) = length;
    start += kBytesInInt;
    memcpy(start,
           value.data(),
           length);
    unsigned int padding = (kBytesInInt - 1) - ((length - 1) % kBytesInInt );
    start += length;
    for (unsigned int index = 0;
         index != padding;
         ++index) {
        *start = ' ';
        ++start;
    }
    return kBytesInInt + length + padding;
}
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

The tag/value pairs of the metadata strings.

Definition at line 107 of file MetadataStrings.h.

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

Definition at line 112 of file MetadataStrings.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