/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 | Private Attributes | Friends
DybDaq::DaqContainer Class Reference

#include <DaqContainer.h>

Inheritance diagram for DybDaq::DaqContainer:
Inheritance graph
[legend]
Collaboration diagram for DybDaq::DaqContainer:
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

virtual ~DaqContainer ()
 Destroy this instance of the class.
virtual unsigned int gather (OutputBufferList &outputBuffers) const
 Adds to the supplied line the OutputBuffers that contain the DAQ format of this objects content returning the total number of bytes in the added buffers.
virtual unsigned int inspect (DaqBuffer::Bytes &inspectors) const
 Adds to the supplied list the DaqBuffer::Bytes that contains inspections of this object's objects.
bool hasDaqTraits () const
 Returns true if this object has a DaqTraits associated with it.
virtual const DaqTraitsdaqTraits () const
 Returns the DaqTraits instance used to parse this object's buffer.
virtual unsigned int bufferSize () const =0
 Returns the size, in 4-bytes, of this ojbect's contents in the buffer.

Static Public Attributes

static const unsigned int kBytesInInt = 4
static const unsigned int kUndefinedFormatComponent = 0xffffffff

Protected Member Functions

 DaqContainer ()
 Creates an instance of this class.
 DaqContainer (const DaqContainer &rhs)
 Creates an instance of this class.
 DaqContainer (DaqExpandable &expandable)
 Creates an instance of this class.
 DaqContainer (const ByteBuffer &byteBuffer, const unsigned int bufferSize)
 Creates an instance of this class.
 DaqContainer (const ByteBuffer &byteBuffer, const DaqTraits &traits, const unsigned int bufferSize)
 Creates an instance of this class.
unsigned int begin () const
 Returns the position in the ByteBuffer, if there is one, that this the beginning of this object's buffer.
unsigned int containerSize () const
 The pre-specified size, if any, of this container.
virtual unsigned int gatherComponents (OutputBufferList &outputBuffers) const =0
 Gathers the DAQ formatted bytes for this object's components.
virtual unsigned int inspectComponents (DaqBuffer::Bytes &inspectors) const =0
 Inspects the DAQ formatted bytes for this object's components.
bool setExpandable (DaqExpandable &expandable)
 Associates the supplied DaqExpanable with this object if it is not already associated with one.
void notifyExpandable (const unsigned int size)
 Notifies any associated DaqExpandable that this object has expanded by the specified ammount.
bool expandedByRomData (const RomData *romData)
 Associates this object with the supplied RomData object if it is not already associated with one.
const char * buffer () const
 Returns the buffer containing the raw file data.
char * buffer ()
 Returns the buffer containing the raw file data.
bool hasByteBuffer () const
 Returns true if this object has a ByteBuffer associated with it.
const ByteBufferbyteBuffer () const
 Returns the buffer, if there is one, containing the raw file data.
unsigned int fillInspectors (DaqBuffer::Bytes &inspectors, unsigned int component, unsigned int cursor) const
 Fills the supplied DaqBuffer::Bytes using the specified component.
virtual bool readBool (const unsigned int field) const
 Returns the value in the specified field as a bool.
virtual int readInt (const unsigned int field) const
 Returns the value in the specified field as an signed int.
virtual unsigned char readUnsignedChar (const unsigned int field) const
 Returns the value in the specified field as an unsigned char.
virtual unsigned int readUnsignedInt (const unsigned int field) const
 Returns the value in the specified field as an unsigned int.
virtual void writeField (const bool value, const unsigned int field)
 Write the supplied value into the specified field.
virtual void writeField (const int value, const unsigned int field)
 Write the supplied value into the specified field.
virtual void writeField (const unsigned int value, const unsigned int field)
 Write the supplied value into the specified field.
virtual unsigned int formatComponent () const
 Returns the component with the format of this buffer.
virtual void expanded (const unsigned int size)=0
 Tells this object that its contents has expanded by the specified number of bytes.

Private Member Functions

DaqContaineroperator= (const DaqContainer &rhs)
 Suppress default.

Private Attributes

DaqExpandablem_expandable
 The DaqExpandable, if any, associated with this object.
unsigned int m_begin
 The position in the ByteBuffer, if there is one, that this the beginning of this object's buffer.
unsigned int m_bufferSize
 The total number of byte that this container covers in the buffer.

Friends

class DaqContainer

Detailed Description

Definition at line 22 of file DaqContainer.h.


Member Typedef Documentation

typedef std::pair<const char*, unsigned int> DybDaq::DaqBuffer::OutputBuffer [inherited]

Definition at line 27 of file DaqBuffer.h.

typedef std::vector<OutputBuffer> DybDaq::DaqBuffer::OutputBufferList [inherited]

Definition at line 28 of file DaqBuffer.h.

typedef std::vector<ByteInspector*> DybDaq::DaqBuffer::Bytes [inherited]

Definition at line 29 of file DaqBuffer.h.

typedef std::vector<BitsInspector*> DybDaq::DaqBuffer::Bits [inherited]

Definition at line 30 of file DaqBuffer.h.


Constructor & Destructor Documentation

DaqContainer::~DaqContainer ( ) [virtual]

Destroy this instance of the class.

Definition at line 64 of file DaqContainer.cc.

                            {
}
DaqContainer::DaqContainer ( ) [protected]

Creates an instance of this class.

Definition at line 19 of file DaqContainer.cc.

                           :
DaqBuffer(((char*)0),
          *((const DaqTraits*)0)),
m_expandable(0),
m_begin(0),
m_bufferSize(0) {
}
DaqContainer::DaqContainer ( const DaqContainer rhs) [protected]

Creates an instance of this class.

Definition at line 27 of file DaqContainer.cc.

                                                        :
DaqBuffer(container),
DaqExpandable(),
m_expandable(0),
m_begin(container.begin()),
m_bufferSize(container.containerSize()) {
    // Currently assumes a ByteBuffer based DaqContainer is being copied.
}
DaqContainer::DaqContainer ( DaqExpandable expandable) [protected]

Creates an instance of this class.

Definition at line 36 of file DaqContainer.cc.

                                                    :
DaqBuffer(((char*)0),
          *((const DaqTraits*)0)),
m_expandable(&expandable),
m_begin(0),
m_bufferSize(0) {
}
DaqContainer::DaqContainer ( const ByteBuffer byteBuffer,
const unsigned int  bufferSize 
) [protected]

Creates an instance of this class.

Definition at line 45 of file DaqContainer.cc.

                                                          :
DaqBuffer(byteBuffer,
          *((DaqTraits*)0)),
m_expandable(0),
m_begin(byteBuffer.position()),
m_bufferSize(bufferSize) {
}
DaqContainer::DaqContainer ( const ByteBuffer byteBuffer,
const DaqTraits traits,
const unsigned int  bufferSize 
) [protected]

Creates an instance of this class.

Definition at line 54 of file DaqContainer.cc.

                                                          :
DaqBuffer(byteBuffer,
          traits),
m_expandable(0),
m_begin(byteBuffer.position()),
m_bufferSize(bufferSize) {
}

Member Function Documentation

unsigned int DaqContainer::gather ( OutputBufferList outputBuffers) const [virtual]

Adds to the supplied line the OutputBuffers that contain the DAQ format of this objects content returning the total number of bytes in the added buffers.

Reimplemented from DybDaq::DaqBuffer.

Definition at line 71 of file DaqContainer.cc.

                                                                       {
    return gatherComponents(outputBuffers);
}
unsigned int DaqContainer::inspect ( DaqBuffer::Bytes inspectors) const [virtual]

Adds to the supplied list the DaqBuffer::Bytes that contains inspections of this object's objects.

Reimplemented from DybDaq::DaqBuffer.

Definition at line 75 of file DaqContainer.cc.

                                                                   {
    return inspectComponents(inspectors);
}
unsigned int DaqContainer::begin ( ) const [protected]

Returns the position in the ByteBuffer, if there is one, that this the beginning of this object's buffer.

Definition at line 67 of file DaqContainer.cc.

                                       {
    return m_begin;
}
unsigned int DaqContainer::containerSize ( ) const [protected]

The pre-specified size, if any, of this container.

Definition at line 79 of file DaqContainer.cc.

                                               {
    return m_bufferSize;
}
virtual unsigned int DybDaq::DaqContainer::gatherComponents ( OutputBufferList outputBuffers) const [protected, pure virtual]

Gathers the DAQ formatted bytes for this object's components.

virtual unsigned int DybDaq::DaqContainer::inspectComponents ( DaqBuffer::Bytes inspectors) const [protected, pure virtual]

Inspects the DAQ formatted bytes for this object's components.

bool DaqContainer::setExpandable ( DaqExpandable expandable) [protected]

Associates the supplied DaqExpanable with this object if it is not already associated with one.

It returns true if the association is successful, false otherwise.

Definition at line 83 of file DaqContainer.cc.

                                                          {
    if (0 != m_expandable) {
        return false;
    }
    m_expandable = &expandable;
    return true;
}
void DaqContainer::notifyExpandable ( const unsigned int  size) [protected]

Notifies any associated DaqExpandable that this object has expanded by the specified ammount.

Definition at line 91 of file DaqContainer.cc.

                                                           {
    if (0 != m_expandable) {
        m_expandable->expanded(size);
    }
}
bool DaqContainer::expandedByRomData ( const RomData romData) [protected]

Associates this object with the supplied RomData object if it is not already associated with one.

It returns true if the association is successful, false otherwise.

Definition at line 97 of file DaqContainer.cc.

                                                           {
    return (const_cast<RomData*>(romData))->setRomExpandable(*this);
}
DaqContainer& DybDaq::DaqContainer::operator= ( const DaqContainer rhs) [private]

Suppress default.

bool DaqBuffer::hasDaqTraits ( ) const [inherited]

Returns true if this object has a DaqTraits associated with it.

Definition at line 62 of file DaqBuffer.cc.

                                   {
    return 0 != &daqTraits();
}
const DaqTraits & DaqBuffer::daqTraits ( ) const [virtual, inherited]

Returns the DaqTraits instance used to parse this object's buffer.

Definition at line 66 of file DaqBuffer.cc.

                                            {
    return *m_traits;
}
virtual unsigned int DybDaq::DaqBuffer::bufferSize ( ) const [pure virtual, inherited]

Returns the size, in 4-bytes, of this ojbect's contents in the buffer.

const char * DaqBuffer::buffer ( ) const [protected, inherited]

Returns the buffer containing the raw file data.

Definition at line 70 of file DaqBuffer.cc.

                                    {
    return m_buffer;
}
char * DaqBuffer::buffer ( ) [protected, inherited]

Returns the buffer containing the raw file data.

Definition at line 168 of file DaqBuffer.cc.

                        {
    return const_cast<char*>(m_buffer);
}
bool DaqBuffer::hasByteBuffer ( ) const [protected, inherited]

Returns true if this object has a ByteBuffer associated with it.

Definition at line 74 of file DaqBuffer.cc.

                                    {
    return 0 != m_byteBuffer;
}
const ByteBuffer & DaqBuffer::byteBuffer ( ) const [protected, inherited]

Returns the buffer, if there is one, containing the raw file data.

Definition at line 78 of file DaqBuffer.cc.

                                              {
    return *m_byteBuffer;
}
unsigned int DaqBuffer::fillInspectors ( DaqBuffer::Bytes inspectors,
unsigned int  component,
unsigned int  cursor 
) const [protected, inherited]

Fills the supplied DaqBuffer::Bytes using the specified component.

Definition at line 136 of file DaqBuffer.cc.

                                                                  {
    const DybDaq::DaqTraits::Definitions& definitions = daqTraits().bitsDefinitions(component);
    ByteInspector::Bits* bitsInByte = 0;
    const DybDaq::DaqTraits::Definitions::const_iterator finished = definitions.end();
    for (DybDaq::DaqTraits::Definitions::const_iterator definition = definitions.begin();
         finished != definition;
         ++definition) {
        const DybDaq::BitsDefinition& bits = *definition;
        if (0 == bitsInByte || (bits.offset() != cursor)) {
            if (0 == bitsInByte && (cursor != bits.offset())) {
                inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + cursor),
                                                       0));
            }
            while (((bits.offset() - cursor) > 1)) {
                ++cursor;
                inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + cursor),
                                                       0));
            }
            bitsInByte = new ByteInspector::Bits();
            cursor = bits.offset();
            inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + bits.offset()),
                                                   bitsInByte));
        } 
        DybDaq::BitsInspector* bitInfo = new BitsInspector(readUnsignedInt(bits.field()),
                                                           bits);
        bitsInByte->push_back(bitInfo);
    }
    return cursor;
}
bool DaqBuffer::readBool ( const unsigned int  field) const [protected, virtual, inherited]

Returns the value in the specified field as a bool.

Definition at line 82 of file DaqBuffer.cc.

                                                       {
    unsigned int fourBytes = readUnsignedInt(field);
    return 0 != fourBytes;
}
int DaqBuffer::readInt ( const unsigned int  field) const [protected, virtual, inherited]

Returns the value in the specified field as an signed int.

Definition at line 87 of file DaqBuffer.cc.

                                                     {
    unsigned int fourBytes = readUnsignedInt(field);
    return *(int*)(&fourBytes);
}
unsigned char DaqBuffer::readUnsignedChar ( const unsigned int  field) const [protected, virtual, inherited]

Returns the value in the specified field as an unsigned char.

Definition at line 92 of file DaqBuffer.cc.

                                                                        {
    unsigned int fourBytes = readUnsignedInt(field);
    return *(unsigned char*)(&fourBytes);
}
unsigned int DaqBuffer::readUnsignedInt ( const unsigned int  field) const [protected, virtual, inherited]

Returns the value in the specified field as an unsigned int.

Definition at line 97 of file DaqBuffer.cc.

                                                                      {
    const DaqTraits& traits = daqTraits();
    unsigned int index = traits.index(field);
    if (index == traits.illegalField()) {
        return 0;
    }
    const unsigned int fourBytes = *(((unsigned int*)m_buffer) + index);
    return (fourBytes >> traits.shift(field)) & traits.mask(field);
}
void DaqBuffer::writeField ( const bool  value,
const unsigned int  field 
) [protected, virtual, inherited]

Write the supplied value into the specified field.

Definition at line 172 of file DaqBuffer.cc.

                                                     {
    const DaqTraits& traits = daqTraits();
    unsigned int index = traits.index(field);
    if (index == traits.illegalField()) {
        return;
    }
    const unsigned int shift = traits.shift(field);
    const unsigned int mask = traits.mask(field) << shift;
    const unsigned int cleared = (*(((unsigned int*)m_buffer) + index)) & (~mask);
    if (value) {
        *(((unsigned int*)m_buffer) + index) = cleared | mask;
    }
}
void DaqBuffer::writeField ( const int  value,
const unsigned int  field 
) [protected, virtual, inherited]

Write the supplied value into the specified field.

Definition at line 187 of file DaqBuffer.cc.

                                                     {
    const DaqTraits& traits = daqTraits();
    unsigned int index = traits.index(field);
    if (index == traits.illegalField()) {
        return;
    }
    const unsigned int shift = traits.shift(field);
    const unsigned int mask = traits.mask(field) << shift;
    unsigned int* location = (((unsigned int*)m_buffer) + index);
    const unsigned int cleared = (*location) & (~mask);
    *location = cleared | ((value << shift) & mask);
}
void DaqBuffer::writeField ( const unsigned int  value,
const unsigned int  field 
) [protected, virtual, inherited]

Write the supplied value into the specified field.

Definition at line 201 of file DaqBuffer.cc.

                                                     {
    const DaqTraits& traits = daqTraits();
    unsigned int index = traits.index(field);
    if (index == traits.illegalField()) {
        return;
    }
    const unsigned int shift = traits.shift(field);
    const unsigned int mask = traits.mask(field) << shift;
    unsigned int* location = (((unsigned int*)m_buffer) + index);
    const unsigned int cleared = (*location) & (~mask);
    *location = cleared | ((value << shift) & mask);
}
unsigned int DaqBuffer::formatComponent ( ) const [protected, virtual, inherited]

Returns the component with the format of this buffer.

Definition at line 215 of file DaqBuffer.cc.

virtual void DybDaq::DaqExpandable::expanded ( const unsigned int  size) [protected, pure virtual, inherited]

Tells this object that its contents has expanded by the specified number of bytes.


Friends And Related Function Documentation

friend class DaqContainer [friend, inherited]

Definition at line 23 of file DaqExpandable.h.


Member Data Documentation

The DaqExpandable, if any, associated with this object.

Definition at line 121 of file DaqContainer.h.

unsigned int DybDaq::DaqContainer::m_begin [private]

The position in the ByteBuffer, if there is one, that this the beginning of this object's buffer.

Definition at line 127 of file DaqContainer.h.

unsigned int DybDaq::DaqContainer::m_bufferSize [private]

The total number of byte that this container covers in the buffer.

Definition at line 132 of file DaqContainer.h.

const unsigned int DaqBuffer::kBytesInInt = 4 [static, inherited]

Definition at line 32 of file DaqBuffer.h.

const unsigned int DaqBuffer::kUndefinedFormatComponent = 0xffffffff [static, inherited]

Definition at line 33 of file DaqBuffer.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:52:49 for DaqReadoutFormat by doxygen 1.7.4