|
CStream class |
Pipelines v1.6 |
|
Description |
The CStream class is the base class of both
the CInStream and COutStream classes.
It is through these class objects that the StageManager
coordinates the flow of records into and out of your stage. However, the
CInstream and COutStream classes themselves do not expose any of their read,
write or connect member functions to you; they only expose that part of their
interface to the CStageManager; which means that you are shielded from the
internal complexity of how your streams are actually connected and how input
and output records flow through them. The limited set of functions that these
classes’ do expose; are those that they inherit from their base class CStream
and these are shown below.
The CInstream and COutStream classes are not
included in this API documentation as they do not provide any information that
is of use to a stage designer.
|
Definition |
The following class definition is an edited
version; it details only those members which are accessible and of use to you.
In addition; any examples that may be shown are only intended as a
demonstration of how certain functions might be used, they do not represent
best practice nor do they take into account the scope and de-allocation of
class objects.
// The CStream class is the base class from which the CInStream and COutStream classes are derived. class CStream
{ public: bool IsConnected( void ) const; bool IsDisConnected( void ) const;};
|
Member variables |
None.
|
Member functions |
bool CStream::IsConnected( void ) const; |
|
● |
Purpose Use
IsConnected() to determine if this stream is
connected. |
||
|
● |
Parameters
|
||
|
● |
Returns |
||
|
|
|
||
|
● |
Messages None |
||
|
● |
Usage To determine if a specific stream is disconnected:DWORD CMyStage::Go( void ) { // Access the manager.CStageManager *pManager = Manager(); // Access my stage. CStage *pStage = pManager->GetStage( *this ); ... // // connected stream. CString szRecord;DWORD dwMaxInStream = pStage->MaxInStream(); for( DWORD dwInStream = 0; dwInStream < dwMaxInStream; ++dwInStream ) { CInStream *pInStream = pStage->GetInStream( dwInStream ); if( pInStream->IsConnected() ) { // Read a record from the input stream. pManager->ReadRecord( *this, dwIndex, &szRecord ) ) ... } } ... return( _RC_SUCCESS_ )} |
bool CStream::IsDisConnected( void ) const; |
|
● |
Purpose Use
IsDisConnected() to determine if this stream is disconnected. |
||
|
● |
Parameters
|
||
|
● |
Returns |
||
|
|
|
||
|
● |
Messages None |
||
|
● |
Usage To determine if a specific stream is connected:DWORD CMyStage::Go( void ) { // Access the manager.CStageManager *pManager = Manager(); // Access my stage. CStage *pStage = pManager->GetStage( *this ); // Get a pointer to my primary output stream.COutStream *pPriOutStream = pStage->GetOutStream( 0 ); ... // My stage reads each set of 20 records from its primary input stream, // and writes an output record which details the accumulted/running total // of the number of input records read so far. // Record buffer. CString szRecord; DWORD dwAccumulator = 0; DWORD dwTotal = 0; while( true ) { // If my primary output stream is disconnected; then there is no need // to continue reading records from my primary input stream. if( pPriOutStream->IsDisConnected() ) break; // Read a record from my primary input stream.if( !pManager->ReadRecord( *this, 0, &szRecord ) ) { // This is the end-of-file on my primary input stream. break; } if( dwAccumulator == 20 ) { szRecord.Format( “%ld”, dwTotal ); // Write the record to my primary output stream.if( !pManager->WriteRecord( *this, 0, &szRecord ) ) { // This is the end-of-file on my primary output stream. break; } dwAccumulator = 0; } ++dwTotal; } return( _RC_SUCCESS_ );} |
|
|