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

In This Package:

DybDaq::DaqFromIStream Class Reference

#include <DaqFromIStream.h>

Inheritance diagram for DybDaq::DaqFromIStream:

[legend]
Collaboration diagram for DybDaq::DaqFromIStream:
[legend]
List of all members.

Public Member Functions

 DaqFromIStream ()
 Creates an instance of this class.
virtual ~DaqFromIStream ()
 Destroys this instance.
bool close ()
 Closes the current Stream being read.
const FileBuffernextRecord ()
 Returns the next record in the file of NULL is the end of the file has been reached.

Protected Member Functions

virtual void closeStream (std::istream &stream)=0
 Used to close the istream that is backing this class.
bool hasIStream () const
 Returns true when this object has a valid ostream.
bool open ()
 Opens this object for reading.
virtual std::istream * openStream ()=0
 Used to open a new stream that is used as the backing of this class.

Private Member Functions

 DaqFromIStream (DaqFromIStream &rhs)
 Suppress default.
DaqFromIStreamoperator= (DaqFromIStream &rhs)
 Suppress default.

Private Attributes

std::istream * m_istream
 The stream being read from.
DybDaq::DaqFormatFromBytesm_daqFromBytes
 The DaqFormatFromBytes used to parse the contents of the file.

Detailed Description

Definition at line 23 of file DaqFromIStream.h.


Constructor & Destructor Documentation

DaqFromIStream::DaqFromIStream (  ) 

Creates an instance of this class.

Definition at line 28 of file DaqFromIStream.cc.

00028                                :
00029   m_istream(0),
00030   m_daqFromBytes(new DaqFormatFromBytes()) {
00031 }

DaqFromIStream::~DaqFromIStream (  )  [virtual]

Destroys this instance.

Definition at line 33 of file DaqFromIStream.cc.

00033                                 {
00034     delete m_daqFromBytes;
00035     if (0 != m_istream) {
00036         delete m_istream;
00037     }
00038 }

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

Suppress default.


Member Function Documentation

bool DaqFromIStream::close (  ) 

Closes the current Stream being read.

Definition at line 40 of file DaqFromIStream.cc.

00040                            {
00041     if (0 != m_istream) {
00042         closeStream(*m_istream);
00043         delete m_istream;
00044         m_istream = 0;
00045     }
00046     return true;
00047 }

const FileBuffer * DaqFromIStream::nextRecord (  ) 

Returns the next record in the file of NULL is the end of the file has been reached.

Definition at line 58 of file DaqFromIStream.cc.

00058                                              {
00059         ByteBuffer* buffer = new ByteBuffer(new char[DEFAULT_BUFFER_SIZE],
00060                                         DEFAULT_BUFFER_SIZE);
00061         m_istream->read(buffer->cursor(),
00062                    2 * ByteBuffer::BYTES_IN_INT);
00063         if (m_istream->eof()) {
00064                 return 0;
00065         }
00066         
00067         unsigned int size = buffer->readUnsignedInt(4);
00068         unsigned int lengthInBytes = size * ByteBuffer::BYTES_IN_INT;
00069         const FileBuffer* result = 0;
00070     unsigned int begin = 0;
00071         while (0 == result && buffer->capacity() != lengthInBytes) {
00072                 if (lengthInBytes > buffer->capacity()) {
00073                         ByteBuffer* previousBuffer = buffer;
00074                         buffer = new ByteBuffer(new char[lengthInBytes],
00075                                                                         lengthInBytes);
00076                         unsigned int bytesRead = previousBuffer->limit();
00077             previousBuffer->position(begin);
00078                         memcpy(buffer->cursor(),
00079                                    previousBuffer->cursor(),
00080                                    bytesRead);
00081                         buffer->limit(bytesRead);
00082             previousBuffer->release();
00083                 }
00084                 unsigned int bytesRead = buffer->limit();
00085                 m_istream->read(buffer->cursor() + bytesRead,
00086                        buffer->capacity() - bytesRead);
00087                 buffer->limit(buffer->capacity());
00088         begin = buffer->position();
00089                 result = m_daqFromBytes->createFileBuffer(buffer);
00090                 if (0 == result) {
00091                         lengthInBytes = m_daqFromBytes->additionalCapacity() + buffer->capacity();
00092                 }
00093         }
00094         return result;
00095 }

virtual void DybDaq::DaqFromIStream::closeStream ( std::istream &  stream  )  [protected, pure virtual]

Used to close the istream that is backing this class.

Implemented in DybDaq::DaqFromFStream, and DybDaq::DaqFromStrStream.

bool DaqFromIStream::hasIStream (  )  const [protected]

Returns true when this object has a valid ostream.

Definition at line 49 of file DaqFromIStream.cc.

00049                                       {
00050     return 0 != m_istream;
00051 }

bool DaqFromIStream::open (  )  [protected]

Opens this object for reading.

Definition at line 53 of file DaqFromIStream.cc.

00053                           {
00054     m_istream = openStream();
00055     return hasIStream();
00056 }

virtual std::istream* DybDaq::DaqFromIStream::openStream (  )  [protected, pure virtual]

Used to open a new stream that is used as the backing of this class.

Implemented in DybDaq::DaqFromFStream, and DybDaq::DaqFromStrStream.

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

Suppress default.


Member Data Documentation

std::istream* DybDaq::DaqFromIStream::m_istream [private]

The stream being read from.

Definition at line 85 of file DaqFromIStream.h.

DybDaq::DaqFormatFromBytes* DybDaq::DaqFromIStream::m_daqFromBytes [private]

The DaqFormatFromBytes used to parse the contents of the file.

Definition at line 90 of file DaqFromIStream.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:08:34 2011 for FileReadoutFormat by doxygen 1.4.7