framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
container_type.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 
18 
19 namespace framework
20 {
21  namespace serializable
22  {
23  namespace detail
24  {
25  template <typename T>
26  struct recursive_serializable_specification;
27 
28  template <typename T, typename Enabler = void>
29  struct is_container_type_impl;
30 
31  template <typename T, typename Enabler = void>
32  struct is_container_default_serializable_impl;
33 
34  template <typename T>
35  struct container_specification_impl;
36 
37  template <typename T>
38  struct container_children_impl;
39  }
40 
64  template <
65  typename Specification,
66  typename Children,
67  bool Default = true>
69  {
70 // GCC bug workaround - www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580
71 #if MAX_GNUC_VERSION(4, 8, 0)
72  public:
73 #else
74  template <typename T, typename Enabler>
75  friend struct detail::is_container_type_impl;
76 
77  template <typename T, typename Enabler>
78  friend struct detail::is_container_default_serializable_impl;
79 
80  template <typename T>
81  friend struct detail::container_specification_impl;
82 
83  template <typename T>
84  friend struct detail::container_children_impl;
85 
86  private:
87 #endif
88  using serializable_container_enabler = void;
89  using serializable_container_specification = typename std::enable_if <is_pack_container <Specification>::value, Specification>::type;
90  using serializable_container_children = typename std::enable_if <is_pack_container <Children>::value, Children>::type;
91  enum{ serializable_container_default = Default };
92 
93  container_type () = delete;
94  ~container_type () = delete;
95  };
96 
103  template <typename T>
104  using is_container_type = typename detail::is_container_type_impl <T>::type;
105 
112  template <typename T>
113  using is_container_default_serializable = typename detail::is_container_default_serializable_impl <T>::type;
114 
122  template <typename T>
123  using container_specification = typename detail::container_specification_impl <T>::type;
124 
132  template <typename T>
133  using container_children = typename detail::container_children_impl <T>::type;
134 
145  template <
146  typename Specification,
147  typename Children,
148  typename... Args>
152  Args&&... args)
153  {
154  return detail::recursive_serializable_specification <Specification>::read(std::forward <Args> (args)...);
155  }
156 
167  template <
168  typename Specification,
169  typename Children,
170  typename... Args>
174  Args&&... args)
175  {
176  return detail::recursive_serializable_specification <Specification>::write(std::forward <Args> (args)...);
177  }
178  }
179 }
180 
181 #include <framework/serializable/container_type.inl>