Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Namespaces | Macros | Functions
i_serializable.h File Reference
#include <string>
#include <typeinfo>
#include <memory>
#include <boost/serialization/access.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <datatools/datatools_config.h>
#include <datatools/factory_macros.h>
#include <datatools/serialization_macros.h>
#include <datatools/utils.h>
#include <datatools/reflection_interface.h>

Go to the source code of this file.

Classes

class  datatools::i_serializable
 Base abstract class of all serializable (and possibly introspectable) classes. More...
 

Namespaces

 datatools
 The Bayeux/datatools library top-level namespace.
 

Macros

#define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_DECLARATION(ClassName)
 Template support for serializable type (backward compatibility support) More...
 
#define DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION()
 
#define DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION(ClassName, ClassSerialTag)
 
#define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_IMPLEMENTATION(ClassName, ClassSerialTag)
 
#define DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT()
 
#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION(ClassName)
 
#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_IMPLEMENTATION(ClassName, ClassBackwardSerialTag)
 
#define DATATOOLS_SERIALIZATION_I_SERIALIZABLE_BASE_OBJECT_NVP
 
#define DATATOOLS_SERIALIZATION_OLD_I_SERIALIZABLE_BASE_OBJECT_NVP
 
#define DATATOOLS_SERIALIZATION_DECLARATION()
 
#define DATATOOLS_SERIALIZATION_SERIALIZE_IMPLEMENT_HEADER(ClassName, ArchiveId, VersionId)
 
#define DATATOOLS_SERIALIZATION_FACTORY_INTERFACE(ClassName)   DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::datatools::i_serializable,ClassName) \
 
#define DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION(ClassName, ClassSerialTag)   DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::datatools::i_serializable,ClassName,ClassSerialTag) \
 
#define DATATOOLS_SERIALIZATION_IMPLEMENTATION(ClassName, ClassSerialTag)   DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassSerialTag) \
 
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
 
#define DATATOOLS_SERIALIZATION_IMPLEMENTATION_ADVANCED(ClassName, ClassSerialTag)
 

Functions

template<class T >
const std::string & datatools::serial_tag ()
 
template<class T >
const std::string & datatools::backward_serial_tag (int i=0)
 
template<typename T >
bool datatools::check_serial_tag (const std::string stag_, const std::string alt_tag_="", typename boost::disable_if< has_bsts< T > >::type *dummy_=0)
 
template<typename T >
bool datatools::check_serial_tag (const std::string stag_, const std::string alt_tag_="", typename boost::enable_if< has_bsts< T > >::type *dummy_=0)
 

Macro Definition Documentation

◆ DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT

#define DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT ( )
Value:
public: \
struct backward_serial_tag_support {}; \

Intrusive macro invoked from the class declaration to declare backward compatibility serial tag support : Example:

class Foo : public datatools::i_serializable
{
DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_DECLARATION()
};

◆ DATATOOLS_SERIALIZATION_DECLARATION

#define DATATOOLS_SERIALIZATION_DECLARATION ( )
Value:
public: \
DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION() \
BOOST_SERIALIZATION_BASIC_DECLARATION () \

Intrusive macro invoked from the class declaration to activate basic serialization support for the class :

Example:

◆ DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED

#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED (   ClassName)
Value:
DATATOOLS_SERIALIZATION_FACTORY_INTERFACE(ClassName) \
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266

Intrusive macro invoked from the class declaration to activate advanced serialization support for the class :

Parameters
ClassNameThe class name (without namespace)

Example:

◆ DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION

#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION (   ClassName)
Value:
namespace datatools { \
template <> \
const std::string & backward_serial_tag< ClassName > (int); \
} \
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13

◆ DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_IMPLEMENTATION

#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_IMPLEMENTATION (   ClassName,
  ClassBackwardSerialTag 
)
Value:
namespace datatools { \
template <> \
const std::string & backward_serial_tag<ClassName> (int /*i*/){ \
static std::unique_ptr<std::string> _backward_serial_tag; \
if ( !_backward_serial_tag){ \
_backward_serial_tag.reset (new std::string(ClassBackwardSerialTag)); \
} \
return *_backward_serial_tag.get (); \
} \
} \
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13

◆ DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_DECLARATION

#define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_DECLARATION (   ClassName)
Value:
namespace datatools { \
template <> \
const std::string & serial_tag< ClassName >(); \
} \
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13

Template support for serializable type (backward compatibility support)

◆ DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_IMPLEMENTATION

#define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_IMPLEMENTATION (   ClassName,
  ClassSerialTag 
)
Value:
namespace datatools { \
template <> \
const std::string & serial_tag<ClassName> (){ \
static std::unique_ptr<std::string> _serial_tag; \
if ( !_serial_tag){ \
_serial_tag.reset(new std::string(ClassSerialTag)); \
} \
return *_serial_tag.get(); \
} \
} \
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13

◆ DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION

#define DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION (   ClassName,
  ClassSerialTag 
)    DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::datatools::i_serializable,ClassName,ClassSerialTag) \

Macro invoked to implement the automatic registration the class in a dedicated factory :

Parameters
ClassNameThe class name (possibly with its full namespace path prefix by ::)
ClassSerialTagThe unique class ID used by the factory (including full namespace prefix) Example:

◆ DATATOOLS_SERIALIZATION_FACTORY_INTERFACE

#define DATATOOLS_SERIALIZATION_FACTORY_INTERFACE (   ClassName)    DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::datatools::i_serializable,ClassName) \

Intrusive macro invoked from the class declaration to declare the automatic registration the class in a dedicated factory :

Parameters
ClassNameThe class name (possibly with its full namespace path prefix by ::) Example:

◆ DATATOOLS_SERIALIZATION_I_SERIALIZABLE_BASE_OBJECT_NVP

#define DATATOOLS_SERIALIZATION_I_SERIALIZABLE_BASE_OBJECT_NVP
Value:
boost::serialization::make_nvp("datatool__i_serializable", \
boost::serialization::base_object<datatools::i_serializable>(*this)) \
\

Macro invoked to specify the inheritance to the datatools::i_serializable within the serialization method :

Example:

class Foo : public datatools::i_serializable
{
...
};
template<class Archive>
void Foo::serialize(Archive& ar, const unsigned int version) {
...
}

◆ DATATOOLS_SERIALIZATION_IMPLEMENTATION

#define DATATOOLS_SERIALIZATION_IMPLEMENTATION (   ClassName,
  ClassSerialTag 
)    DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassSerialTag) \

Intrusive macro invoked to implement basic serialization support for the class :

Parameters
ClassNameThe class name (preferably with full namespace path prefixed by ::)
ClassSerialTagThe unique class serialization ID (tag)

Example:

◆ DATATOOLS_SERIALIZATION_IMPLEMENTATION_ADVANCED

#define DATATOOLS_SERIALIZATION_IMPLEMENTATION_ADVANCED (   ClassName,
  ClassSerialTag 
)
Value:
DATATOOLS_SERIALIZATION_IMPLEMENTATION (ClassName,ClassSerialTag) \
DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION (ClassName,ClassSerialTag) \
#define DATATOOLS_SERIALIZATION_IMPLEMENTATION(ClassName, ClassSerialTag)
Definition: i_serializable.h:348

Intrusive macro invoked to implement advanced serialization support for the class :

Parameters
ClassNameThe class name (preferably with full namespace path prefixed by ::)
ClassSerialTagThe unique class serialization ID (tag)

Example:

◆ DATATOOLS_SERIALIZATION_OLD_I_SERIALIZABLE_BASE_OBJECT_NVP

#define DATATOOLS_SERIALIZATION_OLD_I_SERIALIZABLE_BASE_OBJECT_NVP
Value:
boost::serialization::make_nvp("datatools__serialization__i_serializable", \
boost::serialization::base_object<datatools::i_serializable>(*this)) \
\

Macro invoked to specify the inheritance to the datatools::i_serializable within the serialization method (this is the original version, now obsolete) :

Example:

class Foo : public datatools::i_serializable
{
...
};
template<class Archive>
void Foo::serialize(Archive& ar, const unsigned int version) {
if (version <= ThresholdVersion) {
}
else {
}
...
}

◆ DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION

#define DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION ( )
Value:
public: \
static const std::string SERIAL_TAG; \
static const std::string & serial_tag(); \
virtual const std::string& get_serial_tag() const; \
const std::string & serial_tag()

Intrusive macro invoked from the class declaration to declare serial tag support : Example:

◆ DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION

#define DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION (   ClassName,
  ClassSerialTag 
)
Value:
const std::string ClassName::SERIAL_TAG = ClassSerialTag; \
const std::string& ClassName::serial_tag() { \
static const std::string _stag(ClassSerialTag); \
return _stag; \
} \
const std::string& ClassName::get_serial_tag() const { \
} \
const std::string & serial_tag()

Macro invoked to implement serial tag support : Example:

◆ DATATOOLS_SERIALIZATION_SERIALIZE_IMPLEMENT_HEADER

#define DATATOOLS_SERIALIZATION_SERIALIZE_IMPLEMENT_HEADER (   ClassName,
  ArchiveId,
  VersionId 
)
Value:
template<class Archive> \
void ClassName::serialize(Archive & ArchiveId, const unsigned int VersionId) \
void serialize(Archive &a_ar, geomtools::vector_3d &v_, const unsigned int a_version)

Shortcut macro to generate the proper prototype of the Boost serialization method :

Parameters
ClassNameThe class name (without
ArchiveIdThe archive identifier
VersionIdThe version version number Example:
namespace Bar {
class Foo : public datatools::i_serializable
{
DATATOOLS_SERIALIZATION_DECLARATION_BASIC()
};
}
namespace Bar {
{
ar & ...;
}
}