33 #ifndef __H__UG_archivar
34 #define __H__UG_archivar
36 #include <boost/static_assert.hpp>
37 #include <boost/mpl/for_each.hpp>
38 #include <boost/type_traits/is_base_of.hpp>
39 #include "../boost_serialization.h"
47 template <
typename TArchive,
typename TBase,
typename TDerived>
50 BOOST_STATIC_ASSERT((boost::is_base_of<TBase, TDerived>::value));
51 TDerived& derived =
dynamic_cast<TDerived&
>(base);
52 ar & make_nvp(
name, derived);
57 template <
class TArchive,
class TBase,
class TPairSeq>
64 boost::mpl::for_each<TPairSeq>(
func);
76 std::string typeName(
typeid(t).
name());
78 typename callback_map_t::iterator icallback =
m_callbackMap.find(typeName);
80 "Unregistered class used in 'Archivar::archive': " << typeName);
82 icallback->second(ar, t,
name);
85 template <
class TDerived>
88 BOOST_STATIC_ASSERT((boost::is_base_of<TBase, TDerived>::value));
89 std::string typeName(
typeid(TDerived).
name());
91 &detail::archivar::CallArchiveOnDerivedClass<TArchive, TBase, TDerived>;
location name
Definition: checkpoint_util.lua:128
Definition: archivar.h:59
void register_class(const char *name)
Definition: archivar.h:86
void archive(TArchive &ar, T &t)
Definition: archivar.h:68
std::map< std::string, archive_sig > callback_map_t
Definition: archivar.h:97
callback_map_t m_callbackMap
Definition: archivar.h:98
Archivar()
Definition: archivar.h:61
void archive(TArchive &ar, T &t, const char *name)
Definition: archivar.h:74
void(* archive_sig)(TArchive &, TBase &, const char *name)
Definition: archivar.h:95
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
void CallArchiveOnDerivedClass(TArchive &ar, TBase &base, const char *name)
Definition: archivar.h:48
function func(x, y, z, t, si)
Definition: register_type_pair_functor.h:43