From: stephan b. <sg...@us...> - 2005-01-06 17:03:29
|
Update of /cvsroot/pclasses/pclasses2/src/SIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17499/src/SIO Modified Files: SIO.cpp SIO.h Log Message: Split serializeFor() into input/output serializer getters. Index: SIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/SIO/SIO.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SIO.h 31 Dec 2004 17:41:59 -0000 1.2 +++ SIO.h 6 Jan 2005 17:03:16 -0000 1.3 @@ -37,7 +37,7 @@ serialization code may need to use the classes in P::s11n or possibly even P::s11n::io as well. - SIO is a fork/port of the s11n project: + SIO is a P::Classes-centric fork/port of the s11n project. http://s11n.net @@ -55,7 +55,18 @@ */ namespace SIO { + /** + S11nNode is the "data node" type used by the underlying + s11n framework. In short: these containers are used to hold + serialized data for arbitrary objects. See the s11n library + manual and sample applications for more information than + you care to know about this type. + Note that the exact concrete node type is not guaranteed by + the SIO interface! What is guaranteed is that it will be a type + suitable for use with s11n::node_traits<NodeType> and, by + extension, for use within the s11n framework. + */ typedef ::P::s11n::s11n_node S11nNode; /** NodeTraits provide the interface for fetching and @@ -162,18 +173,25 @@ return ::P::s11n::io::load_serializable<S11nNode,SerializableType>( src ); } - /** - See ::P::s11n::io::create_serializer(). + /** + SHOULD return a dynamically-determined output handler for + the given url. - In short: it looks at the given file to determine what - Serializer should be able to read it. + CURRENTLY always returns createSerializer(). - Once IOManager support is completed this will also support - URL-based lookups. + Caller owns the returned pointer, which may be 0. + */ + SerializerInterface * getOutputSerializer( const std::string & url ); - The caller owns the returned object, which may be NULL. - */ - SerializerInterface * serializerFor( const std::string & url ); + /** + SHOULD return a dynamically-determined input handler for + the given url. + + CURRENTLY always returns createSerializer(). + + Caller owns the returned pointer, which may be 0. + */ + SerializerInterface * getInputSerializer( const std::string & url ); /** Saves src to dest using the default @@ -198,6 +216,9 @@ Uses SerializerPluginManager to load a Serializer. The caller owns the returned object, which may be NULL. + + This function does not set the SIO default serializer - use + serializerClass(string) for that. */ SerializerInterface * createSerializer( const std::string & ); @@ -238,10 +259,10 @@ std::string serializerClass(); /** - Serializes fromobj and deserializes the data by passing - it to toobj. Returns false if either operation fails. + Serializes fromobj deserializes the data into + toobj. Returns false if either operation fails. - SerializableT1 and SerializableT must of course be + SerializableT1 and SerializableT2 must of course be Serializables for this to work. See ::P::s11n::s11n_cast() for full details, including @@ -249,7 +270,7 @@ to different types. */ template <typename SerializableT1, typename SerializableT2> - bool s11n_cast( const SerializableT1 & fromobj, SerializableT2 & toobj ) + bool s11nCast( const SerializableT1 & fromobj, SerializableT2 & toobj ) { return ::P::s11n::s11n_cast<S11nNode,SerializableT1,SerializableT2>( fromobj, toobj ); } Index: SIO.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/SIO/SIO.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SIO.cpp 29 Dec 2004 19:54:44 -0000 1.1 +++ SIO.cpp 6 Jan 2005 17:03:16 -0000 1.2 @@ -19,12 +19,20 @@ std::string m_serializer_class = SIO_KEY_DEFAULT_SERIALIZER; - SerializerInterface * serializerFor( const std::string & url ) + SerializerInterface * getOutputSerializer( const std::string & url ) { // @fixme: be more dynamic here: - // todo: port in IManager support from "original" ps11n + // todo: port in IOManager support from "original" ps11n // once IOM is re-implemented in P2. - return ::P::s11n::io::create_serializer<S11nNode>( m_serializer_class ); + return createSerializer(); + } + + SerializerInterface * getInputSerializer( const std::string & url ) + { + // @fixme: be more dynamic here: + // todo: port in IOManager support from "original" ps11n + // once IOM is re-implemented in P2. + return createSerializer( m_serializer_class ); } SerializerInterface * createSerializer( const std::string & c ) @@ -65,6 +73,8 @@ S11nNode * loadNode( const std::string & src ) { + // todo: use getOutputSerializer() once we've got more + // than one Serializer. return ::P::s11n::io::load_node<S11nNode>( src ); } |