OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osvr::pluginkit::DeviceToken Class Reference

Wrapper class for OSVR_DeviceToken. More...

#include <osvr/PluginKit/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_PluginRegContext ctx, const char *name, OSVR_DeviceInitOptions options=NULL)
 Initialize this device token as synchronous, with the given name and options.
 
void initSync (OSVR_PluginRegContext ctx, std::string const &name, OSVR_DeviceInitOptions options=NULL)
 
void initAsync (OSVR_PluginRegContext ctx, const char *name, OSVR_DeviceInitOptions options=NULL)
 Initialize this device token as asynchronous, with the given name and options.
 
void initAsync (OSVR_PluginRegContext ctx, std::string const &name, 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)
 
void sendJsonDescriptor (const char *json, size_t len)
 Submit a JSON self-descriptor string for the device. More...
 
template<size_t N>
void sendJsonDescriptor (const char(&json)[N])
 
void sendJsonDescriptor (std::string const &json)
 
template<typename DeviceObjectType >
void registerUpdateCallback (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_MessageType msg, const char *bytestream=NULL, size_t len=0)
 
template<size_t N>
void sendData (OSVR_MessageType msg, const char(&bytestream)[N])
 
void sendData (OSVR_MessageType msg, std::string const &bytestream)
 
void sendData (OSVR_MessageType msg, std::vector< char > const &bytestream)
 
void sendData (OSVR_TimeValue const &timestamp, OSVR_MessageType msg, const char *bytestream=NULL, size_t len=0)
 Sends a raw bytestream from your device with a known timestamp. More...
 
template<size_t N>
void sendData (OSVR_TimeValue const &timestamp, OSVR_MessageType msg, const char(&bytestream)[N])
 
void sendData (OSVR_TimeValue const &timestamp, OSVR_MessageType msg, std::string const &bytestream)
 
void sendData (OSVR_TimeValue const &timestamp, OSVR_MessageType msg, std::vector< char > const &bytestream)
 

Detailed Description

Wrapper class for OSVR_DeviceToken.

Definition at line 93 of file DeviceInterface.h.

Member Function Documentation

void osvr::pluginkit::DeviceToken::initSync ( OSVR_PluginRegContext  ctx,
std::string const &  name,
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.

Definition at line 125 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::initAsync ( OSVR_PluginRegContext  ctx,
std::string const &  name,
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.

Definition at line 154 of file DeviceInterface.h.

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

Definition at line 172 of file DeviceInterface.h.

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.

Definition at line 180 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendJsonDescriptor ( const char *  json,
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.

Definition at line 190 of file DeviceInterface.h.

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.

Definition at line 204 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendJsonDescriptor ( 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.

Definition at line 209 of file DeviceInterface.h.

template<typename DeviceObjectType >
void osvr::pluginkit::DeviceToken::registerUpdateCallback ( 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

Definition at line 223 of file DeviceInterface.h.

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.

Definition at line 267 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendData ( OSVR_MessageType  msg,
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.

Definition at line 272 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendData ( OSVR_MessageType  msg,
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.

Definition at line 282 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendData ( OSVR_TimeValue const &  timestamp,
OSVR_MessageType  msg,
const char *  bytestream = NULL,
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.

Definition at line 305 of file DeviceInterface.h.

template<size_t N>
void osvr::pluginkit::DeviceToken::sendData ( 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.

Definition at line 321 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendData ( OSVR_TimeValue const &  timestamp,
OSVR_MessageType  msg,
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.

Definition at line 327 of file DeviceInterface.h.

void osvr::pluginkit::DeviceToken::sendData ( OSVR_TimeValue const &  timestamp,
OSVR_MessageType  msg,
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.

Definition at line 339 of file DeviceInterface.h.


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