OSVR-Core
SkeletonComponent.h
Go to the documentation of this file.
1 
11 // Copyright 2015 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_SkeletonComponent_h_GUID_53FA481D_05BD_4CA5_3A50_FE01B600476E
26 #define INCLUDED_SkeletonComponent_h_GUID_53FA481D_05BD_4CA5_3A50_FE01B600476E
27 
28 // Internal Includes
31 #include <osvr/Common/Export.h>
32 #include <osvr/Common/PathTree.h>
36 #include <osvr/Util/ReturnCodesC.h>
37 
38 // Library/third-party includes
39 #include <json/value.h>
40 #include <vrpn_BaseClass.h>
41 
42 // Standard includes
43 #include <string>
44 
45 namespace osvr {
46 namespace common {
47 
49  OSVR_ChannelCount sensor;
50  };
51 
52  struct SkeletonSpec {
53  Json::Value spec;
54  };
55 
56  namespace messages {
57  class SkeletonRecord : public MessageRegistration<SkeletonRecord> {
58  public:
60 
61  static const char *identifier();
62  };
64  : public MessageRegistration<SkeletonSpecRecord> {
65  public:
67 
68  static const char *identifier();
69  };
70 
71  } // namespace messages
72 
75  public:
80  static OSVR_COMMON_EXPORT shared_ptr<SkeletonComponent>
81  create(std::string const &jsonSpec);
82 
86 
90 
94  OSVR_COMMON_EXPORT void
95  sendNotification(OSVR_ChannelCount sensor,
96  OSVR_TimeValue const &timestamp);
97 
100  OSVR_COMMON_EXPORT void sendArticulationSpec(std::string const &spec);
101 
104  OSVR_COMMON_EXPORT OSVR_ReturnCode
105  setArticulationSpec(std::string const &jsonDescriptor);
106 
107  typedef std::function<void(SkeletonNotification const &,
108  util::time::TimeValue const &)>
109  SkeletonHandler;
110  typedef std::function<void(SkeletonSpec const &,
111  util::time::TimeValue const &)>
112  SkeletonSpecHandler;
113  OSVR_COMMON_EXPORT void registerSkeletonHandler(SkeletonHandler cb);
114  OSVR_COMMON_EXPORT void
115  registerSkeletonSpecHandler(SkeletonSpecHandler cb);
116 
117  private:
118  SkeletonComponent(std::string const &jsonSpec);
119  virtual void m_parentSet();
120 
121  static int VRPN_CALLBACK m_handleSkeletonRecord(void *userdata,
122  vrpn_HANDLERPARAM p);
123  static int VRPN_CALLBACK
124  m_handleSkeletonSpecRecord(void *userdata, vrpn_HANDLERPARAM p);
126  std::string m_spec;
127  std::vector<SkeletonHandler> m_cb;
128  std::vector<SkeletonSpecHandler> m_cb_spec;
130  common::CommonComponent *m_commonComponent;
131  };
132 
133 } // namespace common
134 } // namespace osvr
135 
136 #endif // INCLUDED_SkeletonComponent_h_GUID_53FA481D_05BD_4CA5_3A50_FE01B600476E
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
Header declaring a type and values for simple C return codes.
Definition: CommonComponent.h:44
Definition: SkeletonComponent.h:57
Definition: SkeletonComponent.h:48
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
messages::SkeletonRecord skeletonRecord
Message from server to client, containing skeleton notification.
Definition: SkeletonComponent.h:85
BaseDevice component, for the VRPN built-in common messages.
Definition: CommonComponent.h:82
Definition: DeviceComponent.h:42
CRTP class template wrapping message-specific data and/or logic.
Definition: MessageRegistration.h:44
Definition: SkeletonComponent.h:63
Header.
BaseDevice component.
Definition: SkeletonComponent.h:74
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
messages::SkeletonSpecRecord skeletonSpecRecord
Message from server to client, containing new/updated skeleton articulation spec. ...
Definition: SkeletonComponent.h:89
Definition: SkeletonComponent.h:52