25 #ifndef INCLUDED_Connection_h_GUID_61C65986_E2C9_498F_59F0_8EFC712BA183
26 #define INCLUDED_Connection_h_GUID_61C65986_E2C9_498F_59F0_8EFC712BA183
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
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...
ConnectionDevicePtr createConnectionDevice(std::string const &deviceName)
Create a ConnectionDevice by registering a full device name. This should be namespaced with the plugi...
MessageTypePtr registerMessageType(std::string const &messageId)
Register (or retrieve registration) of a message type.
Header forward declaring MessageType and specifying a smart pointer.
void registerDescriptorHandler(std::function< void()> handler)
Register a function to be called when a descriptor changes.
void registerConnectionHandler(std::function< void()> handler)
Register a function to be called when a client connects or pings.
Header forward-declaring ConnectionDevice and specifying the desired pointer to hold a ConnectionDevi...
Class responsible for hosting plugins, along with their registration and destruction.
Automatically-generated export header - do not edit!
static ConnectionPtr createSharedConnection(boost::optional< std::string const & > iface, boost::optional< int > port)
Factory method to create a shared connection.
virtual void * getUnderlyingObject()
Access implementation details.
shared_ptr< Connection > ConnectionPtr
How one must hold a Connection.
Class wrapping a messaging transport (server or internal) connection.
virtual void m_process()=0
(Subclass implementation) Process messages. This shouldn't block.
Header for basic internal log reference. To actually log to the produced loggers, include
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.
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 void storeConnection(pluginhost::RegistrationContext &ctx, ConnectionPtr conn)
Store a connection pointer in a RegistrationContext.
unique_ptr< MessageType > MessageTypePtr
a uniquely-owned handle for holding a message type registration.
Connection()
brief Constructor
virtual const char * getConnectionKindID()
Returns some implementation-defined string based on the dynamic type of the connection.
shared_ptr< ConnectionDevice > ConnectionDevicePtr
How to hold on to a ConnectionDevice.
void process()
Process messages. This shouldn't block.
void addDevice(ConnectionDevicePtr device)
Add an externally-constructed device to the device list.
std::vector< std::string > NameList
Type of list of device names.
void triggerDescriptorHandlers()
Signal a descriptor update and call any/all descriptor handlers.
boost::iterator_range< DeviceList::const_iterator > getDevices() const
Get the devices, as a range.
virtual ~Connection()
Destructor.
OSVR_ReturnCode(* OSVR_DeviceUpdateCallback)(void *userData)
Function type of a Device Update callback.
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...