OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DeviceWrapper.cpp
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 // Internal Includes
26 #include "DeviceWrapper.h"
27 
28 // Library/third-party includes
29 // - none
30 
31 // Standard includes
32 // - none
33 
34 namespace osvr {
35 namespace common {
36 
37  DeviceWrapper::DeviceWrapper(std::string const &name,
38  vrpn_ConnectionPtr const &conn, bool client)
39  : vrpn_BaseClass(name.c_str(), conn.get()), m_conn(conn),
40  m_client(client) {
41  vrpn_BaseClass::init();
42  m_setup(conn, common::RawSenderType(d_sender_id), name);
43 
44  // Clients: don't print "haven't heard from server" messages.
45  if (client) {
46  shutup = true;
47  }
48  }
49 
50  DeviceWrapper::~DeviceWrapper() {}
51 
52  void DeviceWrapper::mainloop() { update(); }
53 
54  void DeviceWrapper::m_update() {
55  if (m_client) {
56  m_getConnection()->mainloop();
57  client_mainloop();
58  } else {
59  server_mainloop();
60  }
61  }
62 
63  int DeviceWrapper::register_types() {
64  return 0; // success
65  }
66 } // namespace common
67 } // namespace osvr
ref_type_at_key< Derived, Key >::type get(TypeKeyedBase< Derived > &c)
Definition: TypeKeyed.h:200
vrpn_ConnectionPtr m_getConnection() const
Accessor for underlying connection.
Definition: BaseDevice.cpp:113
void update()
Called from the outside to run the mainloop on the device and its components.
Definition: BaseDevice.cpp:79