OSVR-Core
Public Member Functions | List of all members
osvr::pluginkit::DeviceToken Class Reference

Wrapper class for OSVR_DeviceToken. More...

#include <DeviceInterface.h>

Public Member Functions

 DeviceToken (OSVR_DeviceToken device)
 Constructor wrapping an existing device token.
 
 DeviceToken ()
 Default constructor.
 
 operator OSVR_DeviceToken () const
 Conversion operator to the un-wrapped device token.
 
void initSync (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_IN_OPT OSVR_DeviceInitOptions options=NULL)
 Initialize this device token as synchronous, with the given name and options. More...
 
void initSync (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN std::string const &name, OSVR_IN_OPT OSVR_DeviceInitOptions options=NULL)
 
void initAsync (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_IN_OPT OSVR_DeviceInitOptions options=NULL)
 Initialize this device token as asynchronous, with the given name and options. More...
 
void initAsync (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN std::string const &name, OSVR_IN_OPT OSVR_DeviceInitOptions options=NULL)
 
template<typename InterfaceType , typename MessageType >
void send (InterfaceType &iface, MessageType const &msg, OSVR_TimeValue const &timestamp)
 Send a message on a registered interface type, providing the timestamp yourself. More...
 
template<typename InterfaceType , typename MessageType >
void send (InterfaceType &iface, MessageType const &msg)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version takes the current time and uses it as the timestamp. More...
 
void sendJsonDescriptor (OSVR_IN_READS(len) const char *json, OSVR_IN size_t len)
 Submit a JSON self-descriptor string for the device. More...
 
template<size_t N>
void sendJsonDescriptor (const char(&json)[N])
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time. More...
 
void sendJsonDescriptor (OSVR_IN std::string const &json)
 
template<typename DeviceObjectType >
void registerUpdateCallback (OSVR_IN_PTR DeviceObjectType *object)
 Given a pointer to your object that has a public OSVR_ReturnCode update() method, registers that instance and method as the update callback for the device. More...
 
Advanced Functionality

Rarely needed

Send a raw bytestream from your device with a custom message type.

Note
The same function is used for synchronous and asynchronous devices: the device token is sufficient to determine whether locking is needed.
Parameters
msgThe registered message type.
bytestreamA string of bytes to transmit.
lenThe length of the string of bytes.
Exceptions
std::runtime_errorif error in sending.
void sendData (OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN_READS(len) const char *bytestream=NULL, OSVR_IN size_t len=0)
 
template<size_t N>
void sendData (OSVR_MessageType msg, const char(&bytestream)[N])
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time. More...
 
void sendData (OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN std::string const &bytestream)
 
void sendData (OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN std::vector< char > const &bytestream)
 
void sendData (OSVR_IN OSVR_TimeValue const &timestamp, OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN_READS(len) const char *bytestream=NULL, OSVR_IN size_t len=0)
 Sends a raw bytestream from your device with a known timestamp. More...
 
template<size_t N>
void sendData (OSVR_IN OSVR_TimeValue const &timestamp, OSVR_MessageType msg, const char(&bytestream)[N])
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time. More...
 
void sendData (OSVR_IN OSVR_TimeValue const &timestamp, OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN std::string const &bytestream)
 
void sendData (OSVR_IN OSVR_TimeValue const &timestamp, OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN std::vector< char > const &bytestream)
 

Detailed Description

Wrapper class for OSVR_DeviceToken.

Member Function Documentation

§ initAsync() [1/2]

void osvr::pluginkit::DeviceToken::initAsync ( OSVR_IN_PTR OSVR_PluginRegContext  ctx,
OSVR_IN_STRZ const char *  name,
OSVR_IN_OPT OSVR_DeviceInitOptions  options = NULL 
)
inline

Initialize this device token as asynchronous, with the given name and options.

§ initAsync() [2/2]

void osvr::pluginkit::DeviceToken::initAsync ( OSVR_IN_PTR OSVR_PluginRegContext  ctx,
OSVR_IN std::string const &  name,
OSVR_IN_OPT OSVR_DeviceInitOptions  options = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ initSync() [1/2]

void osvr::pluginkit::DeviceToken::initSync ( OSVR_IN_PTR OSVR_PluginRegContext  ctx,
OSVR_IN_STRZ const char *  name,
OSVR_IN_OPT OSVR_DeviceInitOptions  options = NULL 
)
inline

Initialize this device token as synchronous, with the given name and options.

§ initSync() [2/2]

void osvr::pluginkit::DeviceToken::initSync ( OSVR_IN_PTR OSVR_PluginRegContext  ctx,
OSVR_IN std::string const &  name,
OSVR_IN_OPT OSVR_DeviceInitOptions  options = NULL 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ registerUpdateCallback()

template<typename DeviceObjectType >
void osvr::pluginkit::DeviceToken::registerUpdateCallback ( OSVR_IN_PTR DeviceObjectType *  object)
inline

Given a pointer to your object that has a public OSVR_ReturnCode update() method, registers that instance and method as the update callback for the device.

Exceptions
std::runtime_errorif update callback registration fails

§ send() [1/2]

template<typename InterfaceType , typename MessageType >
void osvr::pluginkit::DeviceToken::send ( InterfaceType &  iface,
MessageType const &  msg,
OSVR_TimeValue const &  timestamp 
)
inline

Send a message on a registered interface type, providing the timestamp yourself.

Templated to call implementation in the InterfaceType class.

See also
osvr::clientkit::ImagingInterface, osvr::clientkit::ImagingMessage

§ send() [2/2]

template<typename InterfaceType , typename MessageType >
void osvr::pluginkit::DeviceToken::send ( InterfaceType &  iface,
MessageType const &  msg 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version takes the current time and uses it as the timestamp.

§ sendData() [1/7]

template<size_t N>
void osvr::pluginkit::DeviceToken::sendData ( OSVR_MessageType  msg,
const char(&)  bytestream[N] 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time.

§ sendData() [2/7]

void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN_PTR OSVR_MessageType  msg,
OSVR_IN std::string const &  bytestream 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ sendData() [3/7]

void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN_PTR OSVR_MessageType  msg,
OSVR_IN std::vector< char > const &  bytestream 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ sendData() [4/7]

void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN OSVR_TimeValue const &  timestamp,
OSVR_IN_PTR OSVR_MessageType  msg,
OSVR_IN_READS(len) const char *  bytestream = NULL,
OSVR_IN size_t  len = 0 
)
inline

Sends a raw bytestream from your device with a known timestamp.

Note
The same function is used for synchronous and asynchronous devices: the device token is sufficient to determine whether locking is needed.
Parameters
timestampThe timestamp you want to associate with this message.
msgThe registered message type.
bytestreamA string of bytes to transmit.
lenThe length of the string of bytes.
Exceptions
std::runtime_errorif error in sending.

§ sendData() [5/7]

template<size_t N>
void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN OSVR_TimeValue const &  timestamp,
OSVR_MessageType  msg,
const char(&)  bytestream[N] 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time.

§ sendData() [6/7]

void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN OSVR_TimeValue const &  timestamp,
OSVR_IN_PTR OSVR_MessageType  msg,
OSVR_IN std::string const &  bytestream 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ sendData() [7/7]

void osvr::pluginkit::DeviceToken::sendData ( OSVR_IN OSVR_TimeValue const &  timestamp,
OSVR_IN_PTR OSVR_MessageType  msg,
OSVR_IN std::vector< char > const &  bytestream 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ sendJsonDescriptor() [1/3]

void osvr::pluginkit::DeviceToken::sendJsonDescriptor ( OSVR_IN_READS(len) const char *  json,
OSVR_IN size_t  len 
)
inline

Submit a JSON self-descriptor string for the device.

Parameters
jsonThe JSON string to transmit.
lenThe length of the string.
Exceptions
std::runtime_errorif error in sending.

§ sendJsonDescriptor() [2/3]

template<size_t N>
void osvr::pluginkit::DeviceToken::sendJsonDescriptor ( const char(&)  json[N])
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.For string literals: automatically deduces the length at compile time.

§ sendJsonDescriptor() [3/3]

void osvr::pluginkit::DeviceToken::sendJsonDescriptor ( OSVR_IN std::string const &  json)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


The documentation for this class was generated from the following file: