The ccs::serialization::storage template class has
two template parameters: class TRAITS and typename
BACKEND. The traits class must contain two boolean compile-time
constants (eg, enums) named
WANT_POINTER_TRACKING and
WANT_POLYMORPHIC_SUPPORT. The BACKEND
parameter must name a type that specifies what database backend
to use for storage.
The WANT_POINTER_TRACKING option controls pointer
tracking on a global basis, ie, this value controls whether the
library performs pointer tracking for all pointers that are streamed
to it. If set to false, no pointers are tracked.
If set to true, pointers may be tracked depending
on the value of the
ccs::serialization::want_pointer_tracking_for<T>
template specialization. The default value of
WANT_POINTER_TRACKING is true. The
library's default for the
ccs::serialization::want_pointer_tracking_for<T>
template is true so by default, all pointers are
tracked.
To disable pointer tracking globally:
struct MY_STORAGE_TRAITS {
enum {
WANT_POINTER_TRACKING = false,
WANT_POLYMORPHIC_SUPPORT = true
};
};
ccs::serialization::storage<MY_STORAGE_TRAITS> db;
db << my_object;
...The WANT_POLYMORPHIC_SUPPORT option controls how
pointers to polymorphic types are handled on a global basis, ie, this
value controls whether the library writes out the data of the actual
type that a pointer points at (when set to true),
or whether the library writes out the data of the declared/
static/compile-time type that a pointer points at (when set to
false). If set to true, the
actual type is used if two other conditions are met:
the value of
ccs::serialization::want_polymorphic_pointer_handling_for<T>::value
is true (the default value for this template
is true)
the actual type has been registered with the storage
instance by using the
storage::register_type() member function.
Since the actual types are client-defined, no types are registered
when storage instances are created, so clients must
register types manually.
See the "Polymorphic pointers" section below for more information on serializing polymorphic pointers.
To disable polymorphic pointer support globally:
struct MY_STORAGE_TRAITS {
enum {
WANT_POINTER_TRACKING = true,
WANT_POLYMORPHIC_SUPPORT = false
};
};
ccs::serialization::storage<MY_STORAGE_TRAITS> db;
db << my_object;
...