25 #ifndef INCLUDED_DeviceInitObject_h_GUID_6B7D1689_CE30_4A9F_4B59_36773D1F0064 26 #define INCLUDED_DeviceInitObject_h_GUID_6B7D1689_CE30_4A9F_4B59_36773D1F0064 35 #include <osvr/Connection/Export.h> 42 #include <boost/noncopyable.hpp> 43 #include <boost/optional.hpp> 47 #include <type_traits> 51 namespace connection {
52 class AnalogServerInterface;
53 class ButtonServerInterface;
54 class TrackerServerInterface;
63 OSVR_CONNECTION_EXPORT
explicit OSVR_DeviceInitObject(
67 OSVR_CONNECTION_EXPORT
void setName(std::string
const &n);
70 OSVR_CONNECTION_EXPORT
void 78 OSVR_CONNECTION_EXPORT
void 86 OSVR_CONNECTION_EXPORT
void 91 OSVR_CONNECTION_EXPORT
void 92 addServerInterface(osvr::connection::ServerInterfacePtr
const &iface);
96 OSVR_CONNECTION_EXPORT
void 97 addComponent(osvr::common::DeviceComponentPtr
const &comp);
103 std::is_base_of<osvr::connection::DeviceInterfaceBase, T>::value,
104 "Your interface object must derive from " 105 "DeviceInterfaceBase to use this handy wrapper!");
106 auto ifaceObj = getContext()->registerDataWithGenericDelete(
new T);
107 addTokenInterest(ifaceObj);
114 if (
nullptr != devPtr) {
115 m_tokenInterest.push_back(devPtr);
119 if (
nullptr != ifaceObj) {
120 m_deviceInterfaces.push_back(ifaceObj);
126 for (
auto interest : m_tokenInterest) {
129 for (
auto ifaceObj : m_deviceInterfaces) {
130 ifaceObj->setDeviceToken(*dev);
139 std::string getQualifiedName()
const;
148 boost::optional<OSVR_ChannelCount> getAnalogs()
const {
return m_analogs; }
149 boost::optional<OSVR_ChannelCount> getButtons()
const {
return m_buttons; }
150 bool getTracker()
const {
return m_tracker; }
151 osvr::connection::ServerInterfaceList
const &getServerInterfaces()
const {
152 return m_serverInterfaces;
155 osvr::common::DeviceComponentList
const &getComponents()
const {
163 std::string m_qualifiedName;
164 boost::optional<OSVR_ChannelCount> m_analogs;
166 boost::optional<OSVR_ChannelCount> m_buttons;
170 osvr::connection::ServerInterfaceList m_serverInterfaces;
171 osvr::common::DeviceComponentList m_components;
172 std::vector<OSVR_DeviceTokenObject **> m_tokenInterest;
174 std::vector<osvr::connection::DeviceInterfaceBase *> m_deviceInterfaces;
177 #endif // INCLUDED_DeviceInitObject_h_GUID_6B7D1689_CE30_4A9F_4B59_36773D1F0064 T * makeInterfaceObject()
A helper method to make a "device interface object" of user-designated type and apppropriate lifetime...
Definition: DeviceInitObject.h:101
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
void addTokenInterest(OSVR_DeviceTokenObject **devPtr)
Add an observer that we'll eventually inform about the device token.
Definition: DeviceInitObject.h:113
A DeviceToken connects the generic device interaction code in PluginKit's C API with the workings of ...
Definition: DeviceToken.h:56
Interface for external access to generating tracker reports.
Definition: TrackerServerInterface.h:46
Header wrapping the C99 standard stdint header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Class providing the external interface of a registration context backing a single plugin...
Definition: PluginSpecificRegistrationContext.h:52
shared_ptr< Connection > ConnectionPtr
How one must hold a Connection.
Definition: ConnectionPtr.h:40
Header to bring unique_ptr into the osvr namespace.
Structure used internally to construct the desired type of device.
Definition: DeviceInitObject.h:59
Interface for external access to generating analog reports.
Definition: AnalogServerInterface.h:45
void notifyToken(OSVR_DeviceTokenObject *dev)
Notify all those interested what the device token is.
Definition: DeviceInitObject.h:125
Header declaring the opaque plugin registration context type.
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin's entry point and other locations of control flow transfer...
Definition: PluginRegContextC.h:47
Base class for the DeviceInterfaceObjects retrieved by plugins to let them send data on an interface...
Definition: DeviceInterfaceBase.h:43
Header forward-declaring Connection and specifying the smart pointer to hold a Connection in...