OSVR-Core
VrpnBasedConnection.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_VrpnBasedConnection_h_GUID_49F2C30F_D807_43B1_A754_9B645D3A1809
26 #define INCLUDED_VrpnBasedConnection_h_GUID_49F2C30F_D807_43B1_A754_9B645D3A1809
27 
28 // Internal Includes
31 
32 // Library/third-party includes
33 #include <vrpn_Connection.h>
34 #include <vrpn_ConnectionPtr.h>
35 
36 // Standard includes
37 // - none
38 
39 namespace osvr {
40 namespace connection {
41  namespace messageid {
43  const char *vrpnPing();
44  } // namespace messageid
46  public:
47  enum ConnectionType { VRPN_LOCAL_ONLY, VRPN_SHARED, VRPN_LOOPBACK };
48 
50  VrpnBasedConnection(ConnectionType type);
51 
54  VrpnBasedConnection(boost::optional<std::string const &> iface,
55  boost::optional<int> port);
56 
58  virtual void *getUnderlyingObject();
59  virtual const char *getConnectionKindID();
60  virtual ~VrpnBasedConnection();
61 
62  private:
68  void m_initConnection(const char NIC[] = nullptr, int port = 0);
69 
70  virtual MessageTypePtr
71  m_registerMessageType(std::string const &messageId);
72  virtual ConnectionDevicePtr
73  m_createConnectionDevice(DeviceInitObject &init);
74  virtual void m_registerConnectionHandler(std::function<void()> handler);
75  virtual void m_process();
76 
77  static int VRPN_CALLBACK m_connectionHandler(void *userdata,
78  vrpn_HANDLERPARAM);
79 
80  vrpn_ConnectionPtr m_vrpnConnection;
81  std::vector<std::function<void()> > m_connectionHandlers;
82  common::NetworkingSupport m_network;
83  };
84 
85 } // namespace connection
86 } // namespace osvr
87 #endif // INCLUDED_VrpnBasedConnection_h_GUID_49F2C30F_D807_43B1_A754_9B645D3A1809
Header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Class wrapping a messaging transport (server or internal) connection.
Definition: Connection.h:56
RAII class wrapping networking system startup.
Definition: NetworkingSupport.h:43
Structure used internally to construct the desired type of device.
Definition: DeviceInitObject.h:59
Definition: VrpnBasedConnection.h:45
const char * vrpnPing()
Return the string identifying VRPN ping messages.
Definition: VrpnBasedConnection.cpp:42
unique_ptr< MessageType > MessageTypePtr
a uniquely-owned handle for holding a message type registration.
Definition: MessageTypePtr.h:42
shared_ptr< ConnectionDevice > ConnectionDevicePtr
How to hold on to a ConnectionDevice.
Definition: ConnectionDevicePtr.h:40