SerializableInterface.hpp
1 #pragma once
2 #include <score/plugins/UuidKey.hpp>
3 #include <score/serialization/VisitorInterface.hpp>
4 
5 namespace score
6 {
19 template <typename T>
21 {
22 public:
23  using key_type = UuidKey<T>;
24  using is_abstract_base_tag = std::integral_constant<bool, true>;
25 
26  SerializableInterface() = default;
27  virtual ~SerializableInterface() = default;
28  virtual UuidKey<T> concreteKey() const noexcept = 0;
29 
30  virtual void serialize_impl(const VisitorVariant& vis) const { }
31 };
32 }
33 
38 #define MODEL_METADATA_IMPL(Model_T) \
39  static key_type static_concreteKey() noexcept \
40  { \
41  return Metadata<ConcreteKey_k, Model_T>::get(); \
42  } \
43  key_type concreteKey() const noexcept override \
44  { \
45  return static_concreteKey(); \
46  } \
47  void serialize_impl(const VisitorVariant& vis) const noexcept override \
48  { \
49  score::serialize_dyn(vis, *this); \
50  }
51 
52 #define MODEL_METADATA_IMPL_HPP(Model_T) \
53  static key_type static_concreteKey() noexcept; \
54  key_type concreteKey() const noexcept override; \
55  void serialize_impl(const VisitorVariant& vis) const noexcept override;
56 
57 #define MODEL_METADATA_IMPL_CPP(Model_T) \
58  Model_T::key_type Model_T::static_concreteKey() noexcept \
59  { \
60  return Metadata<ConcreteKey_k, Model_T>::get(); \
61  } \
62  Model_T::key_type Model_T::concreteKey() const noexcept \
63  { \
64  return static_concreteKey(); \
65  } \
66  void Model_T::serialize_impl(const VisitorVariant& vis) const noexcept \
67  { \
68  score::serialize_dyn(vis, *this); \
69  }
Definition: UuidKey.hpp:343
Generic serialization method for abstract classes.
Definition: SerializableInterface.hpp:21
Base toolkit upon which the software is built.
Definition: Application.cpp:90
The VisitorVariant struct.
Definition: VisitorInterface.hpp:26