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

CSink.cpp

Go to the documentation of this file.
00001 
00034 #include "stdafx.h"
00035 
00036 namespace AxPipe {
00045     bool
00046     CSink::DoSegWork(CSeg *pSeg) {
00047         bool fPropagate;                    // true if we propagate in band signals
00048 
00049         switch (pSeg->Type()) {
00050         case eSegTypeOpen:
00051             fPropagate = OutOpen();
00052             // Can't set this false before we've closed properly
00053             m_fIsOpen = true;
00054             return fPropagate;
00055             break;
00056 
00057         case eSegTypeFlush:
00058             return OutFlush();
00059             break;
00060 
00061         case eSegTypeClose:
00062             if (m_fIsOpen) {
00063                 fPropagate = OutClose();
00064                 // Can't set this false before we've closed properly
00065                 m_fIsOpen = false;
00066             }
00067             return fPropagate;
00068             break;
00069 
00070         case eSegTypePlug:
00071             // Set the exit so we can end if it's a thread etc.
00072             OutPlug();                      // Call this class's Plug-function
00073             fPropagate = m_fExit = true;
00074             return fPropagate;
00075             break;
00076 
00077         case 0:
00078             if (!m_fIsOpen) {
00079                 SetError(ERROR_CODE_NOTOPEN, ERROR_MSG_NOTOPEN);
00080                 break;
00081             }
00082             if (pSeg->Len()) {
00083                 // non-zero length data segment.
00084                 // Out() will not be called with anything else. CFilter derived classes have slightly
00085                 // different rules.
00086                 Out(pSeg);
00087             } else {
00088                 pSeg->Release();            // Ignore zero-length segments.
00089             }
00090             break;
00091         default:
00092             // It's an special/unknown segment type, call the handler (even with zero-length)
00093             // Note that we never auto propagate special segments, they are semantially similar
00094             // to normal data segments and must be manually Pump()'d by the implementation.
00095             OutSpecial(pSeg);
00096             break;
00097         }
00098         return false;
00099     }
00100 
00105     void
00106     CSink::Work() {
00107         CSeg *pSeg = m_pSeg;
00108         m_pSeg = NULL;
00109 
00110         (void)DoSegWork(pSeg);
00111     }
00112 
00122     void
00123     CSink::OutPlug() {
00124         Assert::OutputDebugStringF(_T("CSink::OutPlug() m_fExit=%d\n"), m_fExit);
00125     }
00126 
00134     CSeg *
00135     CSink::GetSeg(size_t cb)  {
00136         return new CSeg(cb);
00137     }
00138 
00143     void
00144     CSink::Signal(void *vId, void *p) {
00145     }
00146 
00151     longlong
00152     CSink::SizeMax() {
00153         return OutSizeMax();
00154     }
00155 
00162     void
00163     CSink::OutPump(CSeg *pSeg) {
00164         WorkStart();
00165         m_pSeg = pSeg;
00166         WorkSignal();
00167     }
00168     
00174     longlong
00175     CSink::OutSizeMax() {
00176         return -1;
00177     }
00178     
00183     CSeg *
00184     CSink::OutGetSeg(size_t cb) {
00185         return new CSeg(cb);
00186     }
00187     
00197     bool
00198     CSink::OutSignal(void *vId, void *p) {
00199         return false;
00200     }
00201 
00210     bool
00211     CSink::OutOpen() {
00212         return false;
00213     };
00214     
00217     bool
00218     CSink::OutFlush() {
00219         return false;
00220     };
00221     
00226     bool
00227     CSink::OutClose() {
00228         return false;
00229     };
00239     void
00240     CSink::OutSpecial(CSeg *pSeg) {
00241         pSeg->Release();
00242     }
00243 
00245     CSink::CSink() {
00246         m_pSeg = NULL;
00247         m_fIsOpen = false;
00248     }
00249 
00251     CSink::~CSink() {
00252         OutputDebugStringF(_T("CSink::~CSink() Initating... this=%p\n"), this);
00253         ASSCHK(m_fExit, _T("CSink::~CSink() called without Plug()"));
00254         if (CSeg::IsSeg(m_pSeg)) m_pSeg->Release();
00255         OutputDebugStringF(_T("CSink::~CSink() ...Done. this=%p\n"), this);
00256     }
00257 
00260     void
00261     CSink::AppendSink(CSink *pSink, bool fAutoDelete) {
00262         SetError(ERROR_CODE_GENERIC, _T("Attempt to append to a sink"));
00263     }
00264 
00267     void
00268     CSink::Sync() {
00269         WaitForIdle();
00270         // Do no more, this is a CSink - It's the end of the line.
00271     }
00272 
00278     void
00279     CSink::DestructSink() {
00280         OutputDebugString(_T("CSink::DestructSink()\n"));
00281     }
00282 };

Generated on Mon Feb 2 13:19:18 2004 for AxPipe by doxygen 1.3.5