From: stephan b. <sg...@us...> - 2004-12-26 06:01:05
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17684/test Modified Files: CType.cpp FactoryTest.cpp FactoryTest.h Makefile.toc s11nTest.cpp Log Message: mass commit: playing with Factory's new aliasing support. Index: s11nTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/s11nTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- s11nTest.cpp 26 Dec 2004 05:02:59 -0000 1.2 +++ s11nTest.cpp 26 Dec 2004 06:00:55 -0000 1.3 @@ -1,8 +1,8 @@ +#include <pclasses/s11n/s11n_debuggering_macros.h> #include <pclasses/s11n/s11n.h> #include <pclasses/s11n/s11n_node.h> #include <pclasses/s11n/io/s11n_io.h> -#include <pclasses/s11n/s11n_debuggering_macros.h> #include <pclasses/s11n/list.h> #include <pclasses/s11n/map.h> #include <pclasses/s11n/pods_streamable.h> @@ -12,79 +12,12 @@ #include <list> #include <map> -#include "FactoryTest.h" +#include "FactoryTest.h" // must come after s11n.h - the FactoryTest.h for why #define SERIALIZE(Node,SType,SObj) ::P::s11n::serialize< NODE_TYPE >( Node, SObj ) #define DESERIALIZE(Node,SType) ::P::s11n::deserialize< NODE_TYPE, SType >( Node ) typedef ::P::s11n::io::data_node_serializer<NODE_TYPE> SerializerBase; -#define FACTORYTEST_NO_REGISTER - -// struct TheBase -// { - -// virtual ~TheBase() {} -// virtual std::string classname() const = 0; - -// }; - -// 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"; } -// }; - - -struct TheBase_s11n -{ - bool operator()( NODE_TYPE & dest, const TheBase & src ) const - { - return src.serialize( dest ); - } - - bool operator()( const NODE_TYPE & src, TheBase & dest ) const - { - return dest.deserialize( src ); - } -}; - -#define PS11N_TYPE TheBase -#define PS11N_TYPE_IS_ABSTRACT -#define PS11N_TYPE_NAME "TheBase" -#define PS11N_SERIALIZE_FUNCTOR TheBase_s11n -#include <pclasses/s11n/reg_serializable_traits.h> - -#define PS11N_TYPE AType -#define PS11N_TYPE_INTERFACE TheBase -#define PS11N_TYPE_NAME "AType" -#include <pclasses/s11n/reg_serializable_traits.h> - -#define PS11N_TYPE BType -#define PS11N_TYPE_INTERFACE TheBase -#define PS11N_TYPE_NAME "BType" -#include <pclasses/s11n/reg_serializable_traits.h> bool test_load( const std::string & fn ) { Index: FactoryTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/FactoryTest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FactoryTest.cpp 26 Dec 2004 05:02:59 -0000 1.7 +++ FactoryTest.cpp 26 Dec 2004 06:00:55 -0000 1.8 @@ -13,7 +13,6 @@ #include <pclasses/Plugin/Plugin.h> - int main( int argc, char ** argv ) { CERR << "Factory tests...\n"; @@ -21,26 +20,31 @@ TheBase * a = 0; + typedef P::NamedTypeFactory<TheBase> NTF; + typedef P::Plugin::PluginManager<TheBase> PM; + + PM & pm = PM::instance(); + std::string dllname = "SumDumDLL"; + pm.alias( dllname, "CType" ); + #define CLOAD(CN) a = P::CL::classload<TheBase>( CN ); \ CERR << CN << " classload("<<CN<<")ed? == " << a << "\n"; \ if( a ) CERR << "classname="<<a->classname()<<"\n"; \ delete( a ); a = 0; - typedef P::NamedTypeFactory<TheBase> NTF; #define NTLOAD(CN) a = NTF::instance().create( CN ); \ CERR << CN << " NamedTypeFactory::create("<<CN<<")ed? == " << a << "\n"; \ if( a ) CERR << "classname="<<a->classname()<<"\n"; \ delete( a ); a = 0; - typedef P::Plugin::PluginManager<TheBase> PM; #define PLOAD(CN) a = PM::instance().create( CN ); \ CERR << CN << " PluginManager::create("<<CN<<")ed? == " << a << "\n"; \ if( a ) CERR << "classname="<<a->classname()<<"\n"; \ delete( a ); a = 0; -#define LOAD(CN) NTLOAD(CN); CLOAD(CN); +#define LOAD(CN) PLOAD(CN); CLOAD(CN); #if 0 try @@ -64,7 +68,7 @@ } #endif - LOAD("CType"); // should load ./CType.so + LOAD(dllname); // should load ./CType.so LOAD("DefaultDocumentType"); // should return a (C*) LOAD("TheBase"); LOAD("AType"); Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Makefile.toc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.toc 26 Dec 2004 05:02:59 -0000 1.7 +++ Makefile.toc 26 Dec 2004 06:00:55 -0000 1.8 @@ -32,16 +32,11 @@ ifeq (1,$(build_bins)) BIN_PROGRAMS = FactoryTest PtrTest s11nTest BIN_PROGRAMS_LDADD = $(LIBP_TESTS_LDADD) -# Can't do these until i get the linker flags imported via toc: -# PtrTest - FactoryTest_bin_OBJECTS = FactoryTest.o - FactoryTest_bin_LDADD = $(LIBPSYSTEM_CLIENT_LDADD) -# $(LIBPSYSTEM_CLIENT_LDADD) + FactoryTest_bin_OBJECTS = FactoryTest.o registrations.o + FactoryTest_bin_LDADD = $(LIBPSYSTEM_CLIENT_LDADD) $(LIBPS11N_CLIENT_LDADD) PtrTest_bin_OBJECTS = PtrTest.o PtrTest_bin_LDADD = $(LIBPSYSTEM_CLIENT_LDADD) - - s11nTest_bin_OBJECTS = s11nTest.o $(LIBPS11N_CLIENT_LDADD) $(LIBPSYSTEM_CLIENT_LDADD) - + s11nTest_bin_OBJECTS = s11nTest.o registrations.o $(LIBPS11N_CLIENT_LDADD) $(LIBPSYSTEM_CLIENT_LDADD) include $(TOC_MAKESDIR)/BIN_PROGRAMS.make endif Index: FactoryTest.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/FactoryTest.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FactoryTest.h 26 Dec 2004 05:02:59 -0000 1.3 +++ FactoryTest.h 26 Dec 2004 06:00:55 -0000 1.4 @@ -10,6 +10,11 @@ #endif #include <pclasses/Factory.h> + +#ifndef USE_S11N +# define USE_S11N 0 +#endif + #include <pclasses/s11n/s11n.h> #define NODE_TYPE ::P::s11n::s11n_node @@ -21,6 +26,7 @@ virtual ~TheBase() {} virtual std::string classname() const = 0; + virtual bool serialize( NODE_TYPE & dest ) const { NODETR::class_name( dest, this->classname() ); @@ -35,6 +41,26 @@ }; + +struct TheBase_s11n +{ + bool operator()( NODE_TYPE & dest, const TheBase & src ) const + { + return src.serialize( dest ); + } + + bool operator()( const NODE_TYPE & src, TheBase & dest ) const + { + return dest.deserialize( src ); + } +}; + +#define PS11N_TYPE TheBase +#define PS11N_TYPE_IS_ABSTRACT +#define PS11N_TYPE_NAME "TheBase" +#define PS11N_SERIALIZE_FUNCTOR TheBase_s11n +#include <pclasses/s11n/reg_serializable_traits.h> + struct AType : public TheBase { AType() @@ -65,19 +91,19 @@ }; -#ifndef PCLASSES_S11N_INCLUDED -// avoid duplicate registrations... -# 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> +// #ifndef PCLASSES_S11N_INCLUDED +// // avoid duplicate registrations... +// # 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> -#endif // PCLASSES_S11N_INCLUDED +// # define PFACREG_TYPE BType +// # define PFACREG_TYPE_INTERFACE TheBase +// # define PFACREG_TYPE_NAME "BType" +// # include <pclasses/FactoryReg.h> +// #endif // PCLASSES_S11N_INCLUDED #endif // ptest_FACTORYTEST_HPP_INCLUDED Index: CType.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/CType.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CType.cpp 25 Dec 2004 01:57:09 -0000 1.2 +++ CType.cpp 26 Dec 2004 06:00:55 -0000 1.3 @@ -1,6 +1,6 @@ #include "FactoryTest.h" - +#include <pclasses/s11n/s11n.h> struct CType : public BType { @@ -31,8 +31,12 @@ 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> +// #define PFACREG_TYPE CType +// #define PFACREG_TYPE_INTERFACE TheBase +// #define PFACREG_TYPE_NAME "CType" +// #include <pclasses/FactoryReg.h> +#define PS11N_TYPE CType +#define PS11N_TYPE_INTERFACE TheBase +#define PS11N_TYPE_NAME "CType" +#include <pclasses/s11n/reg_serializable_traits.h> |