OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ProximLROutputBuffer Class Reference

#include <ProximLineReader.hh>

Inheritance diagram for ProximLROutputBuffer:
Inheritance graph
Collaboration diagram for ProximLROutputBuffer:
Collaboration graph

Public Member Functions

 ProximLROutputBuffer (ProximLineReader *lineReader)
 
virtual ~ProximLROutputBuffer ()
 

Protected Member Functions

int overflow (int)
 
int sync ()
 

Private Member Functions

void flushBuffer ()
 

Private Attributes

ProximLineReaderlineReader_
 
const unsigned int BUFFER_SIZE
 

Detailed Description

Stream buffer for the ProximLROutputStream.

This streambuffer converts the stream output to SimulatorEvents when the buffer cotnetnts is flushed.

Definition at line 116 of file ProximLineReader.hh.

Constructor & Destructor Documentation

◆ ProximLROutputBuffer()

ProximLROutputBuffer::ProximLROutputBuffer ( ProximLineReader lineReader)

The Constructor.

Parameters
lineReaderProximLineReader used for output.

Definition at line 223 of file ProximLineReader.cc.

223 :
224 std::streambuf(),
225 lineReader_(lineReader),
226 BUFFER_SIZE(1024) {
227
228 char* ptr = new char[BUFFER_SIZE];
229 setp(ptr, ptr + BUFFER_SIZE);
230 setg(0, 0, 0);
231}
const unsigned int BUFFER_SIZE
ProximLineReader * lineReader_

References BUFFER_SIZE.

◆ ~ProximLROutputBuffer()

ProximLROutputBuffer::~ProximLROutputBuffer ( )
virtual

The Destructor.

Definition at line 237 of file ProximLineReader.cc.

237 {
238 sync();
239}

References sync().

Here is the call graph for this function:

Member Function Documentation

◆ flushBuffer()

void ProximLROutputBuffer::flushBuffer ( )
private

Sends the buffer contents to the linereader.

Definition at line 279 of file ProximLineReader.cc.

279 {
280 if (pbase() != pptr()) {
281 // Buffer is not empty.
282 int len = pptr() - pbase();
283 char* buffer = new char[len+1];
284 strncpy(buffer, pbase(), len);
285 buffer[len] = '\0';
286 lineReader_->output(std::string(buffer));
287 setp(pbase(), epptr());
288 delete[] buffer;
289 }
290}
void output(std::string text)

References lineReader_, and ProximLineReader::output().

Referenced by overflow(), and sync().

Here is the call graph for this function:

◆ overflow()

int ProximLROutputBuffer::overflow ( int  c)
protected

Puts a character at current put position.

This function is called in case there is no room in the buffer to perform the output operation.

Definition at line 248 of file ProximLineReader.cc.

248 {
249
250 flushBuffer();
251
252 if (c != EOF) {
253 if(pbase() == epptr()) {
254 // The buffer length is zero, character is sent directly to the
255 // linereader.
256 lineReader_->output(std::string("") + (char)c);
257 } else {
258 // Append char to the flushed buffer.
259 sputc(c);
260 }
261 }
262 return 0;
263}

References flushBuffer(), lineReader_, and ProximLineReader::output().

Here is the call graph for this function:

◆ sync()

int ProximLROutputBuffer::sync ( )
protected

Synchronizes the streambuffer by flushing buffer contents to the linereader.

Definition at line 269 of file ProximLineReader.cc.

269 {
270 flushBuffer();
271 return 0;
272}

References flushBuffer().

Referenced by ~ProximLROutputBuffer().

Here is the call graph for this function:

Member Data Documentation

◆ BUFFER_SIZE

const unsigned int ProximLROutputBuffer::BUFFER_SIZE
private

Definition at line 126 of file ProximLineReader.hh.

Referenced by ProximLROutputBuffer().

◆ lineReader_

ProximLineReader* ProximLROutputBuffer::lineReader_
private

Definition at line 125 of file ProximLineReader.hh.

Referenced by flushBuffer(), and overflow().


The documentation for this class was generated from the following files: