OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PathElementSerializationDescriptions.h
Go to the documentation of this file.
1 
13 // Copyright 2015 Sensics, Inc.
14 //
15 // Licensed under the Apache License, Version 2.0 (the "License");
16 // you may not use this file except in compliance with the License.
17 // You may obtain a copy of the License at
18 //
19 // http://www.apache.org/licenses/LICENSE-2.0
20 //
21 // Unless required by applicable law or agreed to in writing, software
22 // distributed under the License is distributed on an "AS IS" BASIS,
23 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 // See the License for the specific language governing permissions and
25 // limitations under the License.
26 
27 #ifndef INCLUDED_PathElementSerializationDescriptions_h_GUID_88DACA90_818A_4B81_9655_1177F10E8142
28 #define INCLUDED_PathElementSerializationDescriptions_h_GUID_88DACA90_818A_4B81_9655_1177F10E8142
29 
30 // Internal Includes
32 
33 // Library/third-party includes
34 // - none
35 
36 // Standard includes
37 #include <type_traits>
38 
39 namespace osvr {
40 namespace common {
41  namespace {
42 
45  template <typename Input, typename Known>
46  using enable_if_element_type = typename std::enable_if<std::is_same<
47  typename std::remove_const<Input>::type, Known>::value>::type;
48 
50  template <typename Functor, typename ValType>
51  inline enable_if_element_type<ValType, elements::DeviceElement>
52  serializationDescription(Functor &f, ValType &value) {
53  f("device_name", value.getDeviceName());
54  f("server", value.getServer());
55  f("descriptor", value.getDescriptor());
56  }
57 
59  template <typename Functor, typename ValType>
60  inline enable_if_element_type<ValType, elements::AliasElement>
61  serializationDescription(Functor &f, ValType &value) {
62  f("source", value.getSource());
63  f("priority", value.priority());
64  }
65 
67  template <typename Functor, typename ValType>
68  inline enable_if_element_type<ValType, elements::StringElement>
69  serializationDescription(Functor &f, ValType &value) {
70  f("string", value.getString());
71  }
72 
73  // Descriptions for elements without extra data
74  template <typename Functor, typename ValType>
75  inline enable_if_element_type<ValType, elements::NullElement>
76  serializationDescription(Functor &, ValType &) {}
77  template <typename Functor, typename ValType>
78  inline enable_if_element_type<ValType, elements::PluginElement>
79  serializationDescription(Functor &, ValType &) {}
80  template <typename Functor, typename ValType>
81  inline enable_if_element_type<ValType, elements::InterfaceElement>
82  serializationDescription(Functor &, ValType &) {}
83  template <typename Functor, typename ValType>
84  inline enable_if_element_type<ValType, elements::SensorElement>
85  serializationDescription(Functor &, ValType &) {}
86 
87  } // namespace
88 } // namespace common
89 } // namespace osvr
90 #endif // INCLUDED_PathElementSerializationDescriptions_h_GUID_88DACA90_818A_4B81_9655_1177F10E8142