OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SystemComponent.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_SystemComponent_h_GUID_F74B8728_915D_44AE_612B_6AB934CA4ED2
26 #define INCLUDED_SystemComponent_h_GUID_F74B8728_915D_44AE_612B_6AB934CA4ED2
27 
28 // Internal Includes
30 #include <osvr/Common/Export.h>
34 
35 // Library/third-party includes
36 #include <json/value.h>
37 
38 // Standard includes
39 // - none
40 
41 namespace osvr {
42 namespace common {
43  namespace messages {
44  class RoutesFromServer : public MessageRegistration<RoutesFromServer> {
45  public:
47  typedef void (*MessageHandler)(void *userdata,
48  std::string const &message);
49 
50  static const char *identifier();
51  };
52 
54  : public MessageRegistration<AppStartupToServer> {
55  public:
56  static const char *identifier();
57  };
58 
60  : public MessageRegistration<ClientRouteToServer> {
61  public:
63  static const char *identifier();
64  };
65 
67  : public MessageRegistration<ReplacementTreeFromServer> {
68  public:
70  static const char *identifier();
71  };
72  } // namespace messages
73 
77  public:
79  OSVR_COMMON_EXPORT static const char *deviceName();
84  static OSVR_COMMON_EXPORT shared_ptr<SystemComponent> create();
85 
88 
89  OSVR_COMMON_EXPORT void sendRoutes(std::string const &routes);
90  OSVR_COMMON_EXPORT void
91  registerRoutesHandler(vrpn_MESSAGEHANDLER handler, void *userdata);
92 
95 
99 
100  OSVR_COMMON_EXPORT void sendClientRouteUpdate(std::string const &route);
101  OSVR_COMMON_EXPORT void
102  registerClientRouteUpdateHandler(vrpn_MESSAGEHANDLER handler,
103  void *userdata);
104 
108 
109  typedef std::function<void(Json::Value const &,
110  util::time::TimeValue const &)> JsonHandler;
111  OSVR_COMMON_EXPORT void registerReplaceTreeHandler(JsonHandler cb);
112 
113  OSVR_COMMON_EXPORT void sendReplacementTree(PathTree &tree);
114 
115  private:
116  SystemComponent();
117  virtual void m_parentSet();
118  static int VRPN_CALLBACK
119  m_handleReplaceTree(void *userdata, vrpn_HANDLERPARAM p);
120 
121  std::vector<JsonHandler> m_replaceTreeHandlers;
122  };
123 } // namespace common
124 } // namespace osvr
125 
126 #endif // INCLUDED_SystemComponent_h_GUID_F74B8728_915D_44AE_612B_6AB934CA4ED2
RAII class template managing a message handler callback.
messages::ReplacementTreeFromServer treeOut
Message from server, updating/replacing the client's configuration.
A tree representation, with path/url syntax, of the known OSVR system.
Definition: PathTree.h:43
messages::AppStartupToServer appStartup
Message from client to server, notifying of app ID.
messages::ClientRouteToServer routeIn
Message from client, sending a single new/updated JSON routing directive in to the server...
CRTP class template wrapping message-specific data and/or logic.
messages::RoutesFromServer routesOut
Message from server to client, replacing all routes.
static shared_ptr< SystemComponent > create()
Factory method.
Automatically-generated export header - do not edit!
static const char * deviceName()
Get the special device name to be used with this component.
BaseDevice component, to be used only with the "OSVR" special device.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81