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

AxPipe::CJoin Class Reference

A Y join, taking any number of streams and joining them. More...

#include <AxPipe.h>

Inheritance diagram for AxPipe::CJoin:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CJoin ()
 Construct the CJoin, but Init() must also be called.

virtual ~CJoin ()
 Also destruct all the CTSinkJoin sink-objects.

void OutPlug ()
 Handle Plug() of the stream, checking all input streams for errors too.

CSinkGetSink (int ix)
CJoinInit (int nMaxStreams=2)
 Define how many streams you want here.

CSegStreamSeg (int ix)
 Wait for data from the in-stream, get it and indicate when done.

int StreamIx (int ix)
 Set and return the current input stream index.

int StreamNum ()
 Get the number of streams.

bool StreamEmpty (int ix)
 Tell if an indexed stream is marked as empty.


Private Attributes

CTSinkJoin ** m_ppInSinks
 The array of in-stream control objects.

int m_nMaxStreams
 The max number of streams we're prepared for with Init().


Detailed Description

A Y join, taking any number of streams and joining them.

Build any number of streams, with CSource's at the start and any number of CPipe sections, but do not terminate them with a CSink.

Call Init(int) specifying how many streams you wish to attach to the join.

Get a CSink to terminate them with by calling the GetSink(int) member, with a sink index as argument. This attaches the stream to the CJoin. If a stream is started from a separate CSource, use CThreadSource<> to setup a thread in which to run it.

Override the In() member function to peform custom merging of many streams into one. They are indexed 0 to n-1. Use StreamSeg(int) to call the appropriate stream fiber context. StreamIx(int) to ensure an index is valid. StreamNum() to get the maximum number of streams and StreamEmpty(int) to check if an input stream is marked as empty.

The class supports merging of any number of streams.

Definition at line 532 of file AxPipe.h.


Member Function Documentation

CSink & AxPipe::CJoin::GetSink int  ix  ) 
 

Get a CSink that can be used to terminate an input stream, passing the data to the CJoin. A reference is returned, do not take the address of it and use as a pointer. This object must be destructed by the CJoin code, not the pipe it gets CPipe::Append()'ed to.

Parameters:
ix The index of the input stream to get the CSink for.
Returns:
A reference to a CSink.

Definition at line 165 of file CJoin.cpp.

References _T, ASSCHK, m_nMaxStreams, and m_ppInSinks.

CJoin * AxPipe::CJoin::Init int  nMaxStreams = 2  ) 
 

Define how many streams you want here.

Parameters:
nMaxStreams Specify how many streams at the max you want to join.

Definition at line 150 of file CJoin.cpp.

References m_nMaxStreams, and m_ppInSinks.

bool AxPipe::CJoin::StreamEmpty int  ix  ) 
 

Tell if an indexed stream is marked as empty.

Parameters:
ix The index, in the range 0 - (MaxIx() - 1)
Returns:
true if the indexed stream is marked as empty.

Definition at line 206 of file CJoin.cpp.

References AxPipe::CJoin::CTSinkJoin::IsEmpty(), and m_ppInSinks.

Referenced by CJoinInterleave::In().

int AxPipe::CJoin::StreamIx int  ix  ) 
 

Set and return the current input stream index.

Parameters:
ix The stream you want, it'll get reduced modulo the number of streams.
Returns:
The actual stream used guaranteed in the range 0 - (MaxIx() - 1)

Definition at line 191 of file CJoin.cpp.

References m_nMaxStreams.

Referenced by CJoinInterleave::In().

int AxPipe::CJoin::StreamNum  ) 
 

Get the number of streams.

Returns:
The number of streams.

Definition at line 198 of file CJoin.cpp.

References m_nMaxStreams.

CSeg * AxPipe::CJoin::StreamSeg int  ix  ) 
 

Wait for data from the in-stream, get it and indicate when done.

Returns:
The next segment, NULL if empty.

Definition at line 176 of file CJoin.cpp.

References _T, ASSCHK, AxPipe::CJoin::CTSinkJoin::GetSeg(), AxPipe::CJoin::CTSinkJoin::IsEmpty(), m_nMaxStreams, m_ppInSinks, and AxPipe::CJoin::CTSinkJoin::SinkWorkWait().

Referenced by CJoinInterleave::In().


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