/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DybDaq::DaqFromStrStream Class Reference

#include <DaqFromStrStream.h>

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

                                   :
  m_contents(0),
  m_stringstream(0) {
}
DaqFromStrStream::~DaqFromStrStream ( ) [virtual]

Destroys this instance.

Definition at line 25 of file DaqFromStrStream.cc.

                                    {
    // deleting m_stringstream taken care by superclass.
    if (0 != m_contents) {
        delete m_contents;
    }
}
DybDaq::DaqFromStrStream::DaqFromStrStream ( DaqFromStrStream rhs) [private]

Suppress default.


Member Function Documentation

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

Opens the specified file for reading.

Definition at line 42 of file DaqFromStrStream.cc.

                                                                  {
    if (0 != m_contents) {
        delete m_contents;
    }
    m_contents = new string(contents);
    return open();
}
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.

                                                {
    // deleting m_stringStream taken care by superclass.
    m_stringstream = 0;
}
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.

                                         {
    m_stringstream = new istringstream(*m_contents);
    return m_stringstream;
}
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.

                           {
    if (0 != m_istream) {
        closeStream(*m_istream);
        delete m_istream;
        m_istream = 0;
    }
    return true;
}
const FileBuffer * DaqFromIStream::nextRecord ( ) [virtual, inherited]

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

Implements DybDaq::DaqFromStream.

Definition at line 58 of file DaqFromIStream.cc.

                                             {
        ByteBuffer* buffer = new ByteBuffer(new char[DEFAULT_BUFFER_SIZE],
                                        DEFAULT_BUFFER_SIZE);
        m_istream->read(buffer->cursor(),
                   2 * ByteBuffer::BYTES_IN_INT);
        if (m_istream->eof()) {
                return 0;
        }
        
        unsigned int size = buffer->readUnsignedInt(4);
        unsigned int lengthInBytes = size * ByteBuffer::BYTES_IN_INT;
        const FileBuffer* result = 0;
    unsigned int begin = 0;
        while (0 == result && buffer->capacity() != lengthInBytes) {
                if (lengthInBytes > buffer->capacity()) {
                        ByteBuffer* previousBuffer = buffer;
                        buffer = new ByteBuffer(new char[lengthInBytes],
                                                                        lengthInBytes);
                        unsigned int bytesRead = previousBuffer->limit();
            previousBuffer->position(begin);
                        memcpy(buffer->cursor(),
                                   previousBuffer->cursor(),
                                   bytesRead);
                        buffer->limit(bytesRead);
            previousBuffer->release();
                }
                unsigned int bytesRead = buffer->limit();
                m_istream->read(buffer->cursor() + bytesRead,
                       buffer->capacity() - bytesRead);
                buffer->limit(buffer->capacity());
        begin = buffer->position();
                result = m_daqFromBytes->createFileBuffer(buffer);
                if (0 == result) {
                        lengthInBytes = m_daqFromBytes->additionalCapacity() + buffer->capacity();
                }
        }
        return result;
}
bool DaqFromIStream::hasIStream ( ) const [protected, inherited]

Returns true when this object has a valid ostream.

Definition at line 49 of file DaqFromIStream.cc.

                                      {
    return 0 != m_istream;
}
bool DaqFromIStream::open ( ) [protected, inherited]

Opens this object for reading.

Definition at line 53 of file DaqFromIStream.cc.

                          {
    m_istream = openStream();
    return hasIStream();
}

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 Fri May 16 2014 09:53:22 for FileReadoutFormat by doxygen 1.7.4