新增了PQDIF补招线程,导入了新的lib库
This commit is contained in:
146
LFtid1056/pqdif/include/str_base.cpp
Normal file
146
LFtid1056/pqdif/include/str_base.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
** CPQDIF_StreamIO class. The base class for implementing "stream I/O" which
|
||||
** works along with a CPQDIF_PersistController class to supports a specific
|
||||
** persistence mechanism.
|
||||
** --------------------------------------------------------------------------
|
||||
**
|
||||
** File name: $Workfile: str_base.cpp $
|
||||
** Last modified: $Modtime: 9/21/00 9:09a $
|
||||
** Last modified by: $Author: Bill $
|
||||
**
|
||||
** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/str_base.cpp $
|
||||
** VCS revision: $Revision: 8 $
|
||||
*/
|
||||
#include "PQDIF_classes.h"
|
||||
|
||||
|
||||
// Local constants
|
||||
const long sizeDefaultGrowBy = 16*1024;
|
||||
|
||||
// Construction
|
||||
// ============
|
||||
|
||||
CPQDIF_StreamIO::CPQDIF_StreamIO()
|
||||
{
|
||||
m_processor = NULL;
|
||||
|
||||
m_canWriteFull = false;
|
||||
m_canWriteInc = false;
|
||||
|
||||
m_buffRead.SetSize( 0, sizeDefaultGrowBy );
|
||||
m_posRead = 0;
|
||||
m_buffWrite.SetSize( 0, sizeDefaultGrowBy );
|
||||
m_posWrite = 0;
|
||||
}
|
||||
|
||||
|
||||
CPQDIF_StreamIO::~CPQDIF_StreamIO()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ConnectProcessor( CPQDIF_StreamProcessor * proc )
|
||||
{
|
||||
m_processor = proc;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
long CPQDIF_StreamIO::GetChecksum( void )
|
||||
{
|
||||
return m_processor->GetChecksum();
|
||||
}
|
||||
|
||||
|
||||
void CPQDIF_StreamIO::ResetChecksum( void )
|
||||
{
|
||||
m_processor->ResetChecksum();
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ExecuteProcessorEncode( void )
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if( m_processor )
|
||||
{
|
||||
// Make sure we are connected to it
|
||||
m_processor->ConnectStream( this );
|
||||
|
||||
status = m_processor->StreamEncode();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ExecuteProcessorDecode( void )
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if( m_processor )
|
||||
{
|
||||
// Make sure we are connected to it
|
||||
m_processor->ConnectStream( this );
|
||||
|
||||
status = m_processor->StreamDecode();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ProcessRead( const BYTE * &buffer, long max, long& sizeActual )
|
||||
{
|
||||
buffer = m_buffRead.GetData() + m_posRead; // Adjust to current position
|
||||
sizeActual = m_buffRead.GetSize() - m_posRead; // Get size minus current position
|
||||
if( max > 0 && max > sizeActual )
|
||||
sizeActual = max;
|
||||
return sizeActual > 0;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ProcessWriteReserve( BYTE * & buffer, long size )
|
||||
{
|
||||
buffer = NULL;
|
||||
bool status = m_buffWrite.SetSize( m_posWrite + size );
|
||||
if( status )
|
||||
{
|
||||
buffer = m_buffWrite.GetData() + m_posWrite;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::ProcessWriteRelease( long size )
|
||||
{
|
||||
bool status = m_buffWrite.SetSize( m_posWrite + size );
|
||||
if( status )
|
||||
m_posWrite += size;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::BeginBlock( void )
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
// Clear buffers
|
||||
m_buffRead.SetSize( 0, sizeDefaultGrowBy );
|
||||
m_posRead = 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool CPQDIF_StreamIO::AppendBlock( BYTE * buffer, long size )
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
// Fill the read buffer
|
||||
m_buffRead.Append( buffer, size );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user