| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DybDaq::DaqContainer Class Reference

#include <DaqContainer.h>

Inheritance diagram for DybDaq::DaqContainer:

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

00064                             {
00065 }

DaqContainer::DaqContainer (  )  [protected]

Creates an instance of this class.

Definition at line 19 of file DaqContainer.cc.

00019                            :
00020 DaqBuffer(((char*)0),
00021           *((const DaqTraits*)0)),
00022 m_expandable(0),
00023 m_begin(0),
00024 m_bufferSize(0) {
00025 }

DaqContainer::DaqContainer ( const DaqContainer rhs  )  [protected]

Creates an instance of this class.

Definition at line 27 of file DaqContainer.cc.

00027                                                         :
00028 DaqBuffer(container),
00029 DaqExpandable(),
00030 m_expandable(0),
00031 m_begin(container.begin()),
00032 m_bufferSize(container.containerSize()) {
00033     // Currently assumes a ByteBuffer based DaqContainer is being copied.
00034 }

DaqContainer::DaqContainer ( DaqExpandable expandable  )  [protected]

Creates an instance of this class.

Definition at line 36 of file DaqContainer.cc.

00036                                                     :
00037 DaqBuffer(((char*)0),
00038           *((const DaqTraits*)0)),
00039 m_expandable(&expandable),
00040 m_begin(0),
00041 m_bufferSize(0) {
00042 }

DaqContainer::DaqContainer ( const ByteBuffer byteBuffer,
const unsigned int  bufferSize 
) [protected]

Creates an instance of this class.

Definition at line 45 of file DaqContainer.cc.

00046                                                           :
00047 DaqBuffer(byteBuffer,
00048           *((DaqTraits*)0)),
00049 m_expandable(0),
00050 m_begin(byteBuffer.position()),
00051 m_bufferSize(bufferSize) {
00052 }

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.

00056                                                           :
00057 DaqBuffer(byteBuffer,
00058           traits),
00059 m_expandable(0),
00060 m_begin(byteBuffer.position()),
00061 m_bufferSize(bufferSize) {
00062 }


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.

Definition at line 71 of file DaqContainer.cc.

00071                                                                        {
00072     return gatherComponents(outputBuffers);
00073 }

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.

00075                                                                    {
00076     return inspectComponents(inspectors);
00077 }

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.

00067                                        {
00068     return m_begin;
00069 }

unsigned int DaqContainer::containerSize (  )  const [protected]

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

Definition at line 79 of file DaqContainer.cc.

00079                                                {
00080     return m_bufferSize;
00081 }

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.

00083                                                           {
00084     if (0 != m_expandable) {
00085         return false;
00086     }
00087     m_expandable = &expandable;
00088     return true;
00089 }

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.

00091                                                            {
00092     if (0 != m_expandable) {
00093         m_expandable->expanded(size);
00094     }
00095 }

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.

00097                                                            {
00098     return (const_cast<RomData*>(romData))->setRomExpandable(*this);
00099 }

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.

00062                                    {
00063     return 0 != &daqTraits();
00064 }

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.

00066                                             {
00067     return *m_traits;
00068 }

unsigned int DaqBuffer::gather ( OutputBufferList outputBuffers  )  const [virtual, inherited]

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 107 of file DaqBuffer.cc.

00107                                                                     {
00108     const unsigned int result = bufferSize() * kBytesInInt;
00109     outputBuffers.push_back(OutputBuffer(m_buffer,
00110                                          result));
00111     return result;
00112 }

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.

00070                                     {
00071     return m_buffer;
00072 }

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

Returns the buffer containing the raw file data.

Definition at line 168 of file DaqBuffer.cc.

00168                         {
00169     return const_cast<char*>(m_buffer);
00170 }

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.

00074                                     {
00075     return 0 != m_byteBuffer;
00076 }

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.

00078                                               {
00079     return *m_byteBuffer;
00080 }

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.

00138                                                                   {
00139     const DybDaq::DaqTraits::Definitions& definitions = daqTraits().bitsDefinitions(component);
00140     ByteInspector::Bits* bitsInByte = 0;
00141     const DybDaq::DaqTraits::Definitions::const_iterator finished = definitions.end();
00142     for (DybDaq::DaqTraits::Definitions::const_iterator definition = definitions.begin();
00143          finished != definition;
00144          ++definition) {
00145         const DybDaq::BitsDefinition& bits = *definition;
00146         if (0 == bitsInByte || (bits.offset() != cursor)) {
00147             if (0 == bitsInByte && (cursor != bits.offset())) {
00148                 inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + cursor),
00149                                                        0));
00150             }
00151             while (((bits.offset() - cursor) > 1)) {
00152                 ++cursor;
00153                 inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + cursor),
00154                                                        0));
00155             }
00156             bitsInByte = new ByteInspector::Bits();
00157             cursor = bits.offset();
00158             inspectors.push_back(new ByteInspector(*(((unsigned int*)m_buffer) + bits.offset()),
00159                                                    bitsInByte));
00160         } 
00161         DybDaq::BitsInspector* bitInfo = new BitsInspector(readUnsignedInt(bits.field()),
00162                                                            bits);
00163         bitsInByte->push_back(bitInfo);
00164     }
00165     return cursor;
00166 }

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.

00082                                                        {
00083     unsigned int fourBytes = readUnsignedInt(field);
00084     return 0 != fourBytes;
00085 }

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.

00087                                                      {
00088     unsigned int fourBytes = readUnsignedInt(field);
00089     return *(int*)(&fourBytes);
00090 }

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.

00092                                                                         {
00093     unsigned int fourBytes = readUnsignedInt(field);
00094     return *(unsigned char*)(&fourBytes);
00095 }

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.

00097                                                                       {
00098     const DaqTraits& traits = daqTraits();
00099     unsigned int index = traits.index(field);
00100     if (index == traits.illegalField()) {
00101         return 0;
00102     }
00103     const unsigned int fourBytes = *(((unsigned int*)m_buffer) + index);
00104     return (fourBytes >> traits.shift(field)) & traits.mask(field);
00105 }

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.

00173                                                      {
00174     const DaqTraits& traits = daqTraits();
00175     unsigned int index = traits.index(field);
00176     if (index == traits.illegalField()) {
00177         return;
00178     }
00179     const unsigned int mask = traits.mask(field);
00180     const unsigned int cleared = (*(((unsigned int*)m_buffer) + index)) & (~mask);
00181     if (value) {
00182         *(((unsigned int*)m_buffer) + index) = cleared | mask;
00183     }
00184 }

void DaqBuffer::writeField ( const int  value,
const unsigned int  field 
) [protected, virtual, inherited]

Write the supplied value into the specified field.

Definition at line 186 of file DaqBuffer.cc.

00187                                                      {
00188     const DaqTraits& traits = daqTraits();
00189     unsigned int index = traits.index(field);
00190     if (index == traits.illegalField()) {
00191         return;
00192     }
00193     const unsigned int shift = traits.shift(field);
00194     const unsigned int mask = traits.mask(field) << shift;
00195     unsigned int* location = (((unsigned int*)m_buffer) + index);
00196     const unsigned int cleared = (*location) & (~mask);
00197     *location = cleared | ((value << shift) & mask);
00198 }

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 200 of file DaqBuffer.cc.

00201                                                      {
00202     const DaqTraits& traits = daqTraits();
00203     unsigned int index = traits.index(field);
00204     if (index == traits.illegalField()) {
00205         return;
00206     }
00207     const unsigned int shift = traits.shift(field);
00208     const unsigned int mask = traits.mask(field) << shift;
00209     unsigned int* location = (((unsigned int*)m_buffer) + index);
00210     const unsigned int cleared = (*location) & (~mask);
00211     *location = cleared | ((value << shift) & mask);
00212 }

unsigned int DaqBuffer::formatComponent (  )  const [protected, virtual, inherited]

Returns the component with the format of this buffer.

Definition at line 214 of file DaqBuffer.cc.

00214                                               {
00215     return kUndefinedFormatComponent;
00216 }

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

DaqExpandable* DybDaq::DaqContainer::m_expandable [private]

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 Mon Apr 11 20:07:43 2011 for DaqReadoutFormat by doxygen 1.4.7