framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
serializable.hpp
Go to the documentation of this file.
1 // Copyright (C) 2012 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
13 #pragma once
14 
17 
18 namespace framework
19 {
20  namespace serializable
21  {
22  namespace detail
23  {
24  template <typename T, typename Enabler = void>
25  struct is_object_type_impl;
26 
27  template <typename T, typename Enabler = void>
28  struct is_object_default_serializable_impl;
29 
30  template <typename T, typename Name>
31  struct object_base_impl;
32 
33  template <typename T>
34  struct object_names_impl;
35 
36  template <typename T>
37  struct object_specification_impl;
38 
39  template <typename T, template <typename> class Path, typename Enabler = void>
40  struct extract_values_impl;
41  }
42 
62  template <
63  typename Derived,
64  typename Specification,
65  typename Inherited,
66  typename Constructed,
67  typename Visible,
68  bool Default = true>
69 #ifndef DOXYGEN
70  class serializable_implementation;
71 #else
73  {
74  protected:
78  ~serializable_implementation () = default;
79 
83  serializable_implementation () = default;
84 
91  template <typename... Args>
92  serializable_implementation (Args&&... args);
93 
98  };
99 #endif
100 
107  template <typename T>
108  using is_object_type = typename detail::is_object_type_impl <T>::type;
109 
116  template <typename T>
117  using is_object_default_serializable = typename detail::is_object_default_serializable_impl <T>::type;
118 
126  template <typename T, typename Name>
127  using object_base = typename detail::object_base_impl <T, Name>::type;
128 
136  template <typename T>
137  using object_names = typename detail::object_names_impl <T>::type;
138 
146  template <typename T>
147  using object_specification = typename detail::object_specification_impl <T>::type;
148 
176  template <typename Pack, template <typename> class Path>
177  using extract_values = typename detail::extract_values_impl <Pack, Path>::type;
178 
182  template <
183  typename Derived,
184  typename Specification,
185  typename Inherited,
186  typename Constructed,
187  typename Visible,
188  typename... Args>
189  bool read_dispatch (
191  Derived,
192  Specification,
193  Inherited,
194  Constructed,
195  Visible,
196  true>*,
197  Args&&... args)
198  {
199  return dispatch_read <Specification> (std::forward <Args> (args)...);
200  }
201 
205  template <
206  typename Derived,
207  typename Specification,
208  typename Inherited,
209  typename Constructed,
210  typename Visible,
211  typename... Args>
212  bool write_dispatch (
213  serializable_implementation <
214  Derived,
215  Specification,
216  Inherited,
217  Constructed,
218  Visible,
219  true>*,
220  Args&&... args)
221  {
222  return dispatch_write <Specification> (std::forward <Args> (args)...);
223  }
224 
234  template <typename Derived, typename... Specification>
235  using serializable = serializable_implementation <
236  Derived,
237  alias <Specification...>,
238  extract_values <alias <Specification...>, container_specification>,
239  extract_values <alias <Specification...>, container_children>,
240  extract_values <alias <Specification...>, container_children>>;
241 
252  template <typename Derived, typename... Specification>
254  Derived,
255  alias <Specification...>,
256  extract_values <alias <Specification...>, container_specification>,
257  extract_values <alias <Specification...>, container_children>,
258  extract_values <alias <Specification...>, container_children>,
259  false>;
260  }
261 }
262 
263 #include <framework/serializable/serializable.inl>