/* ** PQController class. This class is used to control the reconstitution ** of PQDIF element objects from a buffer where they have been archived. ** -------------------------------------------------------------------------- ** ** File name: $Workfile: ser_cont_el.cpp $ ** Last modified: $Modtime: 10/07/02 7:41a $ ** Last modified by: $Author: Jack $ ** ** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/ser_cont_el.cpp $ ** VCS revision: $Revision: 11 $ */ #include "PQDIF_classes.h" // Construction // ============ PQController::PQController( void ) { } PQController::~PQController( void ) { } void PQController::ParseRecord ( BYTE * buffer, SIZE4 size, CPQDIF_E_Collection * pcollMain ) { PQDIFIterator piter( this, buffer, size, 0, pcollMain ); piter.ParseCollection(); return; } CPQDIF_E_Collection * PQController::acceptCollection ( CPQDIF_E_Collection * pcoll, int /*index*/, const GUID& tag ) { CPQDIF_E_Collection * pcollNew; // Create the new collection object pcollNew = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); if( pcollNew ) { // Add it to the previous collection pcollNew->SetTag( tag ); pcoll->Add( pcollNew ); } return pcollNew; } CPQDIF_E_Scalar * PQController::acceptScalar ( CPQDIF_E_Collection * pcoll, int /*index*/, const GUID& tag, long typePhysical, void * pdata ) { CPQDIF_E_Scalar * pel; //ASSERT( pdata ); // Create new element pel = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); //ASSERT( pel ); if( pel ) { // Initialize it. If successful then ... pel->SetTag( tag ); if( pel->SetValue( typePhysical, *(PQDIFValue *)pdata ) ) { // Add it to the current collection //ASSERT( pcoll ); pcoll->Add( pel ); } else { delete pel; pel = NULL; } } return pel; } CPQDIF_E_Vector * PQController::acceptVector ( CPQDIF_E_Collection * pcoll, int index, const GUID& tag, long typePhysical, c_vector * pvector, void * pdata ) { SIZE4 sizeValue; CPQDIF_E_Vector * pel = NULL; // Validate parameters //ASSERT( pvector ); //ASSERT( pdata ); // Init sizeValue = theInfo.GetNumBytesOfType( typePhysical ); SIZE4 TotalSize = sizeValue * pvector->count; if ((TotalSize > 0) && (TotalSize < 1000000)) { // Create new element pel = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); //ASSERT( pel ); if( pel ) { // Initialize it pel->SetTag( tag ); pel->SetPhysicalType( typePhysical ); if( pel->SetCount( pvector->count ) ) { memcpy( pel->GetRawData(), pdata, pvector->count * sizeValue ); // Add the element to the current collection //ASSERT( pcoll ); pcoll->Add( pel ); } else { delete pel; pel = NULL; } } } return pel; } bool PQController::decodeValue ( long typePhysical, void * pdata, PQDIFValue& value ) { bool status = false; int iSize = theInfo.GetNumBytesOfType( typePhysical ); if( iSize > 0 ) { memcpy( (void *)&value, pdata, iSize ); status = true; } return status; }