You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: stephan b. <sg...@us...> - 2004-12-26 01:44:04
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8801/include/pclasses/Util Modified Files: LexT.h Log Message: Changed s11n registration to use P::s11n. Index: LexT.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/LexT.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LexT.h 25 Dec 2004 01:03:27 -0000 1.1 +++ LexT.h 26 Dec 2004 01:43:53 -0000 1.2 @@ -468,19 +468,19 @@ //////////////////////////////////////////////////////////////////////// -#ifdef s11n_S11N_INCLUDED // <--- that macro was added in s11n 0.9.7 +#ifdef PCLASSES_S11N_INCLUDED # ifndef p_UTIL_LEXT_REGISTERED_WITH_S11N # define p_UTIL_LEXT_REGISTERED_WITH_S11N 1 // We have s11n! Let's use it! // Plug in a proxy for LexT, to make it work like a Streamable... -# include <s11n.net/s11n/data_node_functor.hpp> // <-- s11n::streamable_type_serialization_proxy class -# include <s11n.net/s11n/pods_streamable.hpp> // <-- required for s11n 0.9.14+ -# define S11N_TYPE lext::LexT // <-- type of object to be treated as a Serializable -# define S11N_TYPE_NAME "LexT" // <-- class name (for the classloader) -# define S11N_SERIALIZE_FUNCTOR ::s11n::streamable_type_serialization_proxy -// ^^^^ our de/s11n implementation (proxy functor) -# include <s11n.net/s11n/reg_serializable_traits.hpp> // <-- register the above data with s11n +# include <pclasses/s11n/data_node_functor.h> // <-- s11n::streamable_type_serialization_proxy class +# include <pclasses/s11n/pods_streamable.h> // <-- required for s11n 0.9.14+ +# define PS11N_TYPE ::P::Util::LexT // <-- type of object to be treated as a Serializable +# define PS11N_TYPE_NAME "LexT" // <-- class name (for the classloader) +# define PS11N_SERIALIZE_FUNCTOR ::P::s11n::streamable_type_serialization_proxy + // ^^^^ our de/s11n implementation (proxy functor) +# include <pclasses/s11n/reg_serializable_traits.h> // <-- register the above data with s11n # endif // p_UTIL_LEXT_REGISTERED_WITH_S11N -#endif // s11n_S11N_INCLUDED +#endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// |
From: stephan b. <sg...@us...> - 2004-12-26 01:43:45
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8735/src/s11n Modified Files: classload.h pods_streamable.h s11n.h test.cpp traits.h Log Message: list/vector/set/multiset de/ser working again. Index: classload.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/classload.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- classload.h 26 Dec 2004 01:26:14 -0000 1.3 +++ classload.h 26 Dec 2004 01:43:29 -0000 1.4 @@ -120,7 +120,7 @@ template <typename InterfaceType, typename SubType> void classloader_register( const std::string & classname ) { - classloader<InterfaceType>().registerRactory( + classloader<InterfaceType>().registerFactory( classname, ::P::Hook::FactoryCreateHook<InterfaceType,SubType>::create ); Index: test.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/test.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test.cpp 26 Dec 2004 01:26:52 -0000 1.1 +++ test.cpp 26 Dec 2004 01:43:29 -0000 1.2 @@ -1,10 +1,13 @@ -#include "s11n.h" -#include "s11n_node.h" -#include "s11n_debuggering_macros.h" - +#include <pclasses/s11n/s11n.h> +#include <pclasses/s11n/s11n_node.h> +#include <pclasses/s11n/s11n_debuggering_macros.h> +#include <pclasses/s11n/list.h> +#include <pclasses/s11n/pods_streamable.h> +#include <pclasses/Util/LexT.h> #include <memory> // auto_ptr #include <cassert> +#include <list> #define NODE_TYPE ::P::s11n::s11n_node #define SERIALIZE(Node,SType,SObj) ::P::s11n::serialize< NODE_TYPE >( Node, SObj ) @@ -100,5 +103,23 @@ BAP b2 = BAP( DESERIALIZE(node,TheBase) ); assert( b2.get() && "Deserialize failed :(" ); CERR << "Deser workie!\n"; + + + TRAITS::clear(node); + + using ::P::Util::LexT; + typedef std::list<LexT> ListT; + ListT list; + for( int i = 0; i < 10; i++ ) + { + list.push_back( LexT( std::string("this is item #") + LexT(i).str() ) ); + } + assert( SERIALIZE(node,ListT,list) ); + list.clear(); + + bool worked = ::P::s11n::deserialize( node, list ); + assert( worked && "deser list failed :(" ); + CERR << "list.size() == " << list.size()<<"\n"; + return 0; } Index: traits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/traits.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- traits.h 26 Dec 2004 00:55:20 -0000 1.2 +++ traits.h 26 Dec 2004 01:43:29 -0000 1.3 @@ -292,7 +292,7 @@ Removes all children and properties from node, freeing up their resources. */ - static void clear ( node_type & node ) + static void clear( node_type & node ) { node.clear(); } Index: s11n.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- s11n.h 26 Dec 2004 01:26:15 -0000 1.3 +++ s11n.h 26 Dec 2004 01:43:29 -0000 1.4 @@ -11,6 +11,8 @@ // The s11n namespace docs go here so doxygen will pick them up nicely. //////////////////////////////////////////////////////////////////////// +#define PCLASSES_S11N_INCLUDED 1 + #include <string> namespace P { Index: pods_streamable.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/pods_streamable.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pods_streamable.h 26 Dec 2004 01:26:15 -0000 1.2 +++ pods_streamable.h 26 Dec 2004 01:43:29 -0000 1.3 @@ -1,4 +1,4 @@ -#if !defined(s11n_PODS_STREAMABLE_HPP_INCLUDED) +#if !defined(p_PODS_STREAMABLE_HPP_INCLUDED) #define p_PODS_STREAMABLE_HPP_INCLUDED 1 //////////////////////////////////////////////////////////////////////// // pod.h: default POD proxies. @@ -72,4 +72,4 @@ #undef PS11N_PODS_STREAMABLE_PROXY -#endif // s11n_PODS_STREAMABLE_HPP_INCLUDED +#endif // p_PODS_STREAMABLE_HPP_INCLUDED |
From: stephan b. <sg...@us...> - 2004-12-26 01:28:46
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7081/include/pclasses Modified Files: pclasses-config.h.at Log Message: Added PACKAGE_{NAME,VERSION} Index: pclasses-config.h.at =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/pclasses-config.h.at,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pclasses-config.h.at 25 Dec 2004 16:47:11 -0000 1.6 +++ pclasses-config.h.at 26 Dec 2004 01:28:34 -0000 1.7 @@ -9,6 +9,8 @@ # undef _ALL_SOURCE #endif +#define PCLASSES_PACKAGE_NAME "@PACKAGE_NAME@" +#define PCLASSES_PACKAGE_VERSION "@PACKAGE_VERSION@" #define PCLASSES_INSTALL_PREFIX "@prefix@" #define PCLASSES_LIB_DIR "@prefix@/lib" #define PCLASSES_SHARED_DATA_DIR "@prefix@/share/pclasses" |
From: stephan b. <sg...@us...> - 2004-12-26 01:27:11
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6895/src/s11n Added Files: test.cpp Log Message: egg: P::s11n works :) --- NEW FILE: test.cpp --- #include "s11n.h" #include "s11n_node.h" #include "s11n_debuggering_macros.h" #include <memory> // auto_ptr #include <cassert> #define NODE_TYPE ::P::s11n::s11n_node #define SERIALIZE(Node,SType,SObj) ::P::s11n::serialize< NODE_TYPE >( Node, SObj ) #define DESERIALIZE(Node,SType) ::P::s11n::deserialize< NODE_TYPE, SType >( Node ) #define TRAITS ::P::s11n::node_traits< NODE_TYPE > struct TheBase { virtual ~TheBase() {} virtual std::string classname() const = 0; virtual bool serialize( NODE_TYPE & dest ) const { TRAITS::class_name( dest, this->classname() ); return true; } virtual bool deserialize( const NODE_TYPE & dest ) { CERR << "Deserializing " << TRAITS::class_name( dest ) << "\n"; return true; } }; 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 "reg_serializable_traits.h" #define PS11N_TYPE AType #define PS11N_TYPE_INTERFACE TheBase #define PS11N_TYPE_NAME "AType" #include "reg_serializable_traits.h" #define PS11N_TYPE BType #define PS11N_TYPE_INTERFACE TheBase #define PS11N_TYPE_NAME "BType" #include "reg_serializable_traits.h" /// i wish i could make this a P::App... int main( int argc, char ** argv ) { CERR << "P::s11n tests...\n"; typedef std::auto_ptr<TheBase> BAP; BAP b1 = BAP( new AType ); NODE_TYPE node; assert( SERIALIZE(node,TheBase,b1.get() ) ); CERR << "Serialize Workie!\n"; BAP b2 = BAP( DESERIALIZE(node,TheBase) ); assert( b2.get() && "Deserialize failed :(" ); CERR << "Deser workie!\n"; return 0; } |
From: stephan b. <sg...@us...> - 2004-12-26 01:26:39
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6787/src/s11n Modified Files: classload.h list.h Makefile.toc map.h pods_streamable.h reg_list_specializations.h reg_map_specializations.h reg_serializable_traits.h s11n.h Log Message: mass commit: it works :) Index: reg_map_specializations.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_map_specializations.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- reg_map_specializations.h 26 Dec 2004 00:55:20 -0000 1.2 +++ reg_map_specializations.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -1,15 +1,15 @@ // a supermacro to generate some partial template specializations for map-type classes. -#ifndef S11N_MAP_TYPE -#error "You must define S11N_MAP_TYPE before including this file. e.g., to std::map or std::multimap." +#ifndef PS11N_MAP_TYPE +#error "You must define PS11N_MAP_TYPE before including this file. e.g., to std::map or std::multimap." #endif -#ifndef S11N_MAP_TYPE_NAME -#error "You must define S11N_MAP_TYPE_NAME before including this file. e.g., to \"list\" or \"vector\"." +#ifndef PS11N_MAP_TYPE_NAME +#error "You must define PS11N_MAP_TYPE_NAME before including this file. e.g., to \"list\" or \"vector\"." #endif -#ifndef S11N_MAP_TYPE_PROXY -#define S11N_MAP_TYPE_PROXY ::P::s11n::map::map_serializable_proxy +#ifndef PS11N_MAP_TYPE_PROXY +#define PS11N_MAP_TYPE_PROXY ::P::s11n::map::map_serializable_proxy #endif namespace { // set up ::classname<>() @@ -17,19 +17,19 @@ //////////////////////////////////////////////////////////// - // S11N_MAP_TYPE + // PS11N_MAP_TYPE template <typename MapType, typename ValueType> - struct class_name< S11N_MAP_TYPE<MapType, ValueType> > + struct class_name< PS11N_MAP_TYPE<MapType, ValueType> > { - typedef S11N_MAP_TYPE<MapType, ValueType> named_type; + typedef PS11N_MAP_TYPE<MapType, ValueType> named_type; static const char * name() { static bool inited = false; if( (!inited) && (inited=true) ) { - ::P::s11n::cl::classloader_register_base< named_type >( S11N_MAP_TYPE_NAME ); + ::P::s11n::cl::classloader_register_base< named_type >( PS11N_MAP_TYPE_NAME ); } - return S11N_MAP_TYPE_NAME; + return PS11N_MAP_TYPE_NAME; } }; @@ -43,10 +43,10 @@ s11n_traits<> specialization for std::map types. */ template <typename KeyT, typename ValT> - struct s11n_traits < S11N_MAP_TYPE<KeyT,ValT> > + struct s11n_traits < PS11N_MAP_TYPE<KeyT,ValT> > { - typedef S11N_MAP_TYPE<KeyT,ValT> serializable_type; - typedef S11N_MAP_TYPE_PROXY serialize_functor; + typedef PS11N_MAP_TYPE<KeyT,ValT> serializable_type; + typedef PS11N_MAP_TYPE_PROXY serialize_functor; typedef serialize_functor deserialize_functor; typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; static const bool cl_reg_placeholder = (::classname<serializable_type>(),true) ; @@ -56,6 +56,6 @@ } // namespace s11n -#undef S11N_MAP_TYPE_PROXY -#undef S11N_MAP_TYPE_NAME -#undef S11N_MAP_TYPE +#undef PS11N_MAP_TYPE_PROXY +#undef PS11N_MAP_TYPE_NAME +#undef PS11N_MAP_TYPE Index: classload.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/classload.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- classload.h 26 Dec 2004 00:55:20 -0000 1.2 +++ classload.h 26 Dec 2004 01:26:14 -0000 1.3 @@ -60,7 +60,7 @@ { try { - return ::P::Factory<InterfaceType>::instance().create( classname ); + return ::P::Factory<InterfaceType, ::P::Sharing::FactoryContext, std::string >::instance().create( classname ); } catch(...) { Index: map.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/map.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- map.h 26 Dec 2004 00:55:20 -0000 1.2 +++ map.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -606,17 +606,17 @@ } } // namespace P::s11n -#define S11N_MAP_TYPE std::pair -#define S11N_MAP_TYPE_NAME "pair" -#define S11N_MAP_TYPE_PROXY ::P::s11n::map::pair_serializable_proxy +#define PS11N_MAP_TYPE std::pair +#define PS11N_MAP_TYPE_NAME "pair" +#define PS11N_MAP_TYPE_PROXY ::P::s11n::map::pair_serializable_proxy #include "reg_map_specializations.h" -#define S11N_MAP_TYPE std::map -#define S11N_MAP_TYPE_NAME "map" +#define PS11N_MAP_TYPE std::map +#define PS11N_MAP_TYPE_NAME "map" #include "reg_map_specializations.h" -#define S11N_MAP_TYPE std::multimap -#define S11N_MAP_TYPE_NAME "multimap" +#define PS11N_MAP_TYPE std::multimap +#define PS11N_MAP_TYPE_NAME "multimap" #include "reg_map_specializations.h" Index: reg_list_specializations.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_list_specializations.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- reg_list_specializations.h 26 Dec 2004 00:55:20 -0000 1.2 +++ reg_list_specializations.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -1,19 +1,19 @@ // a supermacro to generate some partial template specializations for list-type classes. -#ifndef S11N_LIST_TYPE -#error "You must define S11N_LIST_TYPE before including this file. e.g., to std::list or std::vector." +#ifndef PS11N_LIST_TYPE +#error "You must define PS11N_LIST_TYPE before including this file. e.g., to std::list or std::vector." #endif -#ifndef S11N_LIST_TYPE_NAME -#error "You must define S11N_LIST_TYPE_NAME before including this file. e.g., to \"list\" or \"vector\"." +#ifndef PS11N_LIST_TYPE_NAME +#error "You must define PS11N_LIST_TYPE_NAME before including this file. e.g., to \"list\" or \"vector\"." #endif -#ifndef S11N_LIST_TYPE_PROXY -#define S11N_LIST_TYPE_PROXY ::P::s11n::list::list_serializable_proxy +#ifndef PS11N_LIST_TYPE_PROXY +#define PS11N_LIST_TYPE_PROXY ::P::s11n::list::list_serializable_proxy #endif -// #ifndef S11N_LIST_REGISTRATION_FUNC_DEFINED -// # define S11N_LIST_REGISTRATION_FUNC_DEFINED 1 +// #ifndef PS11N_LIST_REGISTRATION_FUNC_DEFINED +// # define PS11N_LIST_REGISTRATION_FUNC_DEFINED 1 // namespace s11n { // namespace list { // template <typename T> @@ -25,7 +25,7 @@ // } // } // } -// #endif // S11N_LIST_REGISTRATION_FUNC_DEFINED +// #endif // PS11N_LIST_REGISTRATION_FUNC_DEFINED namespace { // set up ::classname<>() @@ -33,19 +33,19 @@ //////////////////////////////////////////////////////////// - // S11N_LIST_TYPE + // PS11N_LIST_TYPE template <typename ValueType > - struct class_name< S11N_LIST_TYPE< ValueType > > + struct class_name< PS11N_LIST_TYPE< ValueType > > { - typedef S11N_LIST_TYPE< ValueType > named_type; + typedef PS11N_LIST_TYPE< ValueType > named_type; static const char * name() { static bool inited = false; if( (!inited) && (inited=true) ) { - ::P::s11n::cl::classloader_register_base< named_type >( S11N_LIST_TYPE_NAME ); + ::P::s11n::cl::classloader_register_base< named_type >( PS11N_LIST_TYPE_NAME ); } - return S11N_LIST_TYPE_NAME; + return PS11N_LIST_TYPE_NAME; } }; @@ -60,10 +60,10 @@ s11n_traits<> specialization for std::list types. */ template <typename ValT > - struct s11n_traits < S11N_LIST_TYPE<ValT> > + struct s11n_traits < PS11N_LIST_TYPE<ValT> > { - typedef S11N_LIST_TYPE<ValT> serializable_type; - typedef S11N_LIST_TYPE_PROXY serialize_functor; + typedef PS11N_LIST_TYPE<ValT> serializable_type; + typedef PS11N_LIST_TYPE_PROXY serialize_functor; typedef serialize_functor deserialize_functor; typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; static const bool cl_reg_placeholder = (::classname<serializable_type>(),true) ; @@ -71,6 +71,6 @@ } } // namespace P::s11n -#undef S11N_LIST_TYPE_PROXY -#undef S11N_LIST_TYPE_NAME -#undef S11N_LIST_TYPE +#undef PS11N_LIST_TYPE_PROXY +#undef PS11N_LIST_TYPE_NAME +#undef PS11N_LIST_TYPE Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/Makefile.toc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.toc 26 Dec 2004 00:55:20 -0000 1.2 +++ Makefile.toc 26 Dec 2004 01:26:15 -0000 1.3 @@ -51,5 +51,10 @@ libpclasses_s11n_so_VERSION = $(PACKAGE_VERSION) include $(TOC_MAKESDIR)/SHARED_LIBS.make -all: symlink-headers SHARED_LIBS +BIN_PROGRAMS = test +test_bin_OBJECTS = test.o libpclasses_s11n.so +include $(TOC_MAKESDIR)/BIN_PROGRAMS.make + +all: symlink-headers SHARED_LIBS BIN_PROGRAMS + Index: list.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/list.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- list.h 26 Dec 2004 00:55:20 -0000 1.2 +++ list.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -421,20 +421,20 @@ //////////////////////////////////////////////////////////////////////// // Register proxies for std-namespace sequence containers -#define S11N_LIST_TYPE std::list -#define S11N_LIST_TYPE_NAME "list" +#define PS11N_LIST_TYPE std::list +#define PS11N_LIST_TYPE_NAME "list" #include "reg_list_specializations.h" -#define S11N_LIST_TYPE std::vector -#define S11N_LIST_TYPE_NAME "vector" +#define PS11N_LIST_TYPE std::vector +#define PS11N_LIST_TYPE_NAME "vector" #include "reg_list_specializations.h" -#define S11N_LIST_TYPE std::set -#define S11N_LIST_TYPE_NAME "set" +#define PS11N_LIST_TYPE std::set +#define PS11N_LIST_TYPE_NAME "set" #include "reg_list_specializations.h" -#define S11N_LIST_TYPE std::multiset -#define S11N_LIST_TYPE_NAME "multiset" +#define PS11N_LIST_TYPE std::multiset +#define PS11N_LIST_TYPE_NAME "multiset" #include "reg_list_specializations.h" Index: pods_streamable.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/pods_streamable.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pods_streamable.h 26 Dec 2004 00:37:07 -0000 1.1 +++ pods_streamable.h 26 Dec 2004 01:26:15 -0000 1.2 @@ -20,56 +20,56 @@ #include "data_node_serialize.h" #include "data_node_functor.h" // s11n::streamable_type_serialization_proxy -#define S11N_PODS_STREAMABLE_PROXY s11n::streamable_type_serialization_proxy +#define PS11N_PODS_STREAMABLE_PROXY s11n::streamable_type_serialization_proxy -#define S11N_TYPE char -#define S11N_TYPE_NAME "char" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE char +#define PS11N_TYPE_NAME "char" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE bool -#define S11N_TYPE_NAME "bool" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE bool +#define PS11N_TYPE_NAME "bool" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE int -#define S11N_TYPE_NAME "int" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE int +#define PS11N_TYPE_NAME "int" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE size_t -#define S11N_TYPE_NAME "size_t" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE size_t +#define PS11N_TYPE_NAME "size_t" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE float -#define S11N_TYPE_NAME "float" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE float +#define PS11N_TYPE_NAME "float" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE double -#define S11N_TYPE_NAME "double" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE double +#define PS11N_TYPE_NAME "double" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE long -#define S11N_TYPE_NAME "long" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE long +#define PS11N_TYPE_NAME "long" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE ulong -#define S11N_TYPE_NAME "ulong" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE ulong +#define PS11N_TYPE_NAME "ulong" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#define S11N_TYPE std::string -#define S11N_TYPE_NAME "string" -#define S11N_SERIALIZE_FUNCTOR S11N_PODS_STREAMABLE_PROXY +#define PS11N_TYPE std::string +#define PS11N_TYPE_NAME "string" +#define PS11N_SERIALIZE_FUNCTOR PS11N_PODS_STREAMABLE_PROXY #include "reg_serializable_traits.h" -#undef S11N_PODS_STREAMABLE_PROXY +#undef PS11N_PODS_STREAMABLE_PROXY #endif // s11n_PODS_STREAMABLE_HPP_INCLUDED Index: s11n.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- s11n.h 26 Dec 2004 00:55:20 -0000 1.2 +++ s11n.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -85,9 +85,10 @@ } } // namespace P::s11n #include "classload.h" -// #include "data_node.h" // reference Data Node implementation -// #include "s11n_node.h" // Another reference Data Node implementation -// #include "data_node_algo.h" // reference NodeType implementation -// #include "data_node_serialize.h" // serialize() and friends +#include "traits.h" +#include "data_node.h" // reference Data Node implementation +#include "s11n_node.h" // Another reference Data Node implementation +#include "data_node_algo.h" // reference NodeType implementation +#include "data_node_serialize.h" // serialize() and friends #endif // p_S11N_H_INCLUDED Index: reg_serializable_traits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_serializable_traits.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- reg_serializable_traits.h 26 Dec 2004 00:55:20 -0000 1.2 +++ reg_serializable_traits.h 26 Dec 2004 01:26:15 -0000 1.3 @@ -6,31 +6,31 @@ // // Vars used by this file: // -// S11N_TYPE: type to be registered +// PS11N_TYPE: type to be registered // -// S11N_TYPE_NAME: stringified name of S11N_TYPE +// PS11N_TYPE_NAME: stringified name of PS11N_TYPE // -// S11N_BASE_TYPE: if S11N_TYPE subclasses a regisitered S11N_TYPE, +// PS11N_TYPE_INTERFACE: if PS11N_TYPE subclasses a regisitered PS11N_TYPE, // pass it here. If this is set then the rest of the following // variables need not be set, as they are inherited. // -// S11N_SERIALIZE_FUNCTOR: functor type responsible for handling calls -// to serialize<S11N_TYPE>(). Default is +// PS11N_SERIALIZE_FUNCTOR: functor type responsible for handling calls +// to serialize<PS11N_TYPE>(). Default is // s11n::default_serialize_functor, which simply calls -// S11N_TYPE::operator()( NodeT & ). +// PS11N_TYPE::operator()( NodeT & ). // -// S11N_DESERIALIZE_FUNCTOR: functor type responsible for handling calls -// to serialize(). Defaults to S11N_SERIALIZE_FUNCTOR. +// PS11N_DESERIALIZE_FUNCTOR: functor type responsible for handling calls +// to serialize(). Defaults to PS11N_SERIALIZE_FUNCTOR. // -// S11N_FACTORY_TYPE: functor which is responsible for instantiating -// objects of type S11N_TYPE. Default behaviour is to use -// s11n::cl::object_factory< S11N_BASE_TYPE >. +// PS11N_FACTORY_TYPE: functor which is responsible for instantiating +// objects of type PS11N_TYPE. Default behaviour is to use +// s11n::cl::object_factory< PS11N_TYPE_INTERFACE >. // // THINGS TO KNOW: // // - If the default factory type is NOT used, the caller is -// responsible for registering S11N_TYPE with the appropriate factory, -// using the key S11N_TYPE_NAME. +// responsible for registering PS11N_TYPE with the appropriate factory, +// using the key PS11N_TYPE_NAME. // //////////////////////////////////////////////////////////////////////// // The s11n header files are expected to have been included by the @@ -39,36 +39,36 @@ // // Sample usage: // -// #define S11N_TYPE std::map<Foo,Bar> -// #define S11N_TYPE_NAME "std::map<Foo,Bar>" +// #define PS11N_TYPE std::map<Foo,Bar> +// #define PS11N_TYPE_NAME "std::map<Foo,Bar>" // #include [this file] // // // repeat for each type: -// #define S11N_TYPE std::map<Foo *,Bar *> -// #define S11N_TYPE_NAME "std::map<Foo*,Bar*>" -// #define S11N_SERIALIZE_FUNCTOR some_functor_name +// #define PS11N_TYPE std::map<Foo *,Bar *> +// #define PS11N_TYPE_NAME "std::map<Foo*,Bar*>" +// #define PS11N_SERIALIZE_FUNCTOR some_functor_name // #include [this file] // -// If S11N_TYPE is a subtype of another Serializable, +// If PS11N_TYPE is a subtype of another Serializable, // and should be available via that base-type's classloader // (Yes, you normally WANT this) then define this macro: // -// S11N_BASE_TYPE +// PS11N_TYPE_INTERFACE // -// to the type name of S11N_TYPE's BaseType. +// to the type name of PS11N_TYPE's BaseType. // -// If S11N_BASE_TYPE is not set then the following macros +// If PS11N_TYPE_INTERFACE is not set then the following macros // are also used: // -// #define S11N_SERIALIZE_FUNCTOR some_serializer_functor -// #define S11N_DESERIALIZE_FUNCTOR some_deserializer_functor +// #define PS11N_SERIALIZE_FUNCTOR some_serializer_functor +// #define PS11N_DESERIALIZE_FUNCTOR some_deserializer_functor // -// If S11N_DESERIALIZE_FUNCTOR is defined, that is used -// as the Deserialization proxy, otherwise S11N_SERIALIZE_FUNCTOR +// If PS11N_DESERIALIZE_FUNCTOR is defined, that is used +// as the Deserialization proxy, otherwise PS11N_SERIALIZE_FUNCTOR // functor is used for both cases. // // If neither are set then ::P::s11n::default_serialize_functor -// is installed, and S11N_TYPE must conform to that proxy's +// is installed, and PS11N_TYPE must conform to that proxy's // expectations. // // After each include all of these macros are unset so that they may @@ -76,43 +76,43 @@ //////////////////////////////////////////////////////////////////////// -#ifndef S11N_TYPE -# error "S11N_TYPE must be set before including this file." +#ifndef PS11N_TYPE +# error "PS11N_TYPE must be set before including this file." #endif -#ifndef S11N_TYPE_NAME -# ifdef S11N_NAME // older convention -# define S11N_TYPE_NAME S11N_NAME -# undef S11N_NAME +#ifndef PS11N_TYPE_NAME +# ifdef PS11N_NAME // older convention +# define PS11N_TYPE_NAME PS11N_NAME +# undef PS11N_NAME # else -# error "S11N_TYPE_NAME must be set before including this file. Set it to the stringified form of S11N_TYPE." +# error "PS11N_TYPE_NAME must be set before including this file. Set it to the stringified form of PS11N_TYPE." # endif #endif -// S11N_BASE_TYPE only needs to be set when registering subtypes of an +// PS11N_TYPE_INTERFACE only needs to be set when registering subtypes of an // already-registered base type... -#ifdef S11N_BASE_TYPE -# define S11N_INHERIT 1 +#ifdef PS11N_TYPE_INTERFACE +# define PS11N_INHERIT 1 #else -# define S11N_BASE_TYPE S11N_TYPE -# define S11N_INHERIT 0 -# ifndef S11N_SERIALIZE_FUNCTOR -# define S11N_SERIALIZE_FUNCTOR ::P::s11n::default_serialize_functor +# define PS11N_TYPE_INTERFACE PS11N_TYPE +# define PS11N_INHERIT 0 +# ifndef PS11N_SERIALIZE_FUNCTOR +# define PS11N_SERIALIZE_FUNCTOR ::P::s11n::default_serialize_functor # endif -# ifndef S11N_DESERIALIZE_FUNCTOR -# define S11N_DESERIALIZE_FUNCTOR S11N_SERIALIZE_FUNCTOR +# ifndef PS11N_DESERIALIZE_FUNCTOR +# define PS11N_DESERIALIZE_FUNCTOR PS11N_SERIALIZE_FUNCTOR # endif -#endif // S11N_BASE_TYPE +#endif // PS11N_TYPE_INTERFACE -#ifndef S11N_FACTORY_TYPE +#ifndef PS11N_FACTORY_TYPE // then register a factory of our own... -# define S11N_REG_CLLITE 1 -# define S11N_FACTORY_TYPE s11n::cl::object_factory< S11N_BASE_TYPE > +# define PS11N_REG_CLLITE 1 +# define PS11N_FACTORY_TYPE ::P::s11n::cl::object_factory< PS11N_TYPE_INTERFACE > #else -# define S11N_REG_CLLITE 0 -#endif // S11N_FACTORY_TYPE +# define PS11N_REG_CLLITE 0 +#endif // PS11N_FACTORY_TYPE //////////////////////////////////////////////////////////////////////// @@ -120,65 +120,56 @@ namespace P {namespace s11n { template <> - struct s11n_traits < S11N_TYPE > -#if S11N_INHERIT - : public s11n_traits < S11N_BASE_TYPE > + struct s11n_traits < PS11N_TYPE > +#if PS11N_INHERIT + : public ::P::s11n::s11n_traits < PS11N_TYPE_INTERFACE > #endif { -#if ! S11N_INHERIT - typedef S11N_TYPE serializable_type; - typedef S11N_SERIALIZE_FUNCTOR serialize_functor; - typedef S11N_DESERIALIZE_FUNCTOR deserialize_functor; - typedef S11N_FACTORY_TYPE factory_type; -#endif // S11N_INHERIT -// #if S11N_REG_CLLITE -// static bool cl_reg_placeholder; -// #endif // S11N_REG_CLLITE +#if ! PS11N_INHERIT + typedef PS11N_TYPE serializable_type; + typedef PS11N_SERIALIZE_FUNCTOR serialize_functor; + typedef PS11N_DESERIALIZE_FUNCTOR deserialize_functor; + typedef PS11N_FACTORY_TYPE factory_type; +#endif // PS11N_INHERIT }; -// #if S11N_REG_CLLITE -// bool s11n_traits< S11N_TYPE >::cl_reg_placeholder = -// (s11n::cl::classloader_register< S11N_BASE_TYPE, S11N_TYPE >( S11N_TYPE_NAME ), -// (CERR << "registering " << S11N_TYPE_NAME << "\n"), -// true); -// #endif // S11N_REG_CLLITE } } // namespace P::s11n // end s11n_traits<> //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -// Register the type's name with ::classname<S11N_TYPE>(). +// Register the type's name with ::classname<PS11N_TYPE>(). // This is highly unfortunate, but currently required. -#define NAME_TYPE S11N_TYPE -#define TYPE_NAME S11N_TYPE_NAME -#include <s11n.net/name_type/name_type.h> +#define NAME_TYPE PS11N_TYPE +#define TYPE_NAME PS11N_TYPE_NAME +#include "name_type.h" //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -#if S11N_REG_CLLITE +#if PS11N_REG_CLLITE // register with default classloader... -# define CL_TYPE S11N_TYPE -# define CL_TYPE_NAME S11N_TYPE_NAME -# define CL_BASE_TYPE S11N_BASE_TYPE -# ifdef S11N_ABSTRACT_BASE -# define CL_ABSTRACT_BASE 1 +# define PFACREG_TYPE PS11N_TYPE +# define PFACREG_TYPE_NAME PS11N_TYPE_NAME +# define PFACREG_TYPE_INTERFACE PS11N_TYPE_INTERFACE +# ifdef PS11N_TYPE_IS_ABSTRACT +# define PFACREG_TYPE_IS_ABSTRACT 1 # endif -# include <s11n.net/cl/cllite_reg.h> -#endif // S11N_REG_CLLITE +# include <pclasses/FactoryReg.h> +#endif // PS11N_REG_CLLITE //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // clean up for the next #include ... -#undef S11N_TYPE -#undef S11N_TYPE_NAME -#undef S11N_BASE_TYPE -#undef S11N_SERIALIZE_FUNCTOR -#undef S11N_DESERIALIZE_FUNCTOR -#undef S11N_FACTORY_TYPE -#undef S11N_INHERIT -#undef S11N_REG_CLLITE -#ifdef S11N_ABSTRACT_BASE -# undef S11N_ABSTRACT_BASE +#undef PS11N_TYPE +#undef PS11N_TYPE_NAME +#undef PS11N_TYPE_INTERFACE +#undef PS11N_SERIALIZE_FUNCTOR +#undef PS11N_DESERIALIZE_FUNCTOR +#undef PS11N_FACTORY_TYPE +#undef PS11N_INHERIT +#undef PS11N_REG_CLLITE +#ifdef PS11N_TYPE_IS_ABSTRACT +# undef PS11N_TYPE_IS_ABSTRACT #endif |
From: stephan b. <sg...@us...> - 2004-12-26 00:56:13
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2626/src/s11n Removed Files: node_traits_wrapper.h reg_node_type.h sam_std_containers.h Log Message: long-obsoleted artefact code. --- sam_std_containers.h DELETED --- --- reg_node_type.h DELETED --- --- node_traits_wrapper.h DELETED --- |
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2428/src/s11n Modified Files: Makefile.toc abstract_creator.h algo.h classload.h data_node.cpp data_node.h data_node_algo.h data_node_functor.h data_node_serialize.h functor.h list.h map.h pointer_stripper.h reg_list_specializations.h reg_map_specializations.h reg_serializable_traits.h s11n.cpp s11n.h s11n_debuggering_macros.h s11n_node.cpp s11n_node.h traits.h valarray.h Log Message: whew - moved namespace s11n ==> P::s11n. Index: s11n_node.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n_node.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- s11n_node.cpp 26 Dec 2004 00:37:07 -0000 1.1 +++ s11n_node.cpp 26 Dec 2004 00:55:20 -0000 1.2 @@ -6,7 +6,7 @@ #include "s11n_node.h" -namespace s11n { +namespace P { namespace s11n { #define NODE_CLASS_NAME "s11n::s11n_node" // note that the default implclass is not useable for purposes of classloading // serializables, but: @@ -159,6 +159,6 @@ return this->m_map.end(); } -} // namespace s11n +} } // namespace P::s11n #undef NODE_CLASS_NAME Index: data_node_serialize.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_serialize.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node_serialize.h 26 Dec 2004 00:37:07 -0000 1.1 +++ data_node_serialize.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -30,6 +30,7 @@ #define NODEERR if(0) CERR // ^^^ a debugging macro +namespace P { namespace { // anon namespace important for linking reasons, to avoid ODR violations. /*** @@ -401,8 +402,8 @@ } -} // namespace s11n +}} // namespace P::s11n #undef NODEERR -#endif // s11n_DATA_SERIALIZE_H_INCLUDED +#endif // p_DATA_SERIALIZE_H_INCLUDED Index: s11n_node.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n_node.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- s11n_node.h 26 Dec 2004 00:37:07 -0000 1.1 +++ s11n_node.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -13,12 +13,10 @@ #include <vector> #include "str.h" // to/from() string -namespace s11n { +namespace P { namespace s11n { /** - EXPERIMENTAL: Not for use in client code! - - s11n_node is a reference Data Node implementation intended + s11n_node is a reference Data Node implementation intended for use with s11n::node_traits. */ class s11n_node @@ -300,6 +298,6 @@ }; // class s11n_node -} // namespace s11n +} } // namespace s11n #endif // s11n_S11N_NODE_HPP_INCLUDED Index: abstract_creator.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/abstract_creator.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- abstract_creator.h 26 Dec 2004 00:37:07 -0000 1.1 +++ abstract_creator.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -13,6 +13,7 @@ #include "classload.h" // classloader-related funcs #include "class_name.h" +namespace P { namespace s11n { @@ -145,7 +146,7 @@ ? implclass : ::classname<value_type>(); - v = ::s11n::cl::classload<base_value_type>( key ); + v = ::P::s11n::cl::classload<base_value_type>( key ); if( 0 ) CERR << "create(*) implclass=["<<key<<"] allocated @" <<std::hex<<&v <<"\n"; return 0 != &v; } @@ -162,7 +163,7 @@ }; // abstract_creator<T *> -} // namespace +} } // namespace P::s11n -#endif // s11n_ABSTRACT_CREATOR_H_INCLUDED +#endif // p_ABSTRACT_CREATOR_H_INCLUDED Index: reg_map_specializations.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_map_specializations.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- reg_map_specializations.h 26 Dec 2004 00:37:07 -0000 1.1 +++ reg_map_specializations.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -9,7 +9,7 @@ #endif #ifndef S11N_MAP_TYPE_PROXY -#define S11N_MAP_TYPE_PROXY ::s11n::map::map_serializable_proxy +#define S11N_MAP_TYPE_PROXY ::P::s11n::map::map_serializable_proxy #endif namespace { // set up ::classname<>() @@ -27,7 +27,7 @@ static bool inited = false; if( (!inited) && (inited=true) ) { - ::s11n::cl::classloader_register_base< named_type >( S11N_MAP_TYPE_NAME ); + ::P::s11n::cl::classloader_register_base< named_type >( S11N_MAP_TYPE_NAME ); } return S11N_MAP_TYPE_NAME; } @@ -48,7 +48,7 @@ typedef S11N_MAP_TYPE<KeyT,ValT> serializable_type; typedef S11N_MAP_TYPE_PROXY serialize_functor; typedef serialize_functor deserialize_functor; - typedef ::s11n::cl::object_factory<serializable_type> factory_type; + typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; static const bool cl_reg_placeholder = (::classname<serializable_type>(),true) ; }; Index: data_node.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node.h 26 Dec 2004 00:37:07 -0000 1.1 +++ data_node.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -17,6 +17,7 @@ #include <pclasses/Util/LexT.h> #include "functor.h" // some helpful functors +namespace P { namespace s11n { /** @@ -544,11 +545,11 @@ }; // class data_node -} // namespace s11n +} } // namespace P::s11n #include "traits.h" -namespace s11n { +namespace P { namespace s11n { /** A node_traits specialization for @@ -680,6 +681,6 @@ }; // end node_traits<s11n::data_node> -} // namespace s11n +} } // namespace P::s11n -#endif // s11n_DATA_NODE_H_INCLUDED +#endif // p_DATA_NODE_H_INCLUDED Index: classload.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/classload.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- classload.h 26 Dec 2004 00:37:07 -0000 1.1 +++ classload.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -4,6 +4,7 @@ #include <pclasses/Factory.h> // default classloader/factory implementation. +namespace P { namespace s11n { /** @@ -164,7 +165,7 @@ } // namespace cl -} // namespace s11n +} } // namespace P::s11n #endif // s11n_cl_S11N_CLASSLOAD_HPP_INCLUDED Index: s11n_debuggering_macros.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n_debuggering_macros.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- s11n_debuggering_macros.h 26 Dec 2004 00:37:07 -0000 1.1 +++ s11n_debuggering_macros.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -5,17 +5,6 @@ // decorative. #ifndef CERR #define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " -#define CERRL(A) CERR << A << std::endl; -#endif - -#ifndef COUT -#define COUT std::cout << __FILE__ << ":" << std::dec << __LINE__ << " : " -#define COUTL(A) COUT << A << std::endl; -#endif - -#ifndef DTOROUT -#define DTOR_DEBUG 0 -#define DTOROUT(CLASSNAME) if(DTOR_DEBUG) CERR << "~" << # CLASSNAME << "() " #endif #endif // s11n_DEBUGGERING_MACROS_H Index: valarray.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/valarray.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- valarray.h 26 Dec 2004 00:37:07 -0000 1.1 +++ valarray.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -22,7 +22,7 @@ static std::string n = "valarray"; if( !cl_reg_placeholder && (cl_reg_placeholder=true) ) { - ::s11n::cl::classloader_register< + ::P::s11n::cl::classloader_register< valarray_type,valarray_type >( n ); } @@ -33,7 +33,7 @@ bool class_name< std::valarray<VT> >::cl_reg_placeholder = (::classname< std::valarray<VT> >(),true); } // anonymous ns -namespace s11n { +namespace P { namespace s11n { /** s11n::va encapsulates de/serialization operators for @@ -132,13 +132,13 @@ struct s11n_traits < std::valarray<ValueType> > { typedef std::valarray<ValueType> serializable_type; - typedef ::s11n::va::valarray_serializable_proxy serialize_functor; + typedef ::P::s11n::va::valarray_serializable_proxy serialize_functor; typedef serialize_functor deserialize_functor; - typedef ::s11n::cl::object_factory<serializable_type> factory_type; + typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; }; -} // namespace s11n +} } // namespace P::s11n Index: map.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/map.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- map.h 26 Dec 2004 00:37:07 -0000 1.1 +++ map.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -23,6 +23,7 @@ #include "class_name.h" +namespace P { namespace s11n { @@ -317,7 +318,7 @@ template <typename NodeType, typename PairType> bool deserialize_pair( const NodeType & src, PairType & dest ) { - typedef ::s11n::node_traits<NodeType> NTR; + typedef ::P::s11n::node_traits<NodeType> NTR; //CERR << "deserialize_pair: deserialize " << src.impl_class() << "\n"; typedef typename PairType::first_type FT; typedef typename PairType::second_type ST; @@ -374,7 +375,7 @@ { CERR << "deserialize_pair(): deserialize(node, second) failed. "; // "Node name=["<<NTR::name(*ch)<<"] class=["<<implclass<<"].\n"; - ::s11n::dump_node_debug( *ch, std::cerr ); + ::P::s11n::dump_node_debug( *ch, std::cerr ); AC1st::release( f ); AC2nd::release( s ); return false; @@ -603,11 +604,11 @@ -} // namespace s11n +} } // namespace P::s11n #define S11N_MAP_TYPE std::pair #define S11N_MAP_TYPE_NAME "pair" -#define S11N_MAP_TYPE_PROXY ::s11n::map::pair_serializable_proxy +#define S11N_MAP_TYPE_PROXY ::P::s11n::map::pair_serializable_proxy #include "reg_map_specializations.h" #define S11N_MAP_TYPE std::map Index: s11n.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- s11n.cpp 26 Dec 2004 00:37:07 -0000 1.1 +++ s11n.cpp 26 Dec 2004 00:55:20 -0000 1.2 @@ -2,6 +2,7 @@ #include "s11n.h" #include <pclasses/pclasses-config.h> +namespace P { namespace s11n { std::string library_version() @@ -9,4 +10,4 @@ return PCLASSES_PACKAGE_VERSION; } -} // namespace s11n +} } // namespace P::s11n Index: algo.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/algo.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- algo.h 26 Dec 2004 00:37:07 -0000 1.1 +++ algo.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -11,6 +11,7 @@ #include "functor.h" // object_deleter() +namespace P { namespace s11n { @@ -92,6 +93,6 @@ } -} +} } // P::s11n -#endif // s11n_ALGO_H_INCLUDED +#endif // p_ALGO_H_INCLUDED Index: pointer_stripper.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/pointer_stripper.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pointer_stripper.h 26 Dec 2004 00:37:07 -0000 1.1 +++ pointer_stripper.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -1,6 +1,7 @@ #ifndef p_POINTER_STRIPPER_H_INCLUDED #define p_POINTER_STRIPPER_H_INCLUDED 1 +namespace P { namespace s11n { /** Helper class to strip pointers from value_type @@ -45,6 +46,6 @@ typedef T value_type; }; -} +} } #endif // s11n_POINTER_STRIPPER_H_INCLUDED Index: traits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/traits.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- traits.h 26 Dec 2004 00:37:07 -0000 1.1 +++ traits.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -7,6 +7,7 @@ #include "classload.h" // default classloader/factory implementation. +namespace P { namespace s11n { /** @@ -348,7 +349,7 @@ registered via the s11n::cl::classload() family of functions. */ - typedef ::s11n::cl::object_factory<serializable_type> factory_type; + typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; /** Functor type implementing serialize code. @@ -358,7 +359,7 @@ bool operator()( SomeNodeType & dest, const base_type & src ) const; */ - typedef ::s11n::default_serialize_functor serialize_functor; + typedef ::P::s11n::default_serialize_functor serialize_functor; /** Functor type implementing deserialize code. @@ -367,7 +368,7 @@ bool operator()( const SomeNodeType & src, base_type & dest ) const; */ - typedef ::s11n::default_serialize_functor deserialize_functor; + typedef ::P::s11n::default_serialize_functor deserialize_functor; }; // end s11n_traits<> // namespace Private @@ -426,7 +427,7 @@ // }; -} // namespace s11n +} } // namespace P::s11n #endif // s11n_S11N_TRAITS_HPP_INCLUDED Index: reg_list_specializations.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_list_specializations.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- reg_list_specializations.h 26 Dec 2004 00:37:07 -0000 1.1 +++ reg_list_specializations.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -9,7 +9,7 @@ #endif #ifndef S11N_LIST_TYPE_PROXY -#define S11N_LIST_TYPE_PROXY ::s11n::list::list_serializable_proxy +#define S11N_LIST_TYPE_PROXY ::P::s11n::list::list_serializable_proxy #endif // #ifndef S11N_LIST_REGISTRATION_FUNC_DEFINED @@ -21,7 +21,7 @@ // { // const char * cn = ::classname<T>(); // CERR << "register_list_type<>("<<cn<<")\n"; -// ::s11n::cl::classloader_register_base< T >( cn ); +// ::P::s11n::cl::classloader_register_base< T >( cn ); // } // } // } @@ -43,7 +43,7 @@ static bool inited = false; if( (!inited) && (inited=true) ) { - ::s11n::cl::classloader_register_base< named_type >( S11N_LIST_TYPE_NAME ); + ::P::s11n::cl::classloader_register_base< named_type >( S11N_LIST_TYPE_NAME ); } return S11N_LIST_TYPE_NAME; } @@ -52,6 +52,7 @@ } // anon namespace +namespace P { namespace s11n { @@ -64,11 +65,11 @@ typedef S11N_LIST_TYPE<ValT> serializable_type; typedef S11N_LIST_TYPE_PROXY serialize_functor; typedef serialize_functor deserialize_functor; - typedef ::s11n::cl::object_factory<serializable_type> factory_type; + typedef ::P::s11n::cl::object_factory<serializable_type> factory_type; static const bool cl_reg_placeholder = (::classname<serializable_type>(),true) ; }; -} // namespace s11n +} } // namespace P::s11n #undef S11N_LIST_TYPE_PROXY #undef S11N_LIST_TYPE_NAME Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 26 Dec 2004 00:37:07 -0000 1.1 +++ Makefile.toc 26 Dec 2004 00:55:20 -0000 1.2 @@ -19,7 +19,6 @@ pods_streamable.h \ reg_list_specializations.h \ reg_map_specializations.h \ - reg_node_type.h \ reg_serializable_traits.h \ s11n_debuggering_macros.h \ s11n_node.h \ Index: data_node_algo.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_algo.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node_algo.h 26 Dec 2004 00:37:07 -0000 1.1 +++ data_node_algo.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -23,6 +23,7 @@ // NO DEPS ON data_node.h ALLOWED! //////////////////////////////////////////////////////////////////////// +namespace P { namespace s11n { @@ -139,6 +140,6 @@ } -} // namespace s11n +}} // namespace s11n -#endif // s11n_DATA_ALGO_H_INCLUDED +#endif // p_DATA_ALGO_H_INCLUDED Index: list.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/list.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- list.h 26 Dec 2004 00:37:07 -0000 1.1 +++ list.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -23,6 +23,7 @@ #include <pclasses/Util/LexT.h> +namespace P { namespace s11n { @@ -188,12 +189,12 @@ if( 0 ) { ERRPRE << "child node="<<std::hex<<nch<<std::dec<<", deserialized to ser. implclass="<<implclass<<". It's data node says:\n"; - ::s11n::dump_node_debug( *nch, std::cerr ); + ::P::s11n::dump_node_debug( *nch, std::cerr ); } } if( 0 ) { CERR << "deserialize_list(). INPUT Node tree looks something like:\n"; - ::s11n::dump_node_debug( src, std::cerr ); + ::P::s11n::dump_node_debug( src, std::cerr ); } ERRPRE <<"returning true. dest list size="<<dest.size()<<"...\n"; #undef ERRPRE @@ -416,7 +417,7 @@ } // namespace list -} // namespace s11n +}} // namespace P::s11n //////////////////////////////////////////////////////////////////////// // Register proxies for std-namespace sequence containers Index: data_node_functor.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_functor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node_functor.h 26 Dec 2004 00:37:07 -0000 1.1 +++ data_node_functor.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -33,6 +33,7 @@ // NO DEPS ON data_node.h ALLOWED! //////////////////////////////////////////////////////////////////////// +namespace P { namespace s11n { /** @@ -315,7 +316,7 @@ -} // namespace s11n +} } // namespace s11n -#endif // s11n_DATA_NODE_FUNCTOR_H_INCLUDED +#endif // p_DATA_NODE_FUNCTOR_H_INCLUDED Index: data_node.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node.cpp 26 Dec 2004 00:37:07 -0000 1.1 +++ data_node.cpp 26 Dec 2004 00:55:20 -0000 1.2 @@ -9,7 +9,7 @@ #include "data_node_functor.h" // functors to serialize data_nodes. -namespace s11n { +namespace P { namespace s11n { #define NODE_IMPL_CLASS "s11n::data_node" // note that the default implclass is not useable for purposes of classloading // serializables, but: @@ -280,4 +280,4 @@ -} // namespace s11n +} } // namespace P::s11n Index: s11n.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- s11n.h 26 Dec 2004 00:37:07 -0000 1.1 +++ s11n.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -13,6 +13,7 @@ #include <string> +namespace P { /** The s11n serialization (s11n) framework is an object serialization framework modelled heavily off work by Rusty Ballinger @@ -81,15 +82,12 @@ */ namespace io { } -} +} } // namespace P::s11n #include "classload.h" // #include "data_node.h" // reference Data Node implementation // #include "s11n_node.h" // Another reference Data Node implementation // #include "data_node_algo.h" // reference NodeType implementation // #include "data_node_serialize.h" // serialize() and friends -// #include "data_node_io.h" // i/o-related interfaces -// #include "data_node_format.h" // tree_builder and related classes -// #include "serializers.h" // default serializers/parsers. -#endif // s11n_S11N_H_INCLUDED +#endif // p_S11N_H_INCLUDED Index: functor.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/functor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- functor.h 26 Dec 2004 00:37:07 -0000 1.1 +++ functor.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -9,6 +9,7 @@ #include <string> #include "s11n_debuggering_macros.h" +namespace P { namespace s11n { @@ -368,6 +369,6 @@ }; -} // namespace s11n +} } // namespace P::s11n -#endif // s11n_FUNCTOR_H_INCLUDED +#endif // p_FUNCTOR_H_INCLUDED Index: reg_serializable_traits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/reg_serializable_traits.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- reg_serializable_traits.h 26 Dec 2004 00:37:07 -0000 1.1 +++ reg_serializable_traits.h 26 Dec 2004 00:55:20 -0000 1.2 @@ -67,7 +67,7 @@ // as the Deserialization proxy, otherwise S11N_SERIALIZE_FUNCTOR // functor is used for both cases. // -// If neither are set then ::s11n::default_serialize_functor +// If neither are set then ::P::s11n::default_serialize_functor // is installed, and S11N_TYPE must conform to that proxy's // expectations. // @@ -98,7 +98,7 @@ # define S11N_BASE_TYPE S11N_TYPE # define S11N_INHERIT 0 # ifndef S11N_SERIALIZE_FUNCTOR -# define S11N_SERIALIZE_FUNCTOR ::s11n::default_serialize_functor +# define S11N_SERIALIZE_FUNCTOR ::P::s11n::default_serialize_functor # endif # ifndef S11N_DESERIALIZE_FUNCTOR # define S11N_DESERIALIZE_FUNCTOR S11N_SERIALIZE_FUNCTOR @@ -117,7 +117,7 @@ //////////////////////////////////////////////////////////////////////// // Set up s11n_traits<> specialization... -namespace s11n { +namespace P {namespace s11n { template <> struct s11n_traits < S11N_TYPE > @@ -143,7 +143,7 @@ // true); // #endif // S11N_REG_CLLITE -} // namespace s11n +} } // namespace P::s11n // end s11n_traits<> //////////////////////////////////////////////////////////////////////// |
From: stephan b. <sg...@us...> - 2004-12-26 00:37:41
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32468/src Modified Files: Makefile.toc Log Message: added s11n subdir. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Makefile.toc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.toc 24 Dec 2004 23:06:26 -0000 1.7 +++ Makefile.toc 26 Dec 2004 00:37:32 -0000 1.8 @@ -2,7 +2,7 @@ include toc.make -SUBDIRS = Unicode IO System Util Net +SUBDIRS = Unicode IO System Util Net s11n # Plugins SOURCES = Alloc.cpp \ |
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32352/src/s11n Added Files: abstract_creator.h algo.h classload.h class_name.h data_node_algo.h data_node.cpp data_node_functor.h data_node.h data_node_serialize.h functor.h list.h Makefile.toc map.h name_type.h node_traits_wrapper.h pods_streamable.h pointer_stripper.h reg_list_specializations.h reg_map_specializations.h reg_node_type.h reg_serializable_traits.h s11n.cpp s11n_debuggering_macros.h s11n.h s11n_node.cpp s11n_node.h sam_std_containers.h str.h string_util.cpp string_util.h traits.h valarray.h Log Message: egg --- NEW FILE: s11n_node.cpp --- #include <algorithm> // for_each #include <iterator> #include "functor.h" // object_deleter, child_pointer_deep_copier #include "s11n_node.h" namespace s11n { #define NODE_CLASS_NAME "s11n::s11n_node" // note that the default implclass is not useable for purposes of classloading // serializables, but: // a) the parsers need some text to read. // b) "raw" nodes are often useful for de/ser'ing maps, lists, etc. // c) Serializables must set their implclass *anyway*, so they will // (or should) always overwrite the default class. s11n_node::s11n_node( const std::string & name ) : m_name(name),m_iname(NODE_CLASS_NAME) { } s11n_node::s11n_node( const std::string & name, const std::string implclass ) : m_name( name ), m_iname( implclass ) { } s11n_node::s11n_node() : m_name("s11n_node"), m_iname(NODE_CLASS_NAME) { } s11n_node & s11n_node::operator=( const s11n_node & rhs ) { if( &rhs == this ) return *this; this->copy( rhs ); return *this; } s11n_node::s11n_node( const s11n_node & rhs ) { if( &rhs == this ) return; this->copy( rhs ); } s11n_node::~s11n_node() { this->clear_children(); } s11n_node::map_type & s11n_node::properties() { return this->m_map; } const s11n_node::map_type & s11n_node::properties() const { return this->m_map; } void s11n_node::copy( const s11n_node & rhs ) { if ( &rhs == this ) return; this->clear(); this->name( rhs.name() ); this->class_name( rhs.class_name() ); std::copy( rhs.begin(), rhs.end(), std::insert_iterator<map_type>( this->m_map, this->m_map.begin() ) ); std::for_each( rhs.children().begin(), rhs.children().end(), s11n::child_pointer_deep_copier<child_list_type>( this->children() ) ); } s11n_node::child_list_type & s11n_node::children() { return this->m_children; } const s11n_node::child_list_type & s11n_node::children() const { return this->m_children; } void s11n_node::clear() { this->clear_children(); this->clear_properties(); } void s11n_node::class_name( const std::string & n ) { this->m_iname = n; } std::string s11n_node::class_name()const { return this->m_iname; } void s11n_node::name( const std::string & n ) { this->m_name = n; } std::string s11n_node::name() const { return this->m_name; } bool s11n_node::is_set( const std::string & key ) const { return this->m_map.end() != this->m_map.find( key ); } void s11n_node::unset( const std::string & key ) { s11n_node::map_type::iterator iter; iter = m_map.find( key ); if ( iter == m_map.end() ) return; m_map.erase( iter ); return; } void s11n_node::clear_properties() { if ( m_map.empty() ) return; m_map.erase( m_map.begin(), m_map.end() ); } void s11n_node::clear_children() { std::for_each( this->children().begin(), this->children().end(), s11n::object_deleter() ); this->children().clear(); } s11n_node::iterator s11n_node::begin() { return this->m_map.begin(); } s11n_node::const_iterator s11n_node::begin() const { return this->m_map.begin(); } s11n_node::iterator s11n_node::end() { return this->m_map.end(); } s11n_node::const_iterator s11n_node::end() const { return this->m_map.end(); } } // namespace s11n #undef NODE_CLASS_NAME --- NEW FILE: data_node_serialize.h --- #ifndef p_DATA_SERIALIZE_H_INCLUDED #define p_DATA_SERIALIZE_H_INCLUDED //////////////////////////////////////////////////////////////////////// // data_node_serialize.h: // // Defines the core de/serialize() functions (and close friends). // // License: Public Domain // Author: st...@s1... //////////////////////////////////////////////////////////////////////// #include <string> #include <list> #include <map> #include <deque> #include <cassert> #include <typeinfo> #include "s11n_debuggering_macros.h" // COUT/CERR #include "class_name.h" // ::classname<>() #include "classload.h" // classload() #include "traits.h" // s11n_traits //////////////////////////////////////////////////////////////////////////////// // NO DEPS ON data_node.h/s11n_node.h ALLOWED! //////////////////////////////////////////////////////////////////////////////// #define NODEERR if(0) CERR // ^^^ a debugging macro namespace { // anon namespace important for linking reasons, to avoid ODR violations. /*** s11n_api_marshaler is OBSOLETED (as of version 0.9.3) by s11n_traits. It is implemented in terms of s11n_traits for backwards compatibility, but it will be phased out at some point. For the default implementation s11n_traits<SerializableT> is used to marshal the de/serialize() calls. */ template <typename SerializableT> struct s11n_api_marshaler { /** Same as SerializableT. */ typedef SerializableT serializable_type; /** Returns s11n_traits<serializable_type>::serialize_functor()( dest, src ). It also sets dest's class_name() to ::classname<serializable_type>(), but this is only suitable for monomorphic serializable_types. */ template <typename NodeType> static bool serialize( NodeType &dest, const serializable_type & src ) { typedef s11n::node_traits<NodeType> NTR; typedef s11n::s11n_traits<serializable_type> STR; NTR::class_name( dest, ::classname<serializable_type>() ); // only good for monomorphs return STR::serialize_functor()( dest, src ); } /** Returns s11n_traits<SerializableT>::deserialize_functor()( src, dest ). */ template <typename NodeType> static bool deserialize( const NodeType & src, serializable_type & dest ) { typedef s11n::s11n_traits<serializable_type> STR; return STR::deserialize_functor()( src, dest ); } }; /** A specialization to handle pointer types the same as reference/value types. It simply translates the pointers into references. */ template <typename SerializableT> struct s11n_api_marshaler<SerializableT *> { /** The SerializableT templatized type, minus any pointer part. */ typedef SerializableT serializable_type; /** Convenience typedef: this class' parent type. */ typedef s11n_api_marshaler<serializable_type> parent_type; /** Returns parent_type::serialize( dest, *src ); src must be a valid pointer. */ template <typename NodeType> static bool serialize( NodeType &dest, const serializable_type * src ) { if( ! src ) return false; return parent_type::serialize( dest, *src ); } /** Returns parent_type::deserialize( src, *dest ); dest must be a valid pointer. */ template <typename NodeType> static bool deserialize( const NodeType & src, serializable_type * dest ) { if( ! dest ) return false; return parent_type::deserialize( src, *dest ); } }; } // anon namespace /********************************************************************** General Conventions: NodeType should conform to the conventions laid out by s11n::data_node. SerializableTypes/BaseTypes: - BaseT must have the following in it's interface: - bool SerializeFunction( NodeType & dest ) const; - bool DeserializeFunction( const NodeType & dest ); SerializeFunction/DeserializeFunction need not be virtual, though they may be. Proxy functors: Serialization functor must have: bool operator()( NodeType & dest, const BaseT & src ) const; Deserialization functor must have: bool operator()( const NodeType & src, BaseT & dest ) const; They may be the same functor type - const resolution will determine which s11n uses. Sometimes this causes ambiguity, and may require 2 functors. These signatures apply for all functors designed to work as de/serializers. **********************************************************************/ namespace s11n { /** Returns func( target, src ). Note that using this function bypasses internal API marshalling for src. This is, however, useful in some cases. Note that if src initiates recursive serialization on objects of it's own type the framework will revert to using it's API marshalling, bypassing SerializerFunctorT. A solution is sought for this problem, but none exists yet. */ template <typename DataNodeType,typename SerializableT, typename SerializerFunctorT> bool serialize( DataNodeType & target, const SerializableT & src, const SerializerFunctorT & func ) { try { return func( target, src ); } catch(...) { CERR << "Unknown exception during serialize<>(DataNode,SerializableT,SerializerFunctorT)!\n"; return false; } } /** Returns func( src, target ). Note that using this function bypasses internal API marshalling for the target. This is, however, useful in some cases. See the complementary form of serialize() for important information regarding recursive deserialization. */ template <typename DataNodeType, typename DeserializableT, typename DeserializerFunctorT> bool deserialize( const DataNodeType & src, DeserializableT & target, const DeserializerFunctorT & func ) { try { return func( src, target ); } catch(...) { CERR << "Unknown exception during deserialize<>(DataNode,DeserializableT,DeserializerFunctorT)!\n"; return false; } } /** Serializes src to target using the default API marshaling mechanism. */ template <typename DataNodeType, typename SerializableT> bool serialize( DataNodeType & target, const SerializableT & src ) { try { // typedef typename s11n_traits<SerializableT>::serialize_functor Proxy; // return serialize<DataNodeType,SerializableT,Proxy>( target, src, Proxy() ); // return Proxy()( target, src ); return s11n_api_marshaler<SerializableT>::serialize( target, src ); } catch(...) { CERR << "Unknown exception during serialize<>(DataNode,SerializableT)!\n"; return false; } } /** Deserializes target from src using the default API marshaling mechanism. */ template <typename DataNodeType, typename DeserializableT> bool deserialize( const DataNodeType & src, DeserializableT & target ) { try { // typedef typename s11n_traits<DeserializableT>::deserialize_functor Proxy; // return deserialize<DataNodeType,DeserializableT,Proxy>( src, target, Proxy() ); // return Proxy()( src, target ); return s11n_api_marshaler<DeserializableT>::deserialize( src, target ); } catch(...) { CERR << "Unknown exception during deserialize<>(DataNode,DeserializableT)!\n"; return false; } } /** Tries to deserialize a DeserializableT from src, using <code>s11n_traits<DeserializableT>::factory_type()(node_traits<DataNodeType>::class_name(src))</code> to create a new DeserializableT. Returns 0 on error, otherwise returns a pointer to a new object, which the caller takes ownership of. */ template <typename DataNodeType, typename DeserializableT> DeserializableT * deserialize( const DataNodeType & src ) { typedef s11n_traits<DeserializableT> STR; typedef node_traits<DataNodeType> NTR; DeserializableT * obj = STR::factory_type()( NTR::class_name( src ) ); if( ! obj ) { NODEERR << "deserialize<>(DataNode): impl class '" << NTR::class_name( src )<<"' classload failed.\n" << "It is probably not registered with it's base classloader.\n"; return 0; } if( ! deserialize<DataNodeType,DeserializableT>( src, *obj ) ) { NODEERR << "deserialize<>(DataNode): failed for unknown reason.\n"; delete( obj ); // must not throw! obj = 0; } return obj; } /** Serializes src to as a subnode of target, named nodename. Except for the addition of a subnode, it is identical to serialize( target, src ). This is a convenience function: not part of the s11n kernel. */ template <typename DataNodeType, typename SerializableT > bool serialize_subnode( DataNodeType & target, const std::string & nodename, const SerializableT & src ) { NODEERR << "serialize_subnode<>(DataNodeType, '"<<nodename<<"', SerializableT)\n"; DataNodeType * sub = new DataNodeType; typedef node_traits<DataNodeType> NT; NT::name( *sub, nodename ); if( ! serialize<DataNodeType,SerializableT>( *sub, src ) ) { delete( sub ); sub = 0; } else { target.children().push_back( sub ); } return sub != 0; } /** If a child named subnodename is found in src then this function returns deserialize( child, target ) and returns it's result, otherwise it returns 0. This is a convenience function: not part of the s11n kernel. */ template <typename DataNodeType, typename DeserializableT> bool deserialize_subnode( const DataNodeType & src, const std::string & subnodename, DeserializableT & target ) { const DataNodeType * ch = find_child_by_name( src, subnodename ); if( ! ch ) return false; return deserialize<DataNodeType,DeserializableT>( *ch, target ); } /** If a child named subnodename is found in src then this function returns the result of deserialize(child), otherwise it returns 0. This is a convenience function: not part of the s11n kernel. */ template <typename DataNodeType, typename DeserializableT> DeserializableT * deserialize_subnode( const DataNodeType & src, const std::string & subnodename ) { const DataNodeType * ch = find_child_by_name( src, subnodename ); if( ! ch ) return false; return deserialize<DataNodeType,DeserializableT>( *ch ); } /** Clones an arbitrary SerializableType using it's DataNodeType serialization implementation. Returns a clone of tocp, or returns 0 on error. The caller owns the returned pointer. This copy is polymorphism-safe as long as all participating Serializables (re)implement the appropriate de/serialize operations, similarly to as they would do for a copy ctor or classical Clone() member function. Tip: clone() is a convenient way to test new de/serialize functions, e.g., for new Serializables, because if it works then deserializing from streams/files will also work. This function takes SerializableType through the whole de/serialize process, including classloading. */ template <typename DataNodeType, typename SerializableType> SerializableType * clone( const SerializableType & tocp ) { DataNodeType node; if( ! serialize( node, tocp ) ) return 0; return deserialize<DataNodeType,SerializableType>( node ); } /** "Casts" t1 to t2 using serialization. This will work whenever t1 and t2 are "semantically compatible", whatever that really means. It can be used, e.g., to copy a list<int> to a vector<double>, provided both types have been proxied. Note that in the case of containers, the pointerness of the contained types is irrelevant: this works on both, thus a list<int> can be "cast" to a vector<double*>. As usual for a failed deserialization, if it returns false then t2 may be in an undefined state. There is no guaranty, however, that t2's deserialize operator will ever be called, as the serialization of t1 must first succeed for that to happen. */ template <typename NodeType, typename Type1, typename Type2> bool s11n_cast( const Type1 & t1, Type2 & t2 ) { NodeType n; return serialize<NodeType,Type1>( n, t1 ) && deserialize<NodeType,Type2>( n, t2 ); } } // namespace s11n #undef NODEERR #endif // s11n_DATA_SERIALIZE_H_INCLUDED --- NEW FILE: s11n_node.h --- #ifndef p_S11N_NODE_HPP_INCLUDED #define p_S11N_NODE_HPP_INCLUDED //////////////////////////////////////////////////////////////////////// // s11n_node.h // A reference implementation for s11n's Data Node concept. // License: Public Domain // Author: st...@s1... //////////////////////////////////////////////////////////////////////// #include <string> #include <map> #include <vector> #include "str.h" // to/from() string namespace s11n { /** EXPERIMENTAL: Not for use in client code! s11n_node is a reference Data Node implementation intended for use with s11n::node_traits. */ class s11n_node { public: /** The map type this object uses to store properties. */ typedef std::map < std::string, std::string > map_type; /** A pair type used to store key/value properties internally. */ typedef map_type::value_type value_type; /** The type used to store property keys. For compatibility with std::map. */ typedef map_type::key_type key_type; /** The type used to internally store property values. For compatibility with std::map. */ typedef map_type::mapped_type mapped_type; /** The container type used to store this object's children. It contains (s11n_node *). While the exact type is not guaranteed, it is guaranteed to obey the most-commonly-used std::list/vector conventions: push_back(), erase(), etc. */ typedef std::vector<s11n_node *> child_list_type; /** For iterating over properties using STL conventions. Dereferences to a value_type object. */ typedef map_type::iterator iterator; /** For iterating over properties using STL conventions. Dereferences to a value_type object. */ typedef map_type::const_iterator const_iterator; /** Creates a new node with an empty name() and an class_name() of "s11n::s11n_node". This node is functionally useless until it's name is set, as nodes with empty names are not supported by any current i/o parsers. */ s11n_node(); /** Creates a new node with the given name() and an class_name() of "s11n::s11n_node". */ explicit s11n_node( const std::string & name ); /** Creates a new node with the given name() and and class_name(). Does not throw. */ s11n_node( const std::string & name, const std::string implclass ); /** Destroys all child objects owned by this object, freeing up their resources. Does not throw. */ ~s11n_node(); /** Copies the properties, name, class name and children of rhs. If rhs is this object then this function does nothing. Does not throw. */ s11n_node & operator=( const s11n_node & rhs ); /** See copy(). Does not throw. */ s11n_node( const s11n_node & rhs ); /** Returns a list of the s11n_node children of this object. The caller should not delete any pointers from this list unless he also removes the pointers from the list, or else they will get double-deleted later. In practice it is (almost) never necessary for client code to manipulate this list directly. */ child_list_type & children(); /** The const form of children(). */ const child_list_type & children() const; /** Removes all properties and deletes all children from this object, freeing up their resources. Any pointers to children of this object become invalided by a call to this function (they get deleted). */ void clear(); /** Defines the class name which should be used as the implementation class when this node is deserialize()d. Client Serializable types should call this one time from their serialize() method, <em>after</em> calling the parent class' serialize() method (if indeed that is called at all), passing it the name of their class, <em>using the name expected by the classloader</em>. By convention the class name is the same as it's C++ name, thus Serializable class foo::FooBar should call: <pre> node.class_name( "foo::FooBar" ); </pre> from it's serialize() function. If classes to not set this then the serialized data will not have a proper implementation class name. That *will* break deserialization. */ void class_name( const std::string & n ); /** Returns the implementation class name set via class_name(). */ std::string class_name() const; /** The name which should be used as the key for storing the node. This is normally translated to something like an XML element name (e.g., <name>), and should not contain spaces or other characters which may not be usable as key names. To be safe, stick to alphanumeric and underscores, starting with a letter or underscore. (This class does no enforce any naming conventions, but your data file parsers very well may.) */ void name( const std::string & n ); /** Returns this node's name, as set via name(string). */ std::string name() const; /** Lexically casts val to a string and stores it as a property. If this type conversion is not possible it will fail at compile time. A value-conversion failure, on the other hand, is not caught at compile time. T must support complementary ostream<< and istream>> operators. */ template < typename T > void set( const std::string & key, const T & val ) { this->m_map[key] = str::to(val); } /** Tries to get a property named key and lexically cast it to type T. If this type conversion is not possible it will fail at compile time. A value-conversion failure, on the other hand, is not caught at compile time. If value conversion fails, or if the requested property is not set, then defaultval is returned. This can be interpretted as an error value if the client so chooses, and it is often helpful to pass a known-invalid value here for that purpose. */ template < typename T > T get( const std::string & key, const T & defaultval ) const { const_iterator cit = this->m_map.find( key ); return ( this->m_map.end() == cit ) ? defaultval : str::from( (*cit).second, defaultval); } /** Returns true if this object contains the given property, else false. */ bool is_set( const std::string & key ) const; /** Removes the given property from this object. */ void unset( const std::string & key ); /** Returns the first item in this object's property map. Note that the iterator represents a value_type (std::pair), so use (*it).first to get the key and (*it).second to get the value. */ iterator begin(); /** Returns a const_iterator pointing at this object's first property. */ const_iterator begin() const; /** * The after-the-end iterator for this object's properties. */ iterator end(); /** * The after-the-end iterator for this object's properties. */ const_iterator end() const; map_type & properties(); const map_type & properties() const; private: map_type m_map; // stores key/value properties. std::string m_name; // name of this node std::string m_iname; // class_name name of this node child_list_type m_children; // holds child pointers /** Copies all properties and child s11n_nodes from rhs into this object, as well as any other details which need to be copied. This can be a very expensive operation, and is rarely necessary. */ void copy( const s11n_node & rhs ); /** Removes all property entries from this object. */ void clear_properties(); /** Removes all children from this object, deleting all child pointers. */ void clear_children(); }; // class s11n_node } // namespace s11n #endif // s11n_S11N_NODE_HPP_INCLUDED --- NEW FILE: abstract_creator.h --- #ifndef p_ABSTRACT_CREATOR_H_INCLUDED #define p_ABSTRACT_CREATOR_H_INCLUDED 1 //////////////////////////////////////////////////////////////////////// // abstract_creatore.h: // Defines a difficult-to-describe class. See the docs. // // Author: stephan beal <st...@s1...> // License: Public Domain //////////////////////////////////////////////////////////////////////// #include <string> #include "classload.h" // classloader-related funcs #include "class_name.h" namespace s11n { /** abstract_creator is a helper to avoid some code having to know if a type is created on a stack or the heap. This makes some template code easier to write, as it avoids syntax errors when trying something like: <pre> if( object type is a pointer type ) delete(object); else { ... } </pre> This implementation creates items the stack via the default ctor. If instantiated with (T *) a pointer/heap-based specialization is activated instead. Designed for use with, e.g., ListType::value_type, which will may be, e.g., either T or (T *). These objects contain no state information. */ template <typename T> struct abstract_creator { /** Same as (T). */ typedef T value_type; /** Same as (T). */ typedef T base_value_type; /** This implementation assigns v to value_type() and returns true. The string argument is bogus for this implementation, and is used by the pointer specialization to implement polymorphic classloading of value_type. Historical note: before s11n release 0.9.17 this function incorrectly did nothing. While this works for many cases, it caused a subtle, hard-to-track bug in s11n::list::deserialize_list(), in which a deserialized list was re-used when the function was called recursively. Many thanks to Patrick Lin for reporting that problem. */ static bool create( value_type & v, const std::string & /* implclass */ = std::string() ) { // if( 0 ) CERR << "create(&) implclass="<<implclass<<": initializing @" <<std::hex<<&v <<"\n"; v = value_type(); return true; } /** Does nothing in this specialization. Specializations which allocate resources are expected to release them here. Note that release() exists because using a static boolean to flag a clean-up mode won't work: <pre> typedef double T; T val; if( val is a pointer type ) { delete( val ); } else ... </pre> That will only work when T is actually a pointer type. Thus the following workaround: <pre> typedef [some type] T; T val; typedef abstract_creator<T> AC; assert( AC::create(val) ); // fine for (T) or (T *) ... use val ... AC::release(val); // deletes pointers. No-op for value types </pre> That works with pointers or non-pointers, and simply does nothing for non-pointers. See object_reference_wrapper for a type which can wrap function calls to objects using the dot notation, regardless of their pointerness. */ static void release( value_type & ) { return; } }; // abstract_creator<T> /** A specialization of abstract_creator to create objects on the heap, using the s11n classloader. */ template <typename T> struct abstract_creator<T *> { /** Same as (T *). */ typedef T * value_type; /** Same as (T). */ typedef T base_value_type; /** Tries to create a value_type object, using classload<base_value_type>( key ) to create it. v is assigned to it's value, which may be 0. Returns true if an object is created, else false. The caller owns the returned object. Maintenance note: new classloader registrations may need to be installed as new types show up, especially for streamables/PODs (because those aren't normally registered as classes), or this function won't handle them. In s11n this registration is handled by most of the various proxy installation macros. */ static bool create( value_type & v, const std::string & implclass = std::string() /* guess! */ ) { const std::string key = (! implclass.empty()) ? implclass : ::classname<value_type>(); v = ::s11n::cl::classload<base_value_type>( key ); if( 0 ) CERR << "create(*) implclass=["<<key<<"] allocated @" <<std::hex<<&v <<"\n"; return 0 != &v; } /** Deletes v and assigns it to 0. */ static void release( value_type & v ) { //CERR << "release(" << std::hex<<v<<")\n"; delete( v ); v = 0; } }; // abstract_creator<T *> } // namespace #endif // s11n_ABSTRACT_CREATOR_H_INCLUDED --- NEW FILE: algo.h --- #ifndef p_ALGO_H_INCLUDED #define p_ALGO_H_INCLUDED 1 ///////////////////////////////////////////////////////////////////////// // algo.h: generic algorithms // Author: stephan beal <st...@s1...> // License: Public Domain ///////////////////////////////////////////////////////////////////////// #include <functional> // for_each() #include "functor.h" // object_deleter() namespace s11n { /** For each item in (begin,end] object_deleter()(*item) is called. After this call the container from which the iterators come still contains the items but they are invalid - deleted pointers. The client should call erase(begin,end) to delete the entries, or use convenience function free_list_entries(), which accepts a list-style container. */ template <typename IterT> void delete_objects( IterT begin, IterT end ) { std::for_each( begin, end, object_deleter() ); } /** For each item in [first,last), copies the item to OutputIt if pred(*item) returns true. Copied from: http://www.bauklimatik-dresden.de/privat/nicolai/html/en/cpp.html */ template <typename InputIt, typename OutputIt, typename UnaryPredicate> OutputIt copy_if (InputIt first, InputIt last, OutputIt result, UnaryPredicate pred) { while (first != last) { if (pred(*first)) *result++ = *first; ++first; } return result; } /** Deallocates all objects in list. If the entries are pointers they are deleted, else this is a no-op. After this call, list will be empty. */ template <typename ListType> void free_list_entries( ListType & list ) { object_reference_wrapper<ListType> wr(list); // in case ListType is a pointer type if( ! wr.good() ) return; delete_objects( wr().begin(), wr().end() ); wr().clear(); } /** Deletes any pointers in map, and does nothing for reference types, then calls map.clear(). This is used to treat arbitrary maps containing pointers or value types identically, by applying the same set of deallocation rules for both cases, simplifying some template implementations. After calling this, map will be empty. */ template <typename MapType> void free_map_entries( MapType & map ) { object_reference_wrapper<MapType> wr(map); // in case MapType is a pointer type if( ! wr.good() ) return; std::for_each( wr().begin(), wr().end(), pair_entry_deallocator() ); wr().clear(); } } #endif // s11n_ALGO_H_INCLUDED --- NEW FILE: reg_map_specializations.h --- // a supermacro to generate some partial template specializations for map-type classes. #ifndef S11N_MAP_TYPE #error "You must define S11N_MAP_TYPE before including this file. e.g., to std::map or std::multimap." #endif #ifndef S11N_MAP_TYPE_NAME #error "You must define S11N_MAP_TYPE_NAME before including this file. e.g., to \"list\" or \"vector\"." #endif #ifndef S11N_MAP_TYPE_PROXY #define S11N_MAP_TYPE_PROXY ::s11n::map::map_serializable_proxy #endif namespace { // set up ::classname<>() //////////////////////////////////////////////////////////// // S11N_MAP_TYPE template <typename MapType, typename ValueType> struct class_name< S11N_MAP_TYPE<MapType, ValueType> > { typedef S11N_MAP_TYPE<MapType, ValueType> named_type; static const char * name() { static bool inited = false; if( (!inited) && (inited=true) ) { ::s11n::cl::classloader_register_base< named_type >( S11N_MAP_TYPE_NAME ); } return S11N_MAP_TYPE_NAME; } }; } // anon namespace namespace s11n { /** s11n_traits<> specialization for std::map types. */ template <typename KeyT, typename ValT> struct s11n_traits < S11N_MAP_TYPE<KeyT,ValT> > { typedef S11N_MAP_TYPE<KeyT,ValT> serializable_type; typedef S11N_MAP_TYPE_PROXY serialize_functor; typedef serialize_functor deserialize_functor; typedef ::s11n::cl::object_factory<serializable_type> factory_type; static const bool cl_reg_placeholder = (::classname<serializable_type>(),true) ; }; } // namespace s11n #undef S11N_MAP_TYPE_PROXY #undef S11N_MAP_TYPE_NAME #undef S11N_MAP_TYPE --- NEW FILE: data_node.h --- #ifndef p_DATA_NODE_H_INCLUDED #define p_DATA_NODE_H_INCLUDED // data_node.h // License: Public Domain // Author: st...@s1... #include <string> #include <map> #include <vector> #include <cassert> #include <typeinfo> #include <pclasses/Util/LexT.h> #include "functor.h" // some helpful functors namespace s11n { /** data_node is the next generation of s11n::s11n_node. It is a pure container, without any de/serialization-related methods. It is non-polymorphic, in contrast to s11n_node. This type is a reference implementation for the functionality required of data nodes by the s11n core framework. Any type which conforms to this class' interface/conventions should be usable by s11n::serialize() and related functions. Common conventions for types "conventionally compatible" with data_node are listed below. - Should not throw exceptions, especially in the ctors/dtor. - Each node must have a name, accessible via name(), which "should" conform to common element naming conventions (alphanumeric/underscore). - Must be default constructable via new() and it must be safely deletable via delete(). - Must support deep copy operations, though specific optimizations (e.g. copy-on-write) are not excluded as long as their operation is transparent to client code. - Owns all of it's child pointers, or at least does not require client code to delete them. - Structured like a DOM element, with an arbitrary number of unique key/value pairs and an arbitrary number of child data_node objects (of the same base type as the parent node). - Property key and value types must be i/ostreamable, so as to inherently support easy conversion between strings and arbitrary types such as PODs and std::string, as well as user-defined streamable types. - Each node must have a proper impl_class() (documented at length elsewhere). - Should follow common std::map-style conventions for getting/setting properties, in addition to any other (convenience) interface. The type should provide begin()/end() iterator accessors for the properties. - Should support common std::list-style conventions for traversing child nodes. The conventional function for accessing the children list is named children(). - Need not be polymorphic, but it may be so. - Data nodes are not, by their nature, also Serializable (as such). Indeed, their whole purpose is store data for Serializable types. They ARE "serializable" in the sense that their key/value sets must be eventually convertable to some "external representation" (i.e., strings). - Should not be implemented as template types, for usability and maintenance reasons. One exception might be to go STL-style, and define it as a class template, but provide a typedef or subclass/specialization for the "standard" variant (as is the case for std::string). The first prototype of this library thought it would be clever to use s11n_node<SerializableType>, but i can promise you that causes Coding Hell down the road in client code if you ever try to mix different SerializableTypes in the same code.) More specific conventions will be detailed later in the library manual. */ class data_node { public: /** The map type this object uses to store items internally. */ typedef std::map < std::string, std::string > map_type; /** A pair type used to store key/value properties internally. */ typedef map_type::value_type value_type; /** For compatibility with std::map */ typedef map_type::key_type key_type; /** For compatibility with std::map */ typedef map_type::mapped_type mapped_type; /** The container type used to store this object's children. It contains (data_node *). While the exact type is not guaranteed, it is guaranteed to obey the most-commonly-used std::list/vector conventions: push_back(), erase(), etc. */ typedef std::vector<data_node *> child_list_type; /** For iterating over properties using STL conventions. Dereferences to a value_type object. */ typedef map_type::iterator iterator; /** For iterating over properties using STL conventions. Dereferences to a value_type object. */ typedef map_type::const_iterator const_iterator; /** Creates a new node with an empty name() and an impl_class() of "s11n::data_node". This node is functionally useless until it's name is set, as nodes with empty names are not supported by any current i/o parsers. */ data_node(); /** Creates a new node with the given name() and an impl_class() of "s11n::data_node". */ explicit data_node( const std::string & name ); /** Creates a new node with the given name() and and impl_class(). Does not throw. */ data_node( const std::string & name, const std::string implclass ); /** Destroys all child objects owned by this object, freeing up their resources. Does not throw. */ ~data_node(); /** See copy(). Does not throw. */ data_node & operator=( const data_node & rhs ); /** See copy(). Does not throw. */ data_node( const data_node & rhs ); /** Returns a list of the data_node children of this object. The caller should not delete any pointers from this list unless he also removes the pointers from the list, or else they will get double-deleted later. In practice it is (almost) never necessary for client code to manipulate this list directly. See node_child_simple_formatter<> for a funcfor designed to quickly serialize lists such as this one. */ child_list_type & children(); /** The const form of children(). */ const child_list_type & children() const; /** Removes all properties and deletes all children from this object, freeing up their resources. Any pointers to children of this object become invalided by a call to this function (they get deleted). Since client code doesn't normally hold pointers to data_node children this should not be a practical problem. This is normally only used in test code, not client code. */ void clear(); /** older name for clear(). Deprecated. */ void reset() { this->clear(); } /** Defines the class name which should be used as the implementation for the node when it is deserialize()d. Client Serializable types should call this one time from their serialize() method, <em>after</em> calling the parent class' serialize() method (if indeed that is called at all), passing it the name of their class, <em>as it will be used by the classloader</em>. By convention the class name is the same as it's C++ name, thus Serializable class foo::FooBar should call: <pre> node.impl_class( "foo::FooBar" ); </pre> from it's serialize() function. Historical note: the above call <em>should</em> be handled 100% transparently by this library. There are, however, legitimate use-cases which the template/macro-based solution cannot catch, so users are encouraged to set it manually, as described above. If you don't then you your serialized data will all have the same impl_class: probably that of the base-most Serializable class. That *will* break deserialization. */ void impl_class( const std::string & n ); /** Returns the implementation class name set via impl_class(). */ std::string impl_class() const; /** The name which should be used as the key for storing the node. This is normally translated to something like an XML element name (e.g., <name>), and should not contain spaces or other characters which may not be usable as key names. To be safe, stick to alphanumeric and underscores, starting with a letter or underscore. (This class does no enforce any naming conventions, but your data file parsers certainly will.) */ void name( const std::string & n ); /** Returns this node's name, as set via name(string). */ std::string name() const; /** std::string propval = node["bar"] is functionally identical to node.get_string("bar"). Unlike std::map and the like, calling this operator with a key which is not in the object does not create a new entry - it simply returns an empty string in that case. This behaviour is not a specific of the interface for purposes of data_node conventions. */ const mapped_type operator[] ( const key_type & key ) const; /** Untested. Returns a non-const reference to a property with the given key. If key does not exist a new entry is created. */ mapped_type & operator[] ( const key_type & key ); /** For compatibility with std::map. Inserts a value_type (i.e., pair) into this object. */ void insert( const value_type & ); /** * Returns the value for key, or defaultVal if the key * is not set. * * Maintenance note: this is the "master" * getter. Almost all other getXXX() functions call * this one, so do not call them from inside this * function. * */ std::string get_string( const std::string & key, const std::string & defaultVal = std::string() )const; /** Sets the given key to the given value. See get_string(): same notes apply here. */ void set_string( const std::string & key, const std::string & val ); /** See set_string(). This function is identical except that it converts val to string before saving it. If this type conversion is not possible it will fail at compile time. A value-conversion failure, on the other hand, is not caught at compile time. */ template < typename T > void set( const std::string & key, const T & val ) { ::P::Util::LexT lex(val); this->set_string( key, val ); } /** The <const char *> variants of get() and set() are to help the developer avoid having to cast so much and to help out compilers which have mediocre template support. :/ */ void set( const char *key, const char *val ) { this->set_string( key, val ); } /** Overloaded for strings-via-streams reaons. */ void set( const std::string & key, const char *val ) { this->set_string( key, val ); } /** Overloaded for strings-via-streams reaons. */ void set( const char *key, const std::string & val ) { this->set_string( key, val ); } /** See get_string(). This function is identical except that the returned string is converted to type T. If this type is not possible it will fail at compile time. A value-conversion failure, on the other hand, is not caught at compile time. If value conversion fails then defaultval is returned. This can be interpretted as an error value if the client so chooses, and it is often helpful to pass a known-invalid value here for that purpose. */ template < typename T > T get( const std::string & key, const T & defaultval ) const { ::P::Util::LexT foo = this->get_string( key, ::P::Util::LexT(defaultval).str() ); return foo.template castTo<T>( defaultval ); } /** get(): see <code>set( const char *, const char * )</code>. Same notes apply. */ std::string get( const char *key, const char *val ) const { return this->get_string( key, val ); } /** Overloaded for strings-via-streams reasons. */ std::string get( const std::string & key, const char *val ) const { return this->get_string( key, val ); } /** Overloaded for strings-via-streams reasons. */ std::string get( const char *key, const std::string & val ) const { return this->get_string( key, val ); } /** Returns true if this object contains the given property, else false. */ bool is_set( const std::string & key ) const; /** Removes the given property from this object. */ void unset( const std::string & key ); /** set_bool() is provided to work around a potential compiler warning: <pre> props.set( "foo", false ); // ambiguous: may be bool, const char *, char, or even int :/ </pre> */ void set_bool( const std::string & key, bool val ); /** get_bool(key) returns true if key's value is true, as evaluated by the static function bool_val(). */ bool get_bool( const std::string & key, bool defaultVal ) const; /** * Returns the bool value of the passed string. * The following string values are considered equal to true: * * true, TRUE, True * yes, YES, Yes, y, Y * 1 * * Anything else evaluates to false. * * Case IS significant! */ static bool bool_val( const std::string & key ); /** * Returns end() if the key is not in our map, otherise it returns * that iterator. Use the iterator's 'first' member to get the key * and 'second' to get at it's value. */ iterator find( const std::string & key ); /** * Returns the first item in the data map. * You can use this to iterate, STL-style: * <pre> * data_node::iterator it = node.begin(); * for( ; node.end() != it; ++it ) { ... } * </pre> * * Note that the iterator represents a * value_type (std::pair), so use (*it).first to get * the key and (*it).second to get the value. */ iterator begin(); /** Returns a const_iterator pointing at this object's first property. */ const_iterator begin() const; /** * The after-the-end iterator for the data map. */ iterator end(); /** * The after-the-end iterator for the data map. */ const_iterator end() const; /** * Returns the internally-used map_type (see the typedefs). * It is safe to modify this directly. */ map_type & map(); /** * Returns the internally-used map_type (see the typedefs). */ const map_type & map() const; /** Returns the number of properties in this object. */ size_t size() const; private: map_type m_map; // stores key/value properties. std::string m_name; // name of this node std::string m_iname; // impl_class name of this node child_list_type m_children; // holds child pointers /** Copies all properties and child data_nodes from rhs into this object, as well as any other details which need to be copied. This can be a very expensive operation, and is rarely necessary. */ void copy( const data_node & rhs ); ... [truncated message content] |
From: stephan b. <sg...@us...> - 2004-12-26 00:35:53
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32228/src/s11n Log Message: Directory /cvsroot/pclasses/pclasses2/src/s11n added to the repository |
From: stephan b. <sg...@us...> - 2004-12-25 21:32:15
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7294 Modified Files: configure.pclasses2 Log Message: Added test for (optional) doxygen. Index: configure.pclasses2 =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.pclasses2,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- configure.pclasses2 25 Dec 2004 16:47:11 -0000 1.10 +++ configure.pclasses2 25 Dec 2004 21:32:06 -0000 1.11 @@ -4,6 +4,7 @@ toc_export PACKAGE_RELEASE_CODENAME="The Rewrite" + toc_test check_dist_md5s toc_export PACKAGE_DESCRIPTION="C++ generic application framework library" @@ -211,13 +212,14 @@ fi - +toc_test ${TOC_HOME}/tests/doxygen.sh ######################################################################## # Anything below this line should not modify the config: we are # now exporting our files... ######################################################################## + ######################################################################## toc_boldecho "======================= Creating Makefiles..." make_out=${PWD}/.toc.Makefile |
From: stephan b. <sg...@us...> - 2004-12-25 21:31:41
|
Update of /cvsroot/pclasses/pclasses2/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7193/doc Modified Files: Makefile.toc Log Message: added better doxygen support. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/doc/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 24 Dec 2004 01:11:37 -0000 1.1 +++ Makefile.toc 25 Dec 2004 21:31:32 -0000 1.2 @@ -1,4 +1,22 @@ #!/usr/bin/make -f include toc.make + SUBDIRS = manual + +INCLUDES_DIRS = $(addprefix $(top_includesdir)/,s11n) + +TOPDIR_ABS = $(shell cd $(top_srcdir); echo $$PWD;) +DOXYGEN_ATPARSE_ARGS = \ + DOXYGEN_OUTPUT_PATH="$(TOPDIR_ABS)/doxygen" \ + DOXYGEN_STRIP_PATH="$(TOPDIR_ABS)" \ + DOXYGEN_INPUT="index.txt $(top_srcdir)/include/pclasses" + +ifeq (,$(DOXYGEN_BIN)) +all: +else +include $(TOC_MAKESDIR)/DOXYGEN.make +all: doxygen +endif + + all: subdirs |
From: stephan b. <sg...@us...> - 2004-12-25 21:30:58
|
Update of /cvsroot/pclasses/pclasses2/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7093/doc Added Files: Doxyfile.at index.txt Log Message: egg --- NEW FILE: Doxyfile.at --- # Doxyfile 1.3.7-KDevelop #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = P::Classes PROJECT_NUMBER = @PACKAGE_VERSION@ OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_PATH@ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = @DOXYGEN_STRIP_PATH@ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 8 ALIASES = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = YES HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = NO GENERATE_TESTLIST = NO GENERATE_BUGLIST = NO GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = @DOXYGEN_INPUT@ FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.C \ *.H \ *.tlh \ *.diff \ *.patch \ *.moc \ *.xpm \ *.dox RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 1 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = YES XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = *.h *.hpp PREDEFINED = PCLASSES_HAVE_64BIT_INT EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = @DOXYGEN_OUTPUT_PATH@/PClasses.tag ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = @PERL_BIN@ #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO CLASS_GRAPH = YES COLLABORATION_GRAPH = YES UML_LOOK = NO TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO GRAPHICAL_HIERARCHY = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_DEPTH = 1000 GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO --- NEW FILE: index.txt --- // This is used by Doxygen to generate the index page. /** @mainpage P::Classes: a C++ portable application framework Author: Christian Prochnow <cp...@se...> Home page: http://pclasses.com/ License: GNU Lesser General Public License (LGPL) */ |
From: stephan b. <sg...@us...> - 2004-12-25 20:55:16
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2183/include/pclasses Modified Files: FactoryReg.h Log Message: Added some API docs so when this shows up in doxygen it doesn't look so stupid. Index: FactoryReg.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/FactoryReg.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FactoryReg.h 25 Dec 2004 01:45:14 -0000 1.3 +++ FactoryReg.h 25 Dec 2004 20:55:04 -0000 1.4 @@ -46,11 +46,16 @@ // install a specialization of Factory's default factory type, // so that we won't try to instantiate a PFACREG_TYPE object. namespace P { namespace Hook { + /** + FactoryCreateHook specialization to install a no-op + factory. Intended for use with abastract types. + */ template <> struct FactoryCreateHook< PFACREG_TYPE_INTERFACE , PFACREG_TYPE > { typedef PFACREG_TYPE_INTERFACE * result_type; typedef PFACREG_TYPE actual_type; + /** Returns 0. */ static result_type create() { return 0; @@ -65,14 +70,19 @@ # define p_FACTORY_REG_CONTEXT_DEFINED 1 /////////////////////////////////////////////////////////////// // we must not include this more than once per compilation unit - /////////////////////////////////////////////////////////////// - // A unique (per Context/per compilation unit) space to assign - // a bogus value for classloader registration purposes (see - // the classloader docs for a full description of how this - // works). + /** + A unique (per Context/per compilation unit) space to assign + a bogus value for classloader registration purposes (see + the classloader docs for a full description of how this + works). + */ template <typename Context> struct pfactory_reg_context { + /** + Placeholder variable for automatic factory + registration. + */ static bool placeholder; }; template <typename Context> bool pfactory_reg_context<Context>::placeholder = false; @@ -80,8 +90,9 @@ # define FACTORY_FUNCTION_ ::P::Hook::FactoryCreateHook< PFACREG_TYPE_INTERFACE , PFACREG_TYPE >::create # define FACTORY_INSTANCE_ ::P::Factory< PFACREG_TYPE_INTERFACE, PFACREG_CONTEXT, std::string >::instance() - //////////////////////////////////////////////////////////////////////// - // Register a factory with the classloader: + /** + Placeholder variable for automatic factory registration. + */ bool pfactory_reg_context< PFACREG_TYPE >::placeholder= ( FACTORY_INSTANCE_.registerFactory( PFACREG_TYPE_NAME, FACTORY_FUNCTION_ ), true); |
From: stephan b. <sg...@us...> - 2004-12-25 20:50:40
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1518/include/pclasses/Plugin Modified Files: Plugin.h Log Message: Added caching of SharedLib lookups. Removed the NonCopyable requirement because this object no longer deletes the SharedLib objects. Index: Plugin.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Plugin/Plugin.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Plugin.h 25 Dec 2004 19:56:34 -0000 1.10 +++ Plugin.h 25 Dec 2004 20:50:20 -0000 1.11 @@ -32,7 +32,7 @@ */ template <class InterfaceT> class PluginManager : - public ::P::NamedTypeFactory< InterfaceT >, public NonCopyable + public ::P::NamedTypeFactory< InterfaceT > { public: typedef InterfaceT InterfaceType; @@ -128,22 +128,37 @@ caller does NOT own the pointer - it is owned by this class. - @todo: if the SO is already opened, give back the - existing SharedLib. We can't do this until we map names to - SharedLibs, which we really have little reason to - do. + This function caches lookups, and calling addPlugin() + multiple times with the same so_name will return the + same SharedLib object. */ ::P::System::SharedLib * addPlugin( const std::string & so_name ) throw(::P::RuntimeError) { - //CERR << "addPlugin("<<so_name<<").\n"; + typedef typename PluginsMap::iterator IT; + // look for cached entry: + IT it = this->m_smap.find( so_name ); + if( this->m_smap.end() != it ) + { + return (*it).second; + } + + // find a DLL file: std::string fn = this->searchPath().find( so_name ); if( fn.empty() ) { throw ::P::System::SystemError( 0, (std::string("No plugin found for '")+so_name+"'.").c_str(), P_SOURCEINFO ); } + + // check for entry cached under DLL's file name: + it = this->m_smap.find( fn ); + if( this->m_smap.end() != it ) + { + return (*it).second; + } + + // open DLL and, if workie, cache it: ::P::System::SharedLib * shl = ::P::System::openSharedLib( fn ); - //CERR << "Opened fn="<<fn<<"\n"; m_smap.insert( std::make_pair( fn, shl ) ); return shl; } @@ -195,6 +210,11 @@ lib. That said, the default lib-opening routines do not destroy SharedLibs loaded via this class until post-main(). + + ACHTUNG #2: using the non-const PluginsMap together + with non-const member functions, e.g. addPlugin(), + from multi-threaded code is likely to Cause Greif. + To be fixed, via P's mutex support. */ PluginsMap & loadedPlugins() { @@ -256,7 +276,7 @@ template <typename T> ::P::System::SharedLib * addPlugin( const std::string & pluginname ) throw(RuntimeError) - { + { return pluginManager<T>().addPlugin( pluginname ); } |
From: stephan b. <sg...@us...> - 2004-12-25 20:48:25
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1174/src/System Modified Files: PathFinder.cpp Log Message: Moved joinList() out of the class interface, into an internal helper func. Index: PathFinder.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/PathFinder.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- PathFinder.cpp 24 Dec 2004 01:39:30 -0000 1.2 +++ PathFinder.cpp 25 Dec 2004 20:48:13 -0000 1.3 @@ -51,13 +51,17 @@ this->pathseparator = sep; } - std::string PathFinder::joinList( const string_list & list, const std::string & separator ) const + /** + Internal helper function to collapse a list into a string. + */ + template <typename StringList> + std::string joinList( const StringList & list, const std::string & separator ) { std::string ret; unsigned long count = list.size(); unsigned long at = 0; - string_list::const_iterator it = list.begin(); - string_list::const_iterator et = list.end(); + typename StringList::const_iterator it = list.begin(); + typename StringList::const_iterator et = list.end(); for(; it != et; ++it ) { @@ -66,9 +70,10 @@ } return ret; } + string PathFinder::pathString() const { - return this->joinList( this->paths, this->pathseparator ); + return joinList( this->paths, this->pathseparator ); } const PathFinder::string_list & PathFinder::path() const @@ -78,7 +83,7 @@ string PathFinder::extensionsString() const { - return this->joinList( this->exts, this->pathseparator ); + return joinList( this->exts, this->pathseparator ); } const PathFinder::string_list & PathFinder::extensions() const |
From: stephan b. <sg...@us...> - 2004-12-25 20:48:21
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1174/include/pclasses/System Modified Files: PathFinder.h Log Message: Moved joinList() out of the class interface, into an internal helper func. Index: PathFinder.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/PathFinder.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- PathFinder.h 24 Dec 2004 04:30:12 -0000 1.4 +++ PathFinder.h 25 Dec 2004 20:48:13 -0000 1.5 @@ -154,6 +154,10 @@ /** Empties the hit-cache used by find(). + + Design note: because the cache is mutable data, we + *could* legally make this function const. Something + to consider. */ void clearCache(); @@ -164,10 +168,6 @@ private: - /** - Helper function to collapse a list into a string. - */ - std::string joinList( const string_list & list, const std::string & separator ) const; string_list paths; string_list exts; std::string pathseparator; |
From: stephan b. <sg...@us...> - 2004-12-25 20:08:20
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27858/src/System Modified Files: SharedLib.ltdl.cpp Log Message: Removed a debug output line. Index: SharedLib.ltdl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.ltdl.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SharedLib.ltdl.cpp 25 Dec 2004 07:02:16 -0000 1.5 +++ SharedLib.ltdl.cpp 25 Dec 2004 20:08:07 -0000 1.6 @@ -97,7 +97,7 @@ lt_handle_map_t::iterator it = lt_handle_map().find( _handle ); if( lt_handle_map().end() != it ) { - CERR << "~SharedLib() erasing a handle: " << _handle << "\n"; + // CERR << "~SharedLib() erasing a handle: " << _handle << "\n"; // lt_dlclose((*it).second); lt_handle_map().erase( it ); } |
From: stephan b. <sg...@us...> - 2004-12-25 19:57:16
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25972/include/pclasses/IO Modified Files: IOManager.h Log Message: typedef renamed, to follow PNamingConventions. Index: IOManager.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOManager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IOManager.h 25 Dec 2004 19:53:57 -0000 1.2 +++ IOManager.h 25 Dec 2004 19:56:32 -0000 1.3 @@ -17,8 +17,8 @@ public: typdef IOPluginManager<InterfaceT> ThisType; typedef ::P::PluginManager<InterfaceT> ParentType; - typedef typename ParentType::factory_type factory_type; - typedef typename ParentType::result_type result_type; + typedef typename ParentType::FactoryFuncType FactoryFuncType; + typedef typename ParentType::ResultType ResultType; using ::P::Net::URL; IOPluginManager(){} virtual ~IOPluginManager(){} @@ -40,7 +40,7 @@ Returns this->registerFactory(_protocol.protocol()). */ void - registerFactory(const URL &_protocol, factory_type fp) + registerFactory(const URL &_protocol, FactoryFuncType fp) { this->registerFactory( _protocol.protocol(), fp ) } @@ -48,7 +48,7 @@ /** Returns this->create(_protocol.protocol()). */ - result_type create( const URL & _protocol ) + ResultType create( const URL & _protocol ) { return this->create( _protocol.protocol() ); } |
From: stephan b. <sg...@us...> - 2004-12-25 19:56:48
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25972/include/pclasses Modified Files: Factory.h Log Message: typedef renamed, to follow PNamingConventions. Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Factory.h 25 Dec 2004 16:37:47 -0000 1.10 +++ Factory.h 25 Dec 2004 19:56:39 -0000 1.11 @@ -222,13 +222,13 @@ todo: implement proper functor support. */ - typedef ResultType ( *factory_func_type ) (); + typedef ResultType ( *FactoryFuncType ) (); /** Internal container type used for mapping keys to factories. */ - typedef std::map < key_type, factory_func_type > FactoryMap; + typedef std::map < key_type, FactoryFuncType > FactoryMap; /** @@ -284,7 +284,7 @@ value_type. See the FactoryCreateHook class for a factory which does this subtype-to-base conversion. */ - virtual void registerFactory( const key_type & key, factory_func_type fp ) + virtual void registerFactory( const key_type & key, FactoryFuncType fp ) { // CERR << "registerFactory("<<key<<",facfunc)\n"; factoryMap().insert( FactoryMap::value_type( key, fp ) ); @@ -345,7 +345,7 @@ typedef Factory< InterfaceT, Sharing::FactoryContext, std::string > ParentType; typedef typename ParentType::ResultType ResultType; - typedef typename ParentType::factory_func_type factory_func_type; + typedef typename ParentType::FactoryFuncType FactoryFuncType; virtual ~NamedTypeFactory(){} }; |
From: stephan b. <sg...@us...> - 2004-12-25 19:56:48
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25972/include/pclasses/Plugin Modified Files: Plugin.h Log Message: typedef renamed, to follow PNamingConventions. Index: Plugin.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Plugin/Plugin.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Plugin.h 25 Dec 2004 19:33:46 -0000 1.9 +++ Plugin.h 25 Dec 2004 19:56:34 -0000 1.10 @@ -38,7 +38,7 @@ typedef InterfaceT InterfaceType; typedef ::P::NamedTypeFactory< InterfaceT > ParentType; typedef PluginManager<InterfaceType> ThisType; - typedef typename ParentType::factory_func_type factory_func_type; + typedef typename ParentType::FactoryFuncType FactoryFuncType; typedef typename ParentType::ResultType ResultType; /** |
From: stephan b. <sg...@us...> - 2004-12-25 19:54:15
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25528/include/pclasses/IO Modified Files: IOManager.h Log Message: Corrected broken inheritance (missing namespace). Index: IOManager.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOManager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IOManager.h 25 Dec 2004 17:06:43 -0000 1.1 +++ IOManager.h 25 Dec 2004 19:53:57 -0000 1.2 @@ -1,7 +1,7 @@ #ifndef P_IOMANAGER_HPP_INCLUDED #define P_IOMANAGER_HPP_INCLUDED 1 -#include "pclasses/Phoenix.h" +#include "pclasses/Factory.h" #include "pclasses/Plugin/Plugin.h" #include "pclasses/Net/URL.h" namespace P { @@ -12,7 +12,7 @@ the P::IO layer. */ template <typename InterfaceT> - class IOPluginManager : public ::P::PluginManager<InterfaceT> + class IOPluginManager : public ::P::Plugin::PluginManager<InterfaceT> { public: typdef IOPluginManager<InterfaceT> ThisType; @@ -26,11 +26,14 @@ /** Returns a shared instance of this object. + + Clients may transparently replace or modify the + default returned object by specializing + P::Hook::FactoryInstanceHook<ThisType>. */ static ThisType & instance() { - typedef ::P::Phoenix<ThisType, ::P::Sharing::FactoryContext > PHX; - return PHX::instance(); + return ::P::Hook::FactoryInstanceHook<ThisType>::instance(); } /** |
From: stephan b. <sg...@us...> - 2004-12-25 19:33:55
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22956/include/pclasses/Plugin Modified Files: Plugin.h Log Message: Replaced PluginsList with PluginsMap, mapping DLL names to SharedLibs. Added an #if to allow the blocking out of the FactoryInstanceHook, to disable DLL lookups in the default API. Index: Plugin.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Plugin/Plugin.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Plugin.h 25 Dec 2004 16:47:11 -0000 1.8 +++ Plugin.h 25 Dec 2004 19:33:46 -0000 1.9 @@ -3,6 +3,7 @@ #include <list> #include <string> +#include <map> #include "pclasses/pclasses-config.h" #include "pclasses/Factory.h" #include "pclasses/NonCopyable.h" @@ -41,6 +42,11 @@ typedef typename ParentType::ResultType ResultType; /** + A type used to hold SharedLib handles. + */ + typedef std::map<std::string,::P::System::SharedLib *> PluginsMap; + + /** Creates a PluginManager with a default search path and a platform-specific DLL file extension added to it's searchPath(). @@ -56,7 +62,7 @@ virtual ~PluginManager() throw() { // reminder: openSharedLib() owns - // the objects in m_holder. + // the objects in m_map. } @@ -138,7 +144,7 @@ } ::P::System::SharedLib * shl = ::P::System::openSharedLib( fn ); //CERR << "Opened fn="<<fn<<"\n"; - this->m_holder.push_back( shl ); + m_smap.insert( std::make_pair( fn, shl ) ); return shl; } @@ -146,7 +152,7 @@ Returns a shared instance to an object of this type. Note that this shadows a static member of the same - name in the base class! + name in the base class, but returns a more-derived type. */ static ThisType & instance() { @@ -169,10 +175,6 @@ return this->m_path; } - /** - A type used to hold SharedLib handles. - */ - typedef std::list< ::P::System::SharedLib * > PluginList; /** Returns the list of SharedLibs opened by this type. @@ -186,15 +188,22 @@ provided by the DLL, they will crash when they use it next. In practice it is safest to not close the DLLs and to let the OS do it at app shutdown. + + ACHTUNG: this code has no way of knowing when + a SharedLib dies off, and any given entry + in the list may refer to a no-longer-loaded + lib. That said, the default lib-opening routines + do not destroy SharedLibs loaded via this class + until post-main(). */ - PluginList & sharedLibs() + PluginsMap & loadedPlugins() { - return this->m_holder; + return this->m_smap; } - const PluginList & sharedLibs() const + const PluginsMap & loadedPlugins() const { - return this->m_holder; + return this->m_smap; } /** @@ -216,7 +225,7 @@ this->m_path.addPath( PCLASSES_LIB_DIR ); this->m_path.addExtension(std::string(".")+::P::System::SharedLib::extension()); } - PluginList m_holder; + PluginsMap m_smap; ::P::System::PathFinder m_path; // ^^^^ todo: consider making this static. }; @@ -231,7 +240,8 @@ } /** - Convenience function to add a plugin dir to pluginManager<T>(). + Convenience function returning + pluginManager<T>().addPluginDir(pluginname). */ template <typename T> void addPluginDir( const std::string & path ) throw(RuntimeError) @@ -240,7 +250,8 @@ } /** - Convenience function to open a plugin using pluginManager<T>(). + Convenience function returning + pluginManager<T>().addPlugin(pluginname). */ template <typename T> ::P::System::SharedLib * @@ -250,7 +261,8 @@ } /** - Convenience function to call pluginManager<T>().findPlugin(name). + Convenience function returning + pluginManager<T>().findPlugin(name). */ template <typename T> std::string findPlugin( const std::string & name ) @@ -262,6 +274,10 @@ } // namespace Plugin +#ifndef PCLASSES_DEFAULT_FACTORY_KNOWS_SHAREDLIBS +# define PCLASSES_DEFAULT_FACTORY_KNOWS_SHAREDLIBS 1 +#endif +#if PCLASSES_DEFAULT_FACTORY_KNOWS_SHAREDLIBS namespace Hook { /** @@ -277,6 +293,8 @@ typedef FactoryInstanceHook<FactoryType> ThisType; /** + Initializes the passed-in factory. i.e., it does + nothing. It's here for demonstration purposes. */ void operator()( FactoryType & ) throw() { @@ -296,6 +314,8 @@ }; } // ns Hook +#endif // PCLASSES_DEFAULT_FACTORY_KNOWS_SHAREDLIBS + } // namespace P |
From: stephan b. <sg...@us...> - 2004-12-25 18:59:45
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17918/src/System Modified Files: testMime.cpp Log Message: Added test of MimeType(string) ctor. Index: testMime.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/testMime.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- testMime.cpp 24 Dec 2004 19:19:38 -0000 1.4 +++ testMime.cpp 25 Dec 2004 18:59:37 -0000 1.5 @@ -15,8 +15,10 @@ using P::System::MimeTypeDb; MimeType m1( "text", "plain" ); - MimeType m2( "application", "html" ); -#define MCMP(M1,OP,M2) CERR << M1.mimeType() << " "<<# OP<<" "<< M2.mimeType() << " == " << (M1 OP M2)<<"\n"; + MimeType m2( "application/html" ); + + +#define MCMP(M1,OP,M2) CERR << M1.mimeType() << " "<<# OP<<" "<< M2 << " == " << (M1 OP M2)<<"\n"; #define MCMP2(M1,M2) MCMP(M1,<,M2); MCMP(M2,<,M1); MCMP(M1,==,M2); MCMP2(m1,m2); MCMP2(MimeType( "application", "x" ),MimeType( "application", "x" )); |
From: stephan b. <sg...@us...> - 2004-12-25 18:58:58
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17795/src/System Modified Files: Mime.cpp Log Message: Added i/ostream operators for MimeType. Fixed mimeType() to return an empty string on an invalid (empty) type. Index: Mime.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Mime.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Mime.cpp 25 Dec 2004 18:08:03 -0000 1.8 +++ Mime.cpp 25 Dec 2004 18:58:49 -0000 1.9 @@ -110,6 +110,36 @@ { return lhs.mimeType() == rhs; } + +std::ostream & operator<<( std::ostream & os, const MimeType & m ) +{ + return os << m.mimeType(); +} + +std::istream & operator>>( std::istream & is, MimeType & m ) +{ + std::string buff; + // the following loop is so this func will work regardless + // of is' skipws flag... + char c; + while(1) + { + if( ! is.get(c) ) + { + return is; + } + if( std::isspace( c ) ) break; + buff += c; + } + MimeType tmp( buff ); + if( tmp.subType().empty() || tmp.mediaType().empty() ) + { + is.setstate( std::ios::failbit ); + return is; + } + m = tmp; + return is; +} MimeTypeDb::MimeTypeDb() |