22 #ifndef DATATOOLS_I_SERIALIZABLE_H 23 #define DATATOOLS_I_SERIALIZABLE_H 32 #include <boost/serialization/access.hpp> 33 #include <boost/type_traits.hpp> 34 #include <boost/utility/enable_if.hpp> 35 #include <boost/mpl/has_xxx.hpp> 99 BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_bsts, backward_serial_tag_support,
false)
101 #define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_DECLARATION(ClassName) \ 102 namespace datatools { \ 104 const std::string & serial_tag< ClassName >(); \ 119 #define DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION() \ 121 static const std::string SERIAL_TAG; \ 122 static const std::string & serial_tag(); \ 123 virtual const std::string& get_serial_tag() const; \ 137 #define DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassSerialTag) \ 138 const std::string ClassName::SERIAL_TAG = ClassSerialTag; \ 139 const std::string& ClassName::serial_tag() { \ 140 static const std::string _stag(ClassSerialTag); \ 143 const std::string& ClassName::get_serial_tag() const { \ 144 return ClassName::serial_tag(); \ 149 #define DATATOOLS_SERIALIZATION_EXT_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassSerialTag) \ 150 namespace datatools { \ 152 const std::string & serial_tag<ClassName> (){ \ 153 static std::unique_ptr<std::string> _serial_tag; \ 154 if ( !_serial_tag){ \ 155 _serial_tag.reset(new std::string(ClassSerialTag)); \ 157 return *_serial_tag.get(); \ 174 #define DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT() \ 176 struct backward_serial_tag_support {}; \ 180 #define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION(ClassName) \ 181 namespace datatools { \ 183 const std::string & backward_serial_tag< ClassName > (int); \ 188 #define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassBackwardSerialTag) \ 189 namespace datatools { \ 191 const std::string & backward_serial_tag<ClassName> (int ){ \ 192 static std::unique_ptr<std::string> _backward_serial_tag; \ 193 if ( !_backward_serial_tag){ \ 194 _backward_serial_tag.reset (new std::string(ClassBackwardSerialTag)); \ 196 return *_backward_serial_tag.get (); \ 219 #define DATATOOLS_SERIALIZATION_I_SERIALIZABLE_BASE_OBJECT_NVP \ 220 boost::serialization::make_nvp("datatool__i_serializable", \ 221 boost::serialization::base_object<datatools::i_serializable>(*this)) \ 248 #define DATATOOLS_SERIALIZATION_OLD_I_SERIALIZABLE_BASE_OBJECT_NVP \ 249 boost::serialization::make_nvp("datatools__serialization__i_serializable", \ 250 boost::serialization::base_object<datatools::i_serializable>(*this)) \ 266 #define DATATOOLS_SERIALIZATION_DECLARATION() \ 268 DATATOOLS_SERIALIZATION_SERIAL_TAG_DECLARATION() \ 269 BOOST_SERIALIZATION_BASIC_DECLARATION () \ 293 #define DATATOOLS_SERIALIZATION_SERIALIZE_IMPLEMENT_HEADER(ClassName,ArchiveId,VersionId) \ 294 template<class Archive> \ 295 void ClassName::serialize(Archive & ArchiveId, const unsigned int VersionId) \ 310 #define DATATOOLS_SERIALIZATION_FACTORY_INTERFACE(ClassName) \ 311 DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::datatools::i_serializable,ClassName) \ 328 #define DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION(ClassName,ClassSerialTag) \ 329 DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::datatools::i_serializable,ClassName,ClassSerialTag) \ 348 #define DATATOOLS_SERIALIZATION_IMPLEMENTATION(ClassName,ClassSerialTag) \ 349 DATATOOLS_SERIALIZATION_SERIAL_TAG_IMPLEMENTATION(ClassName,ClassSerialTag) \ 371 #define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName) \ 372 DATATOOLS_SERIALIZATION_DECLARATION() \ 373 DATATOOLS_SERIALIZATION_FACTORY_INTERFACE(ClassName) \ 398 #define DATATOOLS_SERIALIZATION_IMPLEMENTATION_ADVANCED(ClassName,ClassSerialTag) \ 399 DATATOOLS_SERIALIZATION_IMPLEMENTATION (ClassName,ClassSerialTag) \ 400 DATATOOLS_SERIALIZATION_FACTORY_IMPLEMENTATION (ClassName,ClassSerialTag) \ 407 template <
typename T>
409 const std::string alt_tag_ =
"",
410 typename boost::disable_if< has_bsts<T> >::type* dummy_ = 0)
412 if(!dummy_) dummy_ = 0;
414 if (! alt_tag_.empty()){
415 if (stag_ == alt_tag_)
return true;
420 template <
typename T>
422 const std::string alt_tag_ =
"",
423 typename boost::enable_if< has_bsts<T> >::type* dummy_ = 0)
425 if(!dummy_) dummy_ = 0;
427 if (stag_ == ::datatools::backward_serial_tag<T> (0))
return true;
428 if (! alt_tag_.empty()) {
429 if (stag_ == alt_tag_)
return true;
436 #endif // DATATOOLS_I_SERIALIZABLE_H #define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
#define BOOST_SERIALIZATION_BASIC_DECLARATION()
Definition: serialization_macros.h:62