OSVR-Core
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::ArticulationElement>
69  serializationDescription(Functor &f, ValType &value) {
70  f("articulationName", value.getArticulationType());
71  f("boneName", value.getBoneName());
72  f("trackerPath", value.getTrackerPath());
73  }
74 
76  template <typename Functor, typename ValType>
77  inline enable_if_element_type<ValType, elements::StringElement>
78  serializationDescription(Functor &f, ValType &value) {
79  f("string", value.getString());
80  }
81 
82  // Descriptions for elements without extra data
83  template <typename Functor, typename ValType>
84  inline enable_if_element_type<ValType, elements::NullElement>
85  serializationDescription(Functor &, ValType &) {}
86  template <typename Functor, typename ValType>
87  inline enable_if_element_type<ValType, elements::PluginElement>
88  serializationDescription(Functor &, ValType &) {}
89  template <typename Functor, typename ValType>
90  inline enable_if_element_type<ValType, elements::InterfaceElement>
91  serializationDescription(Functor &, ValType &) {}
92  template <typename Functor, typename ValType>
93  inline enable_if_element_type<ValType, elements::SensorElement>
94  serializationDescription(Functor &, ValType &) {}
95 
96  } // namespace
97 } // namespace common
98 } // namespace osvr
99 #endif // INCLUDED_PathElementSerializationDescriptions_h_GUID_88DACA90_818A_4B81_9655_1177F10E8142
Definition: NonLinearOptimization.cpp:107
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3