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

In This Package:

DybDaq::DaqFromStrStream Class Reference

#include <DaqFromStrStream.h>

Inheritance diagram for DybDaq::DaqFromStrStream:

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

Public Member Functions

 DaqFromStrStream ()
 Creates an instance of this class.
virtual ~DaqFromStrStream ()
 Destroys this instance.
const bool openWithString (const std::string &contents)
 Opens the specified file for reading.
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)
 Used to close the istream that is backing this class.
virtual std::istream * openStream ()
 Used to open a new stream that is used as the backing of this class.
bool hasIStream () const
 Returns true when this object has a valid ostream.
bool open ()
 Opens this object for reading.

Private Member Functions

 DaqFromStrStream (DaqFromStrStream &rhs)
 Suppress default.
DaqFromStrStreamoperator= (DaqFromStrStream &rhs)
 Suppress default.

Private Attributes

std::string * m_contents
 The content of the string stream to be used.
std::istringstream * m_stringstream
 The string stream being read.

Detailed Description

Definition at line 19 of file DaqFromStrStream.h.


Constructor & Destructor Documentation

DaqFromStrStream::DaqFromStrStream (  ) 

Creates an instance of this class.

Definition at line 20 of file DaqFromStrStream.cc.

00020                                    :
00021   m_contents(0),
00022   m_stringstream(0) {
00023 }

DaqFromStrStream::~DaqFromStrStream (  )  [virtual]

Destroys this instance.

Definition at line 25 of file DaqFromStrStream.cc.

00025                                     {
00026     // deleting m_stringstream taken care by superclass.
00027     if (0 != m_contents) {
00028         delete m_contents;
00029     }
00030 }

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

Suppress default.


Member Function Documentation

const bool DybDaq::DaqFromStrStream::openWithString ( const std::string &  contents  ) 

Opens the specified file for reading.

void DaqFromStrStream::closeStream ( std::istream &  stream  )  [protected, virtual]

Used to close the istream that is backing this class.

Implements DybDaq::DaqFromIStream.

Definition at line 37 of file DaqFromStrStream.cc.

00037                                                            {
00038     // deleting m_stringStream taken care by superclass.
00039     m_stringstream = 0;
00040 }

std::istream * DaqFromStrStream::openStream (  )  [protected, virtual]

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

Implements DybDaq::DaqFromIStream.

Definition at line 32 of file DaqFromStrStream.cc.

00032                                          {
00033     m_stringstream = new istringstream(*m_contents);
00034     return m_stringstream;
00035 }

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

Suppress default.

bool DaqFromIStream::close (  )  [inherited]

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 (  )  [inherited]

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 }

bool DaqFromIStream::hasIStream (  )  const [protected, inherited]

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, inherited]

Opens this object for reading.

Definition at line 53 of file DaqFromIStream.cc.

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


Member Data Documentation

std::string* DybDaq::DaqFromStrStream::m_contents [private]

The content of the string stream to be used.

Definition at line 65 of file DaqFromStrStream.h.

std::istringstream* DybDaq::DaqFromStrStream::m_stringstream [private]

The string stream being read.

Definition at line 70 of file DaqFromStrStream.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