OSVR-Core
ReportState.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ReportState_h_GUID_452FA875_E51C_4A88_5A58_E28CB6F40B86
26 #define INCLUDED_ReportState_h_GUID_452FA875_E51C_4A88_5A58_E28CB6F40B86
27 
28 // Internal Includes
29 #include <osvr/Util/ClientCallbackTypesC.h>
30 #include <osvr/Common/StateType.h>
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 // - none
37 
38 namespace osvr {
39 namespace common {
40  namespace traits {
41 
48  template <typename ReportType> struct ReportStateGetter {
49  static typename StateType<ReportType>::type const &
50  apply(ReportType const &r) {
51  return r.state;
52  }
53  static typename StateType<ReportType>::type apply(ReportType &r) {
54  return r.state;
55  }
56  };
57 
58  // Template specialization to handle OSVR_PositionReport
59  template <> struct ReportStateGetter<OSVR_PositionReport> {
60  static OSVR_PositionState const &
61  apply(OSVR_PositionReport const &r) {
62  return r.xyz;
63  }
64  static OSVR_PositionState apply(OSVR_PositionReport &r) {
65  return r.xyz;
66  }
67  };
68 
69  // Template specialization to handle OSVR_PoseReport
70  template <> struct ReportStateGetter<OSVR_PoseReport> {
71  static OSVR_PoseState const &apply(OSVR_PoseReport const &r) {
72  return r.pose;
73  }
74  static OSVR_PoseState apply(OSVR_PoseReport &r) { return r.pose; }
75  };
76 
77  // Template specialization to handle OSVR_OrientationReport
79  static OSVR_OrientationState const &
80  apply(OSVR_OrientationReport const &r) {
81  return r.rotation;
82  }
84  return r.rotation;
85  }
86  };
87 
88  // Template specialization to handle OSVR_Location2DReport
90  static OSVR_Location2DState const &
91  apply(OSVR_Location2DReport const &r) {
92  return r.location;
93  }
95  return r.location;
96  }
97  };
98 
99  // Template specialization to handle OSVR_DirectionReport
101  static OSVR_DirectionState const &
102  apply(OSVR_DirectionReport const &r) {
103  return r.direction;
104  }
105  static OSVR_DirectionState apply(OSVR_DirectionReport &r) {
106  return r.direction;
107  }
108  };
109 
110  } // namespace traits
111 
113  template <typename ReportType>
114  typename traits::StateType<ReportType>::type const &
115  reportState(ReportType const &r) {
117  }
118 
120  template <typename ReportType>
123  }
124 } // namespace common
125 } // namespace osvr
126 
127 #endif // INCLUDED_ReportState_h_GUID_452FA875_E51C_4A88_5A58_E28CB6F40B86
OSVR_PoseState pose
The pose structure, containing a position vector and a rotation quaternion.
Definition: ClientReportTypesC.h:161
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
A structure defining a 3D vector, often a position/translation.
Definition: Vec3C.h:48
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
A structure defining a quaternion, often a unit quaternion representing 3D rotation.
Definition: QuaternionC.h:49
Header.
traits::StateType< ReportType >::type const & reportState(ReportType const &r)
Generic const accessor for the "state" member of a report.
Definition: ReportState.h:115
Report type for 3D Direction vector.
Definition: ClientReportTypesC.h:256
Helper traits struct for reportState(), to access the state member of the various report types...
Definition: ReportState.h:48
A structure defining a 2D vector, which represents position.
Definition: Vec2C.h:48
Report type for 2D location.
Definition: ClientReportTypesC.h:247
Metafunction/trait taking a ReportType and returning the associated StateType.
Definition: ReportTraits.h:60
Report type for an orientation callback on a tracker interface.
Definition: ClientReportTypesC.h:145
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Definition: Pose3C.h:54
OSVR_PositionState xyz
The position vector.
Definition: ClientReportTypesC.h:141
Report type for a position callback on a tracker interface.
Definition: ClientReportTypesC.h:137
OSVR_OrientationState rotation
The rotation unit quaternion.
Definition: ClientReportTypesC.h:149
Report type for a pose (position and orientation) callback on a tracker interface.
Definition: ClientReportTypesC.h:155