OSVR-Core
VrpnConnectionDevice.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_VrpnConnectionDevice_h_GUID_A5D057AB_D92A_4784_885E_3DAAAEE142A5
26 #define INCLUDED_VrpnConnectionDevice_h_GUID_A5D057AB_D92A_4784_885E_3DAAAEE142A5
27 
28 // Internal Includes
31 #include <osvr/Util/UniquePtr.h>
32 #include "VrpnBaseFlexServer.h"
34 
35 // Library/third-party includes
36 #include <vrpn_ConnectionPtr.h>
37 
38 // Standard includes
39 #include <string>
40 
41 namespace osvr {
42 namespace connection {
45  public:
47  vrpn_ConnectionPtr const &vrpnConn)
49  DeviceConstructionData data(init, vrpnConn.get());
50  m_server.reset(generateVrpnDynamicServer(data));
51  m_baseobj = data.flexServer;
52  for (auto const &component : init.getComponents()) {
53  m_baseobj->addComponent(component);
54  }
55  }
56  virtual ~VrpnConnectionDevice() {}
57  virtual void m_process() {
59  m_server->mainloop();
60  m_baseobj->mainloop();
61  }
62  virtual void m_sendData(util::time::TimeValue const &timestamp,
63  MessageType *type, const char *bytestream,
64  size_t len) {
65  VrpnMessageType *msgtype = static_cast<VrpnMessageType *>(type);
66  m_baseobj->sendData(timestamp, msgtype->getID(), bytestream, len);
67  }
68 
69  private:
70  vrpn_BaseFlexServer *m_baseobj;
71  unique_ptr<vrpn_MainloopObject> m_server;
72  };
73 } // namespace connection
74 } // namespace osvr
75 
76 #endif // INCLUDED_VrpnConnectionDevice_h_GUID_A5D057AB_D92A_4784_885E_3DAAAEE142A5
Basic implementation of a vrpn_BaseClass server.
Definition: VrpnBaseFlexServer.h:43
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: VrpnMessageType.h:40
OSVR_CONNECTION_EXPORT ConnectionDevice(std::string const &name)
Constructor for use by derived classes only.
Definition: ConnectionDevice.cpp:48
virtual void m_process()
(Subclass implementation) Process messages.
Definition: VrpnConnectionDevice.h:57
Header to bring unique_ptr into the osvr namespace.
T * addComponent(shared_ptr< T > component)
Adds a component to a base device.
Definition: BaseDevice.h:58
Structure used internally to construct the desired type of device.
Definition: DeviceInitObject.h:59
virtual void m_sendData(util::time::TimeValue const &timestamp, MessageType *type, const char *bytestream, size_t len)
(Subclass implementation) Send message.
Definition: VrpnConnectionDevice.h:62
DeviceToken & m_getDeviceToken()
accessor for device token
Definition: ConnectionDevice.cpp:81
Base class for connection-specific message type registration.
Definition: MessageType.h:38
void connectionInteract()
Interact with connection.
Definition: DeviceToken.cpp:104
Definition: DeviceConstructionData.h:41
Base class for connection-specific device data, owned by a DeviceToken.
Definition: ConnectionDevice.h:46
std::string getQualifiedName() const
Get device name qualified by plugin name.
Definition: DeviceInitObject.cpp:118
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
ConnectionDevice implementation for a VrpnBasedConnection.
Definition: VrpnConnectionDevice.h:44
virtual void mainloop()
Definition: VrpnBaseFlexServer.h:56