Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AxPipe::CSource Class Reference

A generic source, as an abstract class. More...

#include <AxPipe.h>

Inheritance diagram for AxPipe::CSource:

Inheritance graph
[legend]
Collaboration diagram for AxPipe::CSource:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~CSource ()
 Ensure Plug() is called.

CSourceAppend (CSink *pSink)
 Append a section by pointer with auto deletion.

CSourceAppend (CSink &sink)
 Append a section by reference.

CSourceOpen ()
 Open the source and possibly propagate downstream.

CSourceClose ()
 Close the source and possible propagate downstream.

CSourceDrain ()
 Drain the pipe until In() says we're empty for now.

CSourcePlug ()
 Plug this pipe, prepare for exit, cannot reopen after this. It's ok to call Plug() multiple times.

void Out (CSeg *pSeg)
 Send data to an attached CSink.


Protected Member Functions

virtual CSegIn ()=0
 The basic source of segments.


Detailed Description

A generic source, as an abstract class.

You must override In(), and most likely provide your own constructor as well. The OutOpen() override shoulde be able to handle multiple calls, with OutClose() inbetween of course. Once open, Drain() should be called. This will push data from In() downstream until it signals empty, whereupon a flush is sent. If the source supports it, Drain() may be called multiple times in a row.

To support usage of multiple sources within a specific pipe, you may implement the OutClose() and OutOpen() methods, typically to close a file, and then open a new one, respectively.

Shutdown of the pipe occurs by either calling Plug() explicitly, or by calling it implicitly from the destructor of the CSource.

Definition at line 376 of file AxPipe.h.


Constructor & Destructor Documentation

AxPipe::CSource::~CSource  )  [virtual]
 

Ensure Plug() is called.

When a CSource get's destructed, we ensure that Plug() is called, so we know that we really can destruct it safely without any other threads referencing it.

Definition at line 39 of file CSource.cpp.


Member Function Documentation

CSource * AxPipe::CSource::Append CSink sink  ) 
 

Append a section by reference.

Parameters:
sink Reference to an instance of a CSink derived object.
Returns:
A pointer to 'this' CSource
See also:
CPipe::Append(CSink&)

Reimplemented from AxPipe::CPipe.

Definition at line 57 of file CSource.cpp.

References AxPipe::CPipe::AppendSink().

CSource * AxPipe::CSource::Append CSink pSink  ) 
 

Append a section by pointer with auto deletion.

Parameters:
pSink Pointer to an instance of a CSink derived object.
Returns:
A pointer to 'this' CSource
See also:
CPipe::Append(CSink *)

Reimplemented from AxPipe::CPipe.

Definition at line 47 of file CSource.cpp.

CSource * AxPipe::CSource::Close  ) 
 

Close the source and possible propagate downstream.

This will first call OutClose(), then propagate the signal downstream if OutClose() indicates we should by returning true. Override OutClose() to implement a closing of the stream.

Reimplemented from AxPipe::CPipe.

Definition at line 84 of file CSource.cpp.

References AxPipe::eSegTypeClose, and AxPipe::CSink::OutPump().

CSource * AxPipe::CSource::Drain  ) 
 

Drain the pipe until In() says we're empty for now.

Returns:
A pointer to 'this' CSource to allow the notation: pmySource->Drain()->Plug();

Definition at line 95 of file CSource.cpp.

References _T, ASSCHK, AxPipe::ERROR_CODE_NOTOPEN, AxPipe::CError::GetErrorCode(), In(), AxPipe::CSeg::Len(), AxPipe::nGlobalInit, AxPipe::CSeg::Release(), AxPipe::CError::SetError(), AxPipe::CNoThread::WorkEnd(), AxPipe::CNoThread::WorkSignal(), and AxPipe::CNoThread::WorkStart().

virtual CSeg* AxPipe::CSource::In  )  [protected, pure virtual]
 

The basic source of segments.

Must override in all CSource derived classes. Should return a memory segment CSeg with new data as long as there is data available.

Returns:
NULL on error, zero-length on empty/eof, otherwise a CSeg with data.

Implemented in AxPipe::CSourceNull, AxPipe::CSourceMem, AxPipe::CSourceMemFile, and CJoinInterleave.

Referenced by Drain().

CSource * AxPipe::CSource::Open  ) 
 

Open the source and possibly propagate downstream.

All other sections Open() will only open the stream downstream of the current object, but since this is a CSource, we first call our own OutOpen(), then propagate if OutOpen() indicates we should. Override OutOpen() to implement stream open.

Returns:
A pointer to 'this' cSource.

Reimplemented from AxPipe::CPipe.

Definition at line 70 of file CSource.cpp.

References AxPipe::eSegTypeOpen, and AxPipe::CSink::OutPump().

void AxPipe::CSource::Out CSeg pSeg  )  [virtual]
 

Send data to an attached CSink.

Parameters:
pSeg Pointer to a CSeg containing the data to send downstream.

Implements AxPipe::CPipe.

Definition at line 134 of file CSource.cpp.

References AxPipe::CSink::OutPump(), and AxPipe::CSeg::Release().

CSource * AxPipe::CSource::Plug  ) 
 

Plug this pipe, prepare for exit, cannot reopen after this. It's ok to call Plug() multiple times.

Returns:
A pointer to 'this' CSource.

Definition at line 124 of file CSource.cpp.

References AxPipe::eSegTypePlug, and AxPipe::CSink::OutPump().


The documentation for this class was generated from the following files:
Generated on Mon Feb 2 13:19:28 2004 for AxPipe by doxygen 1.3.5