OSVR-Core
|
A DeviceToken connects the generic device interaction code in PluginKit's C API with the workings of an actual ConnectionDevice. More...
#include <DeviceToken.h>
Public Types | |
using | EventFunction = std::function< void()> |
Public Member Functions | |
virtual | ~OSVR_DeviceTokenObject () |
Destructor. | |
OSVR_CONNECTION_EXPORT std::string const & | getName () const |
Accessor for name property. | |
OSVR_CONNECTION_EXPORT void | setUpdateCallback (osvr::connection::DeviceUpdateCallback const &cb) |
Sets the update/wait callback. | |
OSVR_CONNECTION_EXPORT void | setPreConnectionInteract (EventFunction const &f) |
Sets a function to be executed at the beginning of connectionInteract() | |
OSVR_CONNECTION_EXPORT void | sendData (osvr::connection::MessageType *type, const char *bytestream, size_t len) |
Send data. More... | |
OSVR_CONNECTION_EXPORT void | sendData (osvr::util::time::TimeValue const ×tamp, osvr::connection::MessageType *type, const char *bytestream, size_t len) |
Send data. More... | |
OSVR_CONNECTION_EXPORT osvr::util::GuardPtr | getSendGuard () |
void | connectionInteract () |
Interact with connection. More... | |
void | stopThreads () |
Stop any threads spawned and owned by this DeviceToken. | |
OSVR_CONNECTION_EXPORT void | setDeviceDescriptor (std::string const &jsonString) |
Send a new or updated device descriptor for this device. | |
template<typename T > | |
void * | acquireObject (T obj) |
Pass (smart-pointer) ownership of some object to the client context. More... | |
OSVR_CONNECTION_EXPORT bool | releaseObject (void *obj) |
Frees some object whose lifetime is controlled by the client context. More... | |
Static Public Member Functions | |
Factory functions | |
Creates a device token (and underlying ConnectionDevice) that has a wait callback that can block, that is called repeatedly in a thread of its own (managed by OSVR) | |
static OSVR_CONNECTION_EXPORT osvr::connection::DeviceTokenPtr | createAsyncDevice (osvr::connection::DeviceInitObject &init) |
static OSVR_CONNECTION_EXPORT osvr::connection::DeviceTokenPtr | createSyncDevice (osvr::connection::DeviceInitObject &init) |
Creates a device token (and underlying ConnectionDevice) that has an update method that runs in the server mainloop. More... | |
static OSVR_CONNECTION_EXPORT osvr::connection::DeviceTokenPtr | createVirtualDevice (std::string const &name, osvr::connection::ConnectionPtr const &conn) |
Creates a device token (and underlying ConnectionDevice) without a traditional, built-in update method - typically for server-internal usage. More... | |
Protected Member Functions | |
OSVR_DeviceTokenObject (std::string const &name) | |
osvr::connection::ConnectionPtr | m_getConnection () |
osvr::connection::ConnectionDevicePtr | m_getConnectionDevice () |
virtual void | m_setUpdateCallback (osvr::connection::DeviceUpdateCallback const &cb)=0 |
virtual void | m_sendData (osvr::util::time::TimeValue const ×tamp, osvr::connection::MessageType *type, const char *bytestream, size_t len)=0 |
virtual osvr::util::GuardPtr | m_getSendGuard ()=0 |
virtual void | m_connectionInteract ()=0 |
virtual void | m_stopThreads () |
A DeviceToken connects the generic device interaction code in PluginKit's C API with the workings of an actual ConnectionDevice.
|
inline |
Pass (smart-pointer) ownership of some object to the client context.
void OSVR_DeviceTokenObject::connectionInteract | ( | ) |
Interact with connection.
Only legal to end up in ConnectionDevice::sendData from within here somehow.
|
static |
Creates a device token (and underlying ConnectionDevice) that has an update method that runs in the server mainloop.
|
static |
Creates a device token (and underlying ConnectionDevice) without a traditional, built-in update method - typically for server-internal usage.
bool OSVR_DeviceTokenObject::releaseObject | ( | void * | obj | ) |
Frees some object whose lifetime is controlled by the client context.
OSVR_CONNECTION_EXPORT void OSVR_DeviceTokenObject::sendData | ( | osvr::connection::MessageType * | type, |
const char * | bytestream, | ||
size_t | len | ||
) |
Send data.
The timestamp for the data is assumed to be at the time this call is placed.
This may block until the next connectionInteract call before forwarding on to ConnectionDevice::sendData, depending on the type of device token.
OSVR_CONNECTION_EXPORT void OSVR_DeviceTokenObject::sendData | ( | osvr::util::time::TimeValue const & | timestamp, |
osvr::connection::MessageType * | type, | ||
const char * | bytestream, | ||
size_t | len | ||
) |
Send data.
This may block until the next connectionInteract call before forwarding on to ConnectionDevice::sendData, depending on the type of device token.