#include <traits.hpp>
Public Types | |
typedef SerializableT | serializable_type |
The type of object we want to [de]serialize. | |
typedef ::s11n::cl::object_factory< serializable_type > | factory_type |
Type which will be used to instantiate new objects of serializable_type. | |
typedef ::s11n::default_serialize_functor | serialize_functor |
Functor type implementing serialize code. | |
typedef ::s11n::default_serialize_functor | deserialize_functor |
Functor type implementing deserialize code. | |
typedef ::s11n::default_cleanup_functor< serializable_type > | cleanup_functor |
This type is used to clean up a partial deserialized object on error. | |
Public Member Functions | |
s11n_traits () | |
The s11n framework instantiates an s11n_traits object at some points to allow the traits object to do things like factory registration. | |
~s11n_traits () | |
Static Public Member Functions | |
static const std::string | class_name (const serializable_type *) |
As of s11n 1.1, specializations must define the class_name() function. |
It should be specialized to define various aspects of serialization for a given type.
The interface shown here is the bare minimum which s11n_traits specializations must implement. Specializations may optionally add to the interface, but client code is discouraged from relying on any extensions.
This type is stateless, and specializations are expected to be stateless (at least, they will be treated as if they are).
Client code is not expected to need to use this type directly, except for purposes of plugging in their types into the s11n framework. More specifically, it is not expected that Serializables will use this type.
Parameterized on:
SerializableT: the base-most Serializable type. This is the base-most point of reference for classloading and "template typing". Subclasses of SerializableT are assumed to be handleable via the same de/serialize interface as SerializableT.
Changes from 1.0.x to 1.1.x:
Definition at line 405 of file traits.hpp.
typedef SerializableT s11n::s11n_traits< SerializableT >::serializable_type |
typedef ::s11n::cl::object_factory<serializable_type> s11n::s11n_traits< SerializableT >::factory_type |
Type which will be used to instantiate new objects of serializable_type.
It must implement:
serializable_type * operator()( const std::string & classname ) const;
It is expected to return, polymorphically if possible, a new serializable_type on success or 0 on failure.
The default factory_type works with types registered via the s11n::cl::classload() family of functions.
Definition at line 434 of file traits.hpp.
typedef ::s11n::default_serialize_functor s11n::s11n_traits< SerializableT >::serialize_functor |
Functor type implementing serialize code.
Must implement:
bool operator()( SomeNodeType & dest, const base_type & src ) const;
Definition at line 444 of file traits.hpp.
typedef ::s11n::default_serialize_functor s11n::s11n_traits< SerializableT >::deserialize_functor |
Functor type implementing deserialize code.
Must implement:
bool operator()( const SomeNodeType & src, base_type & dest ) const;
Definition at line 453 of file traits.hpp.
typedef ::s11n::default_cleanup_functor<serializable_type> s11n::s11n_traits< SerializableT >::cleanup_functor |
This type is used to clean up a partial deserialized object on error.
If this functor, and all specializations it calls, do their part, we can make much better exception guarantees, theoretically avoiding any leaks due to exceptions thrown during deserialization.
cleanup_functor must follow the conventions laid out by s11n::default_cleanup_functor<serializable_type>.
Definition at line 465 of file traits.hpp.
s11n::s11n_traits< SerializableT >::s11n_traits | ( | ) | [inline] |
The s11n framework instantiates an s11n_traits object at some points to allow the traits object to do things like factory registration.
Definition at line 412 of file traits.hpp.
s11n::s11n_traits< SerializableT >::~s11n_traits | ( | ) | [inline] |
Definition at line 413 of file traits.hpp.
static const std::string s11n::s11n_traits< SerializableT >::class_name | ( | const serializable_type * | ) | [inline, static] |
As of s11n 1.1, specializations must define the class_name() function.
This implementation returns a useless, unspecified class name. Specializations must return the class name of serializable_type, preferably polymorphically (polymorphic naming is unfortunately not possible without some client-side help).
instance_hint is a HINT to this class as to the actual instance we want the name for, and may be 0. It is provided so that class hierarchies which have virtual functions like className() can make those available to the core library via s11n_traits specializations.
Specializations MUST accept 0 as a valid instance_hint value are are NEVER REQUIRED to pay any attention to instance_hint. The default implementation does nothing with it.
Design notes:
Definition at line 505 of file traits.hpp.