25 #ifndef INCLUDED_Connection_h_GUID_61C65986_E2C9_498F_59F0_8EFC712BA183 26 #define INCLUDED_Connection_h_GUID_61C65986_E2C9_498F_59F0_8EFC712BA183 29 #include <osvr/Connection/Export.h> 39 #include <boost/noncopyable.hpp> 40 #include <boost/optional.hpp> 41 #include <boost/range/iterator_range.hpp> 52 namespace connection {
57 public enable_shared_from_this<Connection> {
64 OSVR_CONNECTION_EXPORT
static ConnectionPtr createLocalConnection();
72 boost::optional<int> port);
74 OSVR_CONNECTION_EXPORT
static std::tuple<void *, ConnectionPtr>
75 createLoopbackConnection();
84 OSVR_CONNECTION_EXPORT
static void 113 OSVR_CONNECTION_EXPORT
void process();
117 OSVR_CONNECTION_EXPORT
void 121 OSVR_CONNECTION_EXPORT
void 131 typedef std::vector<ConnectionDevicePtr> DeviceList;
134 boost::iterator_range<DeviceList::const_iterator>
getDevices()
const {
135 return boost::make_iterator_range(begin(m_devices), end(m_devices));
153 std::string
const &deviceName,
170 NameList
const &deviceNames,
204 DeviceList m_devices;
205 std::vector<std::function<void()> > m_descriptorHandlers;
206 util::log::LoggerPtr m_log;
210 #endif // INCLUDED_Connection_h_GUID_61C65986_E2C9_498F_59F0_8EFC712BA183 OSVR_CONNECTION_EXPORT ConnectionDevicePtr registerAdvancedDevice(std::string const &deviceName, OSVR_DeviceUpdateCallback updateFunction, void *userdata)
Record a full device name (namespaced with the plugin name) associated with a given callback...
Definition: Connection.cpp:107
OSVR_CONNECTION_EXPORT ConnectionDevicePtr createConnectionDevice(std::string const &deviceName)
Create a ConnectionDevice by registering a full device name.
Definition: Connection.cpp:91
OSVR_CONNECTION_EXPORT MessageTypePtr registerMessageType(std::string const &messageId)
Register (or retrieve registration) of a message type.
Definition: Connection.cpp:86
Header forward declaring MessageType and specifying a smart pointer.
OSVR_CONNECTION_EXPORT void registerDescriptorHandler(std::function< void()> handler)
Register a function to be called when a descriptor changes.
Definition: Connection.cpp:155
OSVR_CONNECTION_EXPORT void registerConnectionHandler(std::function< void()> handler)
Register a function to be called when a client connects or pings.
Definition: Connection.cpp:152
Header forward-declaring ConnectionDevice and specifying the desired pointer to hold a ConnectionDevi...
Class responsible for hosting plugins, along with their registration and destruction.
Definition: RegistrationContext.h:53
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
virtual OSVR_CONNECTION_EXPORT void * getUnderlyingObject()
Access implementation details.
Definition: Connection.cpp:170
shared_ptr< Connection > ConnectionPtr
How one must hold a Connection.
Definition: ConnectionPtr.h:40
Class wrapping a messaging transport (server or internal) connection.
Definition: Connection.h:56
virtual void m_process()=0
(Subclass implementation) Process messages.
Header for basic internal log reference.
virtual MessageTypePtr m_registerMessageType(std::string const &messageId)=0
(Subclass implementation) Register (or retrieve registration) of a message type.
Structure used internally to construct the desired type of device.
Definition: DeviceInitObject.h:59
boost::iterator_range< DeviceList::const_iterator > getDevices() const
Get the devices, as a range.
Definition: Connection.h:134
virtual void m_registerConnectionHandler(std::function< void()> handler)=0
(Subclass implementation) Register a function to handle "new connection"/ping messages.
Header declaring device callback types.
static OSVR_CONNECTION_EXPORT void storeConnection(pluginhost::RegistrationContext &ctx, ConnectionPtr conn)
Store a connection pointer in a RegistrationContext.
Definition: Connection.cpp:79
unique_ptr< MessageType > MessageTypePtr
a uniquely-owned handle for holding a message type registration.
Definition: MessageTypePtr.h:42
static OSVR_CONNECTION_EXPORT ConnectionPtr createSharedConnection(boost::optional< std::string const &> iface, boost::optional< int > port)
Factory method to create a shared connection.
Definition: Connection.cpp:53
Connection()
brief Constructor
Definition: Connection.cpp:165
virtual OSVR_CONNECTION_EXPORT const char * getConnectionKindID()
Returns some implementation-defined string based on the dynamic type of the connection.
Definition: Connection.cpp:172
shared_ptr< ConnectionDevice > ConnectionDevicePtr
How to hold on to a ConnectionDevice.
Definition: ConnectionDevicePtr.h:40
OSVR_CONNECTION_EXPORT void process()
Process messages.
Definition: Connection.cpp:143
OSVR_ReturnCode(* OSVR_DeviceUpdateCallback)(void *userData)
Function type of a Device Update callback.
Definition: DeviceCallbackTypesC.h:48
OSVR_CONNECTION_EXPORT void addDevice(ConnectionDevicePtr device)
Add an externally-constructed device to the device list.
Definition: Connection.cpp:129
std::vector< std::string > NameList
Type of list of device names.
Definition: Connection.h:157
OSVR_CONNECTION_EXPORT void triggerDescriptorHandlers()
Signal a descriptor update and call any/all descriptor handlers.
Definition: Connection.cpp:159
virtual OSVR_CONNECTION_EXPORT ~Connection()
Destructor.
Definition: Connection.cpp:168
virtual ConnectionDevicePtr m_createConnectionDevice(DeviceInitObject &init)=0
(Subclass implementation) Register a full device name.
Header forward-declaring RegistrationContext.
Header forward-declaring Connection and specifying the smart pointer to hold a Connection in...