Update of /cvsroot/pclasses/pclasses2/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11835/test
Added Files:
CType.cpp FactoryTest.h
Log Message:
egg
--- NEW FILE: FactoryTest.h ---
#ifndef ptest_FACTORYTEST_HPP_INCLUDED
#define ptest_FACTORYTEST_HPP_INCLUDED 1
////////////////////////////////////////////////////////////////////////
// Demonstration classes for FactoryTest.
////////////////////////////////////////////////////////////////////////
#ifndef CERR
#define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : "
#endif
#include <pclasses/Factory.h>
struct TheBase
{
virtual ~TheBase() {}
virtual std::string classname() const = 0;
};
#endif // ptest_FACTORYTEST_HPP_INCLUDED
--- NEW FILE: CType.cpp ---
#include "FactoryTest.h"
struct AType : public TheBase
{
AType()
{
CERR << "AType()\n";
}
virtual ~AType()
{
CERR << "~AType()\n";
}
virtual std::string classname() const { return "AType"; }
};
struct BType : public AType
{
BType()
{
CERR << "BType()\n";
}
virtual ~BType()
{
CERR << "~BType()\n";
}
virtual std::string classname() const { return "BType"; }
};
#define PFACREG_TYPE AType
#define PFACREG_TYPE_INTERFACE TheBase
// #define PFACREG_TYPE_IS_ABSTRACT // define to install a null factory for AType
#define PFACREG_TYPE_NAME "AType"
#include <pclasses/FactoryReg.h>
#define PFACREG_TYPE BType
#define PFACREG_TYPE_INTERFACE TheBase
#define PFACREG_TYPE_NAME "BType"
#include <pclasses/FactoryReg.h>
struct CType : public BType
{
CType()
{
CERR << "CType()\n";
}
virtual ~CType()
{
CERR << "~CType()\n";
}
virtual std::string classname() const { return "CType"; }
};
TheBase * new_CType()
{
return new CType;
}
void CType_bogo_init()
{
CERR << "CType_bogo_init()\n";
::P::NamedTypeFactory<TheBase>::instance().registerFactory( "XtraType", new_CType );
}
int CType_bogo_init_placeholder = ( CType_bogo_init(), 0 );
#define PFACREG_TYPE CType
#define PFACREG_TYPE_INTERFACE TheBase
#define PFACREG_TYPE_NAME "CType"
#include <pclasses/FactoryReg.h>
|