#include <AxPipe.h>
Inheritance diagram for AxPipe::CSink:
Public Member Functions | |
virtual void | OutPump (CSeg *pSeg) |
Hand off a segment to Work(). | |
CSink () | |
Initialize member variables. | |
virtual | ~CSink () |
Plug the pipe, destroy the sink and release remaining m_pSeg if any. | |
virtual void | AppendSink (CSink *pSink, bool fAutoDelete) |
Error catcher. | |
virtual void | DestructSink () |
Destruct code place holder for derived classes. | |
virtual void | Sync () |
Ensure that all threads downstream are idle. | |
Protected Member Functions | |
void | Work () |
Process one CSeg. | |
CSeg * | GetSeg (size_t cb) |
Allocate a new segment, possibly from the next section of the pipe. | |
virtual void | Signal (void *vId, void *p) |
Out of band signalling down stream place holder. | |
longlong | SizeMax () |
Estimate the final sinks size, if limited. | |
virtual longlong | OutSizeMax () |
Overrideable, Calculate the maximum size of the CSink. | |
virtual CSeg * | OutGetSeg (size_t cb) |
Overrideable, Allocate a CSeg for this sink. | |
virtual bool | OutSignal (void *vId, void *p) |
Overrideable, Receive an out of band signal from upstream. | |
virtual bool | OutOpen () |
Overrideable, Open the data stream for processing. | |
virtual bool | OutFlush () |
Overrideable, Handle request for flush of buffered data. | |
virtual bool | OutClose () |
Overrideable, Output any final data, close and prepare for new Open(). | |
virtual void | OutPlug () |
Plug this section. | |
virtual void | OutSpecial (CSeg *pSeg) |
Overrideable, Consume a special segment. | |
virtual void | Out (CSeg *pSeg)=0 |
Overrideable, Consume a segment and Pump() the processed result downstream. | |
Protected Attributes | |
bool | m_fIsOpen |
Keep track if this part is open. | |
CSeg * | m_pSeg |
Next/Current segment to work on. | |
Private Member Functions | |
bool | DoSegWork (CSeg *pSeg) |
Send a CSeg onwards for processing, handling special types. | |
Friends | |
class | CPipe |
CPipe needs private access. |
A CSink should be at the terminating end of all pipe lines, if you really don't need one, attach a /dev/null equivalent sink, CSinkNull. (The framework will work anyway, but it's good practice.)
Convention dictates that all CSink derived classes are named with CSink as a prefix.
CPipe is a derivation of CSink too, basically with the added logic to send data onwards.
Definition at line 213 of file AxPipe.h.
|
Error catcher. You can't append a CSink to a CSink, so this implements code to catch that error. Reimplemented in AxPipe::CPipe, and AxPipe::CSplit. Definition at line 260 of file CSink.cpp. References _T, AxPipe::ERROR_CODE_GENERIC, and AxPipe::CError::SetError(). Referenced by AxPipe::CPipe::AppendSink(). |
|
Destruct code place holder for derived classes. Called by the virtual destructor, the default implementation for CSink does nothing. The purpose of DestructSink() is to ensure that the whole chain gets destructed, also depending on if they should be auto deleted. It should be called by the destructor before it does the remaining destructing. Reimplemented in AxPipe::CPipe, and AxPipe::CSplit. Definition at line 278 of file CSink.cpp. References _T. Referenced by AxPipe::CPipe::DestructSink(). |
|
Send a CSeg onwards for processing, handling special types. Helper function that is also called by derived classes that want slightly different Work() logic, but can leverage this common base. Checks for special AxPipe::eSegType types, and calls the appropriate OutOpen(), OutClose(), OutFlush() and Out() functions depending on the case. Only in the case of Out() does the actual data segment get passed on. Any custom AxPipe::eSegType segment types gets passed as normal segments to Out(). Ensures that the pipe is Open() at this stage before sending data etc.
Definition at line 45 of file CSink.cpp. References AxPipe::ERROR_CODE_NOTOPEN, AxPipe::eSegTypeClose, AxPipe::eSegTypeFlush, AxPipe::eSegTypeOpen, AxPipe::eSegTypePlug, AxPipe::CSeg::Len(), m_fIsOpen, Out(), OutClose(), OutFlush(), OutOpen(), OutPlug(), OutSpecial(), AxPipe::CSeg::Release(), AxPipe::CError::SetError(), and AxPipe::CSeg::Type(). Referenced by Work(), and AxPipe::CPipe::Work(). |
|
Allocate a new segment, possibly from the next section of the pipe. Allocate a new segment, possibly from the next section of the pipe. Callable from user code in derived classes. Call this to get a segment if you suspect the next in line is a sink that might provide an efficient segment, such as for a memory mapped file.
Reimplemented in AxPipe::CPipe. |
|
Overrideable, Consume a segment and Pump() the processed result downstream. The provided segment is guaranteed to be non-NULL and non-zero-length A special CSeg with a non-zero AxPipe::eSegType value will be sent to OutSpecial(). This is must be implemented in derived classes, there is no default. For CSink directly derived class the actual method of consuming it is up to the CSink, for CPipe derived classes, CPipe::Pump() is the normal method for sending processed data.
Implemented in AxPipe::CPipe, AxPipe::CSinkNull, AxPipe::CSplit, AxPipe::CSource, AxPipe::CFilter, AxPipe::CJoin::CTSinkJoin, AxPipe::CSinkMemFile, AxPipe::Stock::CPipeFindSync, AxPipe::Stock::CPipeHMAC_SHA1< iBits >, AxPipe::Stock::CPipeInflate, and AxPipe::Stock::CPipeSHA1. Referenced by DoSegWork(). |
|
Overrideable, Output any final data, close and prepare for new Open(). The code should handle multiple (extra) calls to an already closed stream with no ill effects, i.e. silently ignore them. This default implementation returns false to stop propagation, since it's a CSink.
Reimplemented in AxPipe::CPipe, AxPipe::CSplit, AxPipe::CFilter, AxPipe::CJoin::CTSinkJoin, AxPipe::CSourceMemFile, AxPipe::CSinkMemFile, AxPipe::Stock::CPipeHMAC_SHA1< iBits >, AxPipe::Stock::CPipeInflate, and AxPipe::Stock::CPipeSHA1. Definition at line 226 of file CSink.cpp. Referenced by DoSegWork(). |
|
Overrideable, Handle request for flush of buffered data. You are not required to honor the request.
Reimplemented in AxPipe::CSplit, AxPipe::CFilter, and AxPipe::CJoin::CTSinkJoin. Definition at line 217 of file CSink.cpp. Referenced by DoSegWork(). |
|
Overrideable, Allocate a CSeg for this sink. Override in user derived classes to provide an efficient memory segment output from a CSink, especially for memory mapped files.
Reimplemented in AxPipe::CPipe, and AxPipe::CSinkMemFile. Definition at line 183 of file CSink.cpp. Referenced by AxPipe::CPipe::GetSeg(). |
|
Overrideable, Open the data stream for processing. Override in user derived classes. Called by the framework as a result of an Open() call here or upstream. Prepare for processing of a new stream, it must support being called again after a Close() call. No data may be processed by the stream without an Open() call. The default implementation for a CSink returns false, as it does not make sense to propagate downstream from a CSink()
Reimplemented in AxPipe::CPipe, AxPipe::CSplit, AxPipe::CFilter, AxPipe::CSourceMemFile, AxPipe::CSinkMemFile, AxPipe::Stock::CPipeHMAC_SHA1< iBits >, AxPipe::Stock::CPipeInflate, and AxPipe::Stock::CPipeSHA1. Definition at line 210 of file CSink.cpp. Referenced by DoSegWork(). |
|
Plug this section. Unless we're already exited, end processing and wait for it to reach idle state. Should not be called from Work() or Out(). Finally, we wait for the worker thread, if any, to actually exit, thus assuring that when Plug() returns, it is safe to call the destructor. The purpose of Plug is to finalize all processing and to ensure that any errors are found and reported. Final error checking for processing should thus not be done before Plug() is called. After Plug() is called, the only thing that should be done with the object and the pipe line is to destruct it. Reimplemented in AxPipe::CJoin. Definition at line 122 of file CSink.cpp. References _T. Referenced by DoSegWork(). |
|
Hand off a segment to Work(). Do not call from user code, only from derived framework classes. The normal usage is to have the previous section up the line call this via it's CPipe::m_pSink pointer, the roundabout way is to enable seamless threading. Is frequently called from other library-internal classes, therefore public
Reimplemented in AxPipe::CPipeBlock. Definition at line 162 of file CSink.cpp. References m_pSeg, AxPipe::CNoThread::WorkSignal(), and AxPipe::CNoThread::WorkStart(). Referenced by AxPipe::CSource::Close(), AxPipe::CPipe::Close(), AxPipe::CPipe::Flush(), AxPipe::CSource::Open(), AxPipe::CPipe::Open(), AxPipe::CSource::Out(), AxPipe::CSource::Plug(), AxPipe::CPipe::Pump(), AxPipe::CSplit::PumpSplit(), and AxPipe::CPipe::Work(). |
|
Overrideable, Receive an out of band signal from upstream. Override in user derived classes to receive a signal sent from upstream. This will be called synchronized with the data stream, so previously sent data will have reached this section, unless some intermediate section buffers. No automatic Flush() request is sent though. This CSink default implementation does nothing and returns false to stop propagation, since it's CSink.
Reimplemented in AxPipe::CPipe. Definition at line 197 of file CSink.cpp. Referenced by AxPipe::CPipe::Signal(). |
|
Overrideable, Calculate the maximum size of the CSink. Override this in user derived classes to return the maximum size of the sink, or -1 for expandable. The default CSink implementation always returns -1.
Reimplemented in AxPipe::CPipe. Definition at line 174 of file CSink.cpp. References AxPipe::longlong. Referenced by AxPipe::CPipe::OutSizeMax(), and SizeMax(). |
|
Overrideable, Consume a special segment. Segments may be marked as special with a non-zero value based on AxPipe::eSegType types. These are filtered out of the stream by the framework and presented here instead of to Out(). Use this in derived classes to provide in band signalling and for other custom needs. Start numbering from AxPipe::eSegTypeDerived. The default implementation here just calls CSeg::Release() on the provided CSeg . These segements may be zero-length.
Reimplemented in AxPipe::CPipe, and AxPipe::CSplit. Definition at line 239 of file CSink.cpp. References AxPipe::CSeg::Release(). Referenced by DoSegWork(). |
|
Out of band signalling down stream place holder. Callable from user code in derived classes. Does nothing, this is a CSink.
Reimplemented in AxPipe::CPipe. Definition at line 143 of file CSink.cpp. Referenced by AxPipe::CPipe::Signal(). |
|
Estimate the final sinks size, if limited. Callable from user code in derived classes.
Definition at line 151 of file CSink.cpp. References AxPipe::longlong, and OutSizeMax(). |
|
Ensure that all threads downstream are idle. Synchronize all work downstream, ensuring that there is no work in progress. Reimplemented in AxPipe::CPipe, and AxPipe::CSplit. Definition at line 267 of file CSink.cpp. References AxPipe::CNoThread::WaitForIdle(). Referenced by AxPipe::CPipe::Sync(). |
|
Process one CSeg. Called with CSink::m_pSeg set to whatever needs to be processed. Work guarantees to never call Out() with anything but a valid, non-zero-length data segment. Other cases are handled by OutOpen(), OutClose() and OutFlush(). A Plug() request causes nothing to be sent to Out(). Implements AxPipe::CNoThread. Reimplemented in AxPipe::CPipe, and AxPipe::CFilter. Definition at line 105 of file CSink.cpp. References DoSegWork(), and m_pSeg. |