/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::DaqFromIStream Class Reference

#include <DaqFromIStream.h>

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

DaqFromIStream::~DaqFromIStream ( ) [virtual]

Destroys this instance.

Definition at line 33 of file DaqFromIStream.cc.

                                {
    delete m_daqFromBytes;
    if (0 != m_istream) {
        delete m_istream;
    }
}
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.

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

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;
}
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.

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

Opens this object for reading.

Definition at line 53 of file DaqFromIStream.cc.

                          {
    m_istream = openStream();
    return hasIStream();
}
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.

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