📄 pqdfacty.cpp
字号:
/*
** CPQDIF_Factory class. Implements two sets of member functions:
** - The "abstract factory" methods such as NewPersistController() are
** used to create objects in such a way that the caller does not need to
** know the exact "concrete" class.
**
** --------------------------------------------------------------------------
** This class is a Singleton class; this means that only one instance of it
** should ever be created. This instance is made global, and is one of the
** only global objects in the entire system.
** --------------------------------------------------------------------------
**
** File name: $Workfile: pqdfacty.cpp $
** Last modified: $Modtime: 2/05/98 10:59a $
** Last modified by: $Author: Rob $
**
** VCS archive path: $Archive: /ElectrotekLibs/PQDIF/BasicPQDIF/pqdfacty.cpp $
** VCS revision: $Revision: 3 $
*/
#include "PQDIF_classes.h"
// The one and only factory object (Singleton)
CPQDIF_Factory theFactory;
// Construction
// ============
CPQDIF_Factory::CPQDIF_Factory()
{
}
CPQDIF_Factory::~CPQDIF_Factory()
{
}
// Creates a new persistence contoller of the specified concrete class.
//
CPQDIF_PersistController * CPQDIF_Factory::NewPersistController( PF_PersistController which )
{
CPQDIF_PersistController * ppc = NULL;
switch( which )
{
case PFPC_FlatFile:
ppc = new CPQDIF_PC_FlatFile();
break;
default:
// Cannot support...
ppc = NULL;
break;
}
return ppc;
}
// Creates a new stream object of the specified concrete class.
//
CPQDIF_StreamIO * CPQDIF_Factory::NewStreamIO( PF_StreamIO which )
{
CPQDIF_StreamIO * pstream = NULL;
switch( which )
{
case PSIO_FlatFile:
pstream = new CPQDIF_S_FlatFile();
break;
case PSIO_Chunk:
pstream = new CPQDIF_S_Chunk();
break;
default:
// Cannot support...
pstream = NULL;
break;
}
return pstream;
}
// Creates a new stream processor object. The list of concrete classes
// is extensible.
//
CPQDIF_StreamProcessor * CPQDIF_Factory::NewStreamProcessor( long which )
{
CPQDIF_StreamProcessor * pproc = NULL;
switch( which )
{
case ID_COMP_ALG_NONE:
pproc = new CPQDIF_SP_Nothing();
break;
case ID_COMP_ALG_ZLIB:
pproc = new CPQDIF_SP_ZLIB();
break;
case ID_COMP_ALG_PKZIPCL:
//pproc = new CPQDIF_SP_PKZIP();
break;
default:
// Cannot support...
pproc = NULL;
break;
}
return pproc;
}
// Creates a new PQDIF record object of the specified concrete class.
//
CPQDIFRecord * CPQDIF_Factory::NewRecord( PF_Record which )
{
CPQDIFRecord * prec = NULL;
switch( which )
{
// In all cases, create a general record, but with different header tags.
case PFR_Record:
prec = new CPQDIF_R_General();
prec->HeaderSetTag( tagBlank );
break;
case PFR_Container:
prec = new CPQDIF_R_General();
prec->HeaderSetTag( tagContainer );
break;
case PFR_DataSource:
prec = new CPQDIF_R_General();
prec->HeaderSetTag( tagRecDataSource );
break;
case PFR_MonitorSettings:
prec = new CPQDIF_R_General();
prec->HeaderSetTag( tagRecMonitorSettings );
break;
case PFR_Observation:
prec = new CPQDIF_R_General();
prec->HeaderSetTag( tagRecObservation );
break;
default:
prec = NULL;
break;
}
return prec;
}
CPQDIF_R_Observation * CPQDIF_Factory::NewObservationWrapper
(
CPQDIFRecord * precBase,
CPQDIFRecord * precDataSource
)
{
CPQDIF_R_Observation * pobs = NULL;
pobs = new CPQDIF_R_Observation( *precBase );
if( pobs )
{
// need to fix - check this first?
pobs->SetDataSource( (CPQDIF_R_DataSource *) precDataSource );
}
return pobs;
}
CPQDIF_R_Observation * CPQDIF_Factory::NewObservationWrapper2
(
CPQDIFRecord * precBase,
CPQDIFRecord * precDataSource,
CPQDIFRecord * precSettings
)
{
CPQDIF_R_Observation * pobs = NULL;
pobs = new CPQDIF_R_Observation( *precBase );
if( pobs )
{
// need to fix - check these first?
pobs->SetDataSource( (CPQDIF_R_DataSource *) precDataSource );
pobs->SetMonitorSettings( (CPQDIF_R_Settings *) precSettings );
}
return pobs;
}
// Creates a new PQDIF element object from the specified concrete
// class.
//
CPQDIF_Element * CPQDIF_Factory::NewElement( long which )
{
CPQDIF_Element * pel = NULL;
switch( which )
{
case ID_ELEMENT_TYPE_COLLECTION:
pel = new CPQDIF_E_Collection();
break;
case ID_ELEMENT_TYPE_SCALAR:
pel = new CPQDIF_E_Scalar();
break;
case ID_ELEMENT_TYPE_VECTOR:
pel = new CPQDIF_E_Vector();
break;
default:
pel = NULL;
break;
}
return pel;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -