hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
fwd.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2024 INRIA
3 //
4 
5 #ifndef HPP_FCL_SERIALIZATION_FWD_H
6 #define HPP_FCL_SERIALIZATION_FWD_H
7 
8 #include <type_traits>
9 
10 #include <boost/archive/text_iarchive.hpp>
11 #include <boost/archive/text_oarchive.hpp>
12 #include <boost/archive/xml_iarchive.hpp>
13 #include <boost/archive/xml_oarchive.hpp>
14 #include <boost/archive/binary_iarchive.hpp>
15 #include <boost/archive/binary_oarchive.hpp>
16 
17 #include <boost/serialization/split_free.hpp>
18 #include <boost/serialization/shared_ptr.hpp>
19 #include <boost/serialization/export.hpp>
20 
21 #include "hpp/fcl/fwd.hh"
23 
24 #define HPP_FCL_SERIALIZATION_SPLIT(Type) \
25  template <class Archive> \
26  void serialize(Archive& ar, Type& value, const unsigned int version) { \
27  split_free(ar, value, version); \
28  }
29 
30 #define HPP_FCL_SERIALIZATION_DECLARE_EXPORT(T) \
31  BOOST_CLASS_EXPORT_KEY(T) \
32  namespace boost { \
33  namespace archive { \
34  namespace detail { \
35  namespace extra_detail { \
36  template <> \
37  struct init_guid<T> { \
38  static guid_initializer<T> const& g; \
39  }; \
40  } \
41  } \
42  } \
43  } \
44 
45 
46 #define HPP_FCL_SERIALIZATION_DEFINE_EXPORT(T) \
47  namespace boost { \
48  namespace archive { \
49  namespace detail { \
50  namespace extra_detail { \
51  guid_initializer<T> const& init_guid<T>::g = \
52  ::boost::serialization::singleton< \
53  guid_initializer<T> >::get_mutable_instance() \
54  .export_guid(); \
55  } \
56  } \
57  } \
58  } \
59 
60 
61 namespace hpp {
62 namespace fcl {
63 namespace serialization {
64 namespace detail {
65 
66 template <class Derived, class Base>
68 
69 template <class Derived, class Base>
71  void init(std::true_type) const {
72  boost::serialization::void_cast_register<Derived, Base>();
73  }
74 
75  void init(std::false_type) const {}
76 
79  _Pragma("GCC diagnostic ignored \"-Wconversion\"")
80  BOOST_STATIC_WARNING((std::is_base_of<Base, Derived>::value));
82  init(std::is_base_of<Base, Derived>());
83  return *this;
84  }
85 };
86 
87 } // namespace detail
88 
89 template <typename T>
90 struct register_type {
91  template <class Archive>
92  static void on(Archive& /*ar*/) {}
93 };
94 } // namespace serialization
95 } // namespace fcl
96 } // namespace hpp
97 
98 #define HPP_FCL_SERIALIZATION_CAST_REGISTER(Derived, Base) \
99  namespace hpp { \
100  namespace fcl { \
101  namespace serialization { \
102  namespace detail { \
103  template <> \
104  struct init_cast_register<Derived, Base> { \
105  static cast_register_initializer<Derived, Base> const& g; \
106  }; \
107  cast_register_initializer<Derived, Base> const& init_cast_register< \
108  Derived, Base>::g = \
109  ::boost::serialization::singleton< \
110  cast_register_initializer<Derived, Base> >::get_mutable_instance() \
111  .init(); \
112  } \
113  } \
114  } \
115  }
116 
117 #endif // ifndef HPP_FCL_SERIALIZATION_FWD_H
#define HPP_FCL_COMPILER_DIAGNOSTIC_PUSH
Definition: fwd.hh:120
#define HPP_FCL_COMPILER_DIAGNOSTIC_POP
Definition: fwd.hh:121
Main namespace.
Definition: broadphase_bruteforce.h:44
void init(std::true_type) const
Definition: fwd.h:71
void init(std::false_type) const
Definition: fwd.h:75
cast_register_initializer const & init() const
Definition: fwd.h:77
static void on(Archive &)
Definition: fwd.h:92