OSVR-Core
Namespaces | Classes | Typedefs | Enumerations | Functions
osvr::common Namespace Reference

Handles spatial transformations. More...

Namespaces

 class_of_service
 Contains tag types for requesting different classes of service from the networking-based underlying transport (VRPN)
 
 elements
 Namespace for the various element types that may constitute a node in the path tree.
 
 exceptions
 Exceptions that may be thrown from this module.
 
 traits
 Type traits and metaprogramming supports related to specially-handled reports.
 

Classes

struct  ActualBufferAlignment
 Traits class describing actual alignment of Buffer. More...
 
class  AliasProcessor
 A short-lived class for setting up options then processing alias directives to apply to a path tree. More...
 
class  BaseDevice
 Class used as an interface for underlying devices that can have device components (corresponding to interface classes) More...
 
class  Buffer
 A buffer of bytes, built on a byte-vector-like container. More...
 
class  BufferReader
 Provides for a single reading pass over a buffer. More...
 
struct  CallbackStorage
 Trait computing the storage for callbacks for a report type. More...
 
class  ChangeOfBasis
 
class  CommonComponent
 BaseDevice component, for the VRPN built-in common messages. More...
 
class  ConnectionWrapper
 
class  CorrelatedStringMap
 This is like a RegisteredStringMap, except it also knows that some peer also has a string map, likely with some of the same strings, but with different ids. More...
 
class  DeduplicatingFunctionWrapper
 A wrapper for a unary function that only calls its contained function when the input has changed. More...
 
struct  DesiredBufferAlignment
 Traits class specifying the (potentially platform-specific!) preferred alignment for Buffer. More...
 
class  DeviceComponent
 
class  DeviceWrapper
 Base class used to implement BaseDevice/DeviceComponent-based devices on top of VRPN. More...
 
class  DirectionComponent
 BaseDevice component. More...
 
struct  DirectionData
 
class  ExternalBufferReadingWrapper
 Class wrapping an externally-owned and controlled buffer with the vector-like functionality needed to read from it. More...
 
class  EyeTrackerComponent
 BaseDevice component. More...
 
class  GeneralizedTransform
 Container for easy manipulation of nested transforms. More...
 
struct  ImageData
 
class  ImagingComponent
 BaseDevice component. More...
 
class  ImpliedSenderMessageHandleTraits
 A class template for the common message traits where the registrar is passed by pointer, has registerHandler and unregisterHandler methods, and doesn't take a RawSenderType because it's implied. More...
 
class  InterfaceCallbacks
 Class to maintain callbacks for an interface for each report type explicitly enumerated. More...
 
class  InterfaceState
 Class to maintain state for an interface for each report (and thus state) type explicitly enumerated. More...
 
class  IPCRingBuffer
 A ring buffer for interprocess communication, with managed occupancy. More...
 
struct  is_buffer
 Type trait: is the given type a buffer? More...
 
struct  is_buffer_reader
 Type trait: is the given type a buffer reader? More...
 
class  JSONTransformVisitor
 
class  Location2DComponent
 BaseDevice component. More...
 
struct  LocationData
 
class  LocomotionComponent
 BaseDevice component. More...
 
class  LowLatency
 An object that sets a system for low-latency, but potentially high-CPU-usage, high power, and even lower-performance due to scheduling (see the cautions about timeBeginPeriod). More...
 
class  MessageHandler
 RAII class template managing a message handler callback. More...
 
class  MessageHandlerBase
 
class  MessageRegistration
 CRTP class template wrapping message-specific data and/or logic. More...
 
struct  NaviPositionData
 
struct  NaviVelocityData
 
class  NetworkingSupport
 RAII class wrapping networking system startup. More...
 
class  OriginalSource
 The result of resolving a tree node to a device: either an original source to connect to, or nothing. More...
 
struct  OSVR_EyeNotification
 
class  ParsedAlias
 
class  ParsedArticulation
 
class  PathTree
 A tree representation, with path/url syntax, of the known OSVR system. More...
 
class  PathTreeObserver
 
class  PathTreeOwner
 Object responsible for owning a path tree (specifically a "downstream"/client path tree), replacing its contents from JSON-serialized data, and notifying a collection of observers of such events. More...
 
class  RawMessageType
 Type-safe wrapper with built-in default for a VRPN "message type" integer. More...
 
class  RawSenderType
 Type-safe wrapper with built-in default for a VRPN "sender type" integer. More...
 
class  RegisteredStringMap
 Centralize a string registry. More...
 
class  RouteContainer
 
class  SkeletonComponent
 BaseDevice component. More...
 
struct  SkeletonNotification
 
struct  SkeletonSpec
 
struct  StateMapContents
 A templated type containing state and a timestamp for known, specialized report types. More...
 
class  SystemComponent
 BaseDevice component, to be used only with the "OSVR" special device. More...
 
struct  TrackerSensorInfo
 fully-resolved data about a tracker sensor. Defaults per the schema. More...
 
class  Transform
 Spatial transformation, consisting of both pre and post components. More...
 
class  TreeResolutionVisitor
 
struct  YourComplicatedType
 Dummy example for your type. More...
 
struct  YourSimpleType
 

Typedefs

typedef shared_ptr< BaseDeviceBaseDevicePtr
 
typedef ImpliedSenderMessageHandleTraits< vrpn_MESSAGEHANDLER, BaseDeviceBaseDeviceMessageHandleTraits
 Traits class for use with MessageHandler.
 
typedef char BufferElement
 The single-byte element in a buffer.
 
typedef std::allocator< BufferElementBufferAllocator
 Allocator type for Buffer - might be usefully aligned.
 
typedef std::vector< BufferElement, BufferAllocatorBufferByteVector
 A typedef for a vector of bytes usable as a buffer, that might be "over-aligned" in some desirable way. More...
 
template<typename T = ClientContext>
using ClientContextUniquePtr = unique_ptr< T, ClientContextDeleter >
 Template alias for a ClientContext unique_ptr with the correct deleter class. More...
 
using ClientContextSharedPtr = shared_ptr< ClientContext >
 
typedef ::OSVR_ClientContextObject ClientContext
 
typedef void(* ClientContextDeleter) (ClientContext *)
 
using ClientInterfaceFactory = std::function< ClientInterfacePtr(ClientContext &, const char[])>
 A factory function type taking the client context and path, and returning a ClientInterfacePtr. More...
 
typedef ::OSVR_ClientInterfaceObject ClientInterface
 
typedef shared_ptr< ClientInterfaceClientInterfacePtr
 Pointer for holding ClientInterface objects safely.
 
typedef weak_ptr< ClientInterfaceClientInterfaceWeakPtr
 Pointer for observing ClientInterface objects safely and weakly.
 
typedef shared_ptr< DeviceComponentDeviceComponentPtr
 
typedef std::vector< DeviceComponentPtr > DeviceComponentList
 
typedef shared_ptr< OSVR_ImageBufferElementImageBufferPtr
 
using CallbackTuple = typepack::TypeKeyedTuple< traits::ReportTypeList, CallbackStorage >
 
typedef std::vector< ClientInterfacePtrInterfaceList
 
template<typename ReportType >
using StateMapValueType = boost::optional< StateMapContents< ReportType >>
 Alias taking a report type and returning a state map value type. More...
 
using StateMap = typepack::TypeKeyedTuple< traits::ReportTypeList, typepack::quote< StateMapValueType >>
 Data structure mapping from a report type to an optional state value. More...
 
typedef shared_ptr< IPCRingBufferIPCRingBufferPtr
 Pointer type for holding a shared memory ring buffer.
 
template<typename MessageTraits >
using MessageHandlerPtr = shared_ptr< MessageHandler< MessageTraits > >
 
template<typename MessageTraits >
using MessageHandlerList = std::vector< MessageHandlerPtr< MessageTraits > >
 
typedef std::vector< shared_ptr< MessageHandlerBase > > GenericMessageHandlerList
 
typedef uint8_t AliasPriority
 
typedef ::osvr::util::TreeNode< PathElement > PathNode
 The specific tree node type that contains a path element.
 
typedef ::osvr::util::TreeNodePointer< PathElement >::type PathNodePtr
 The ownership pointer of the specific tree node.
 
typedef PathNodePathNodeParentPtr
 The weak (non-owning) pointer used to refer to a parent tree node.
 
typedef shared_ptr< PathTreeObserverPathTreeObserverPtr
 
typedef weak_ptr< PathTreeObserverPathTreeObserverWeakPtr
 
typedef shared_ptr< SkeletonComponentSkeletonComponentPtr
 

Enumerations

enum  PathTreeEvents : std::size_t { AboutToUpdate, AfterUpdate }
 

Functions

OSVR_COMMON_EXPORT PathNodeaddDevice (PathTree &tree, std::string const &deviceName, elements::DeviceElement dev=elements::DeviceElement())
 Adds/updates nodes for the basic path to a device. More...
 
OSVR_COMMON_EXPORT Json::Value convertRouteToAlias (Json::Value const &val)
 Given a single JSON object, if it's an old-fashioned "routing directive", convert it to a normal "alias". More...
 
OSVR_COMMON_EXPORT Json::Value createJSONAlias (std::string const &path, Json::Value const &destination)
 Given a path and a destination, combine them into a JSON alias description. More...
 
OSVR_COMMON_EXPORT Json::Value applyPriorityToAlias (Json::Value const &alias, AliasPriority priority)
 Given a JSON object describing one or more aliases, set the priority of the alias(es). More...
 
size_t computeAlignmentPadding (size_t alignment, size_t currentSize)
 Given an alignment in bytes, and a current size of a buffer, return the number of bytes of padding required to align the next field to be added to the buffer at the desired alignment within that buffer. More...
 
template<typename Visitor >
Visitor::result_type applyPathNodeVisitor (Visitor &v, PathNode &node)
 Visit a node's element's contained type, similar to boost::apply_visitor, but passing both the PathNode and the PathElement type. More...
 
template<typename Visitor >
Visitor::result_type applyPathNodeVisitor (Visitor &v, PathNode const &node)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. const version.
 
template<typename CharType >
BufferReader< ExternalBufferReadingWrapper< CharType > > readExternalBuffer (const CharType *buf, size_t len)
 Constructs and returns a buffer reader for an externally-allocated buffer: it's on you to supply a valid pointer and length. More...
 
OSVR_COMMON_EXPORT void deleteContext (ClientContext *ctx)
 Use the stored deleter to appropriately delete the client context. More...
 
template<typename T , typename... Args>
TmakeContext (Args... args)
 Create a subclass object of ClientContext, setting the deleter appropriately by passing it as the last parameter. More...
 
template<typename T >
ClientContextSharedPtr wrapSharedContext (T *context)
 Wrap a client context pointer in a shared pointer with the correct custom deleter. More...
 
ClientInterfaceFactory getStandardClientInterfaceFactory ()
 Returns a client interface factory suitable for standard client use. More...
 
OSVR_COMMON_EXPORT BaseDevicePtr createClientDevice (std::string const &name, vrpn_ConnectionPtr const &conn)
 Factory function for a bare client device with no components/interfaces registered by default.
 
OSVR_COMMON_EXPORT BaseDevicePtr createServerDevice (std::string const &name, vrpn_ConnectionPtr const &conn)
 Factory function for a bare server device with no components/interfaces registered by default.
 
double degreesToRadians (double degrees)
 
double radiansToDegrees (double radians)
 
template<typename UnaryPredicate >
void remove_if (GeneralizedTransform &transform, UnaryPredicate pred)
 Remove levels from a generalized transform as dictated by an arbitrary predicate. More...
 
template<typename Type >
Type integerByteSwap (Type const v)
 Swap the order of bytes of an arbitrary integer type.
 
template<typename Derived >
Json::Value toJson (Eigen::QuaternionBase< Derived > const &quat)
 Converts quaternions to JSON objects.
 
template<typename Derived >
Json::Value toJson (Eigen::MatrixBase< Derived > const &vec)
 Converts vectors to JSON arrays.
 
Eigen::Quaterniond quatFromJson (Json::Value const &json)
 
Eigen::Vector3d vec3FromJson (Json::Value const &json)
 
Json::Value jsonParse (std::string const &str)
 Parses a string as JSON, returning a null value if parsing fails.
 
std::string jsonToCompactString (Json::Value const &val)
 Turns the JSON value into a compact string representation.
 
std::string jsonToStyledString (Json::Value const &val)
 Turns the JSON value into a pretty-printed, human-targeted string representation. More...
 
Json::Value toJson (OSVR_TimeValue const &ts)
 
OSVR_TimeValue timevalueFromJson (Json::Value const &val)
 
OSVR_COMMON_EXPORT std::string normalizeDeviceDescriptor (std::string const &jsonDescriptor)
 "Normalizes" a device descriptor by parsing it and adding implied interfaces to the existing device descriptor before serializing it back out to a string. More...
 
detail::AliasPriorityWrapper outputPriority (AliasPriority priority)
 Helper method to output a priority in a formatted way to a stream. More...
 
OSVR_COMMON_EXPORT std::string getFullPath (PathNode const &node)
 Gets the absolute path for the given node.
 
OSVR_COMMON_EXPORT const char * getTypeName (PathNode const &node)
 Gets an identifying string for the node value type.
 
bool addAliasFromSourceAndRelativeDest (PathNode &node, std::string const &source, std::string const &dest, AliasPriority priority=ALIASPRIORITY_MANUAL)
 
bool addArticulation (PathNode &node, std::string const &source, std::string const &dest)
 
bool isPathAbsolute (std::string const &source)
 
OSVR_COMMON_EXPORT Json::Value pathNodeToJson (PathNode const &node)
 Serialize a path node to a JSON object.
 
OSVR_COMMON_EXPORT Json::Value pathTreeToJson (PathTree const &tree, bool keepNulls=false)
 Serialize a path tree to a JSON array of objects, one for each node.
 
OSVR_COMMON_EXPORT void jsonToPathTree (PathTree &tree, Json::Value nodes)
 Deserialize a path tree from a JSON array of objects.
 
void processArticulationSpec (PathNode &devNode, Json::Value const &desc)
 Set up a path tree based on articulationSpec.
 
OSVR_COMMON_EXPORT void processArticulationSpecForPathTree (PathTree &tree, std::string const &deviceName, Json::Value const &articSpec)
 
OSVR_COMMON_EXPORT bool processDeviceDescriptorForPathTree (PathTree &tree, std::string const &deviceName, std::string const &jsonDescriptor, int listenPort, std::string const &host)
 Set up a path tree based on a device descriptor. More...
 
OSVR_COMMON_EXPORT bool processDeviceDescriptorFromExistingDevice (PathNode &devNode, elements::DeviceElement const &devElt)
 Set up a path tree based on a device descriptor from an existing DeviceElement node. More...
 
template<typename ReportType >
traits::StateType< ReportType >::type const & reportState (ReportType const &r)
 Generic const accessor for the "state" member of a report.
 
template<typename ReportType >
traits::StateType< ReportType >::type & reportState (ReportType &r)
 Generic accessor for the "state" member of a report.
 
OSVR_COMMON_EXPORT std::vector< std::string > resolveFullTree (PathTree &tree)
 Traverse the given path tree, resolving all aliases found to fully populate any generated sensor targets. More...
 
OSVR_COMMON_EXPORT boost::optional< OriginalSourceresolveTreeNode (PathTree &pathTree, std::string const &path)
 
template<typename BufferType , typename MessageClass >
void serialize (BufferType &buf, MessageClass &msg)
 Serializes a message into a buffer, using a MessageClass More...
 
template<typename BufferReaderType , typename MessageClass >
void deserialize (BufferReaderType &reader, MessageClass &msg)
 Deserializes a message from a buffer, using a MessageClass More...
 
TrackerSensorInfo getTrackerSensorInfo (OriginalSource const &source)
 Given a fully-parsed tracker source, determines what messages and subsets thereof it reports. More...
 
template<typename T >
Eigen::Matrix4d rotate (double degrees, T const &axis)
 
std::string getJSONStringAtNode (PathNode const &node)
 
std::string getJSONStringFromTree (PathTree const &tree, std::string const &path)
 
template<typename T = Eigen::Vector3d>
T vectorFromJson (Json::Value const &v)
 
void mergeIdenticalInterfaces (Json::Value &existingIface, Json::Value &newIface, std::string const &detail)
 
void appendCurrentIface (Json::Value &augInterface, Json::Value &currInterface)
 appends json value for a given string More...
 
void normalizeForEyeTracker (Json::Value &descriptor, std::string const &ifaceName)
 For eyetracker, it will add the following interfaces to the descriptor provided that they are set to true: OSVR_Direction, OSVR_Location2D, OSVR_Tracker, OSVR_Button.
 
template<typename T >
boost::optional< TgetSensorNumberHelper (OriginalSource const &self)
 
std::string getPathFromOldRouteSource (Json::Value obj)
 Helper, converts old-style tracker source into normal. More...
 
template<typename T >
Json::Value pathElementToJson (T const &element)
 Returns a JSON object with any element-type-specific data for the given PathElement-holdable type.
 
elements::PathElement jsonToPathElement (Json::Value const &json)
 
template<typename ValueType >
util::TreeNode< ValueType > & treePathRetrieve (util::TreeNode< ValueType > &node, std::string path, bool permitParent=false)
 Internal method for parsing a path and getting or creating the nodes along it. More...
 
template<typename ValueType >
util::TreeNode< ValueType > const & treePathRetrieve (util::TreeNode< ValueType > const &node, std::string path, bool permitParent=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version works with const trees, and does not create missing children: instead it throws util::tree::NoSuchChild. More...
 
template<typename ValueType >
util::TreeNode< ValueType > & pathParseAndRetrieve (util::TreeNode< ValueType > &root, std::string const &path)
 Internal method for parsing a path and getting or creating the nodes along it. More...
 
template<typename ValueType >
util::TreeNode< ValueType > const & pathParseAndRetrieve (util::TreeNode< ValueType > const &root, std::string const &path)
 
bool addAlias (PathNode &node, std::string const &source, AliasPriority priority)
 
bool addAliasFromRoute (PathNode &node, std::string const &route, AliasPriority priority)
 
void clonePathTree (PathTree const &src, PathTree &dest)
 
template<typename T , typename F >
void for_each_cleanup_pointers (T &c, F &&f)
 Given a container of weak ptrs to some type and a functor that operates on references to that type, go through all elements of the container in a single pass, calling the functor on those elements still valid, and removing those invalid ones. More...
 
bool isNodeAnAlias (PathNode const &node)
 
void ifNullTryInferFromParent (common::PathNode &node)
 Given a node, if it's null, try to infer from the parent what it should be. More...
 
void resolveTreeNodeImpl (PathTree &pathTree, std::string const &path, OriginalSource &source)
 
Constants

Gets the path separator character - a slash.

OSVR_COMMON_EXPORT char getPathSeparatorCharacter ()
 
OSVR_COMMON_EXPORT const char * getPathSeparator ()
 Gets the path separator - a slash - as a null-terminated string. More...
 

Detailed Description

Handles spatial transformations.

Typedef Documentation

§ BufferByteVector

A typedef for a vector of bytes usable as a buffer, that might be "over-aligned" in some desirable way.

Check ActualBufferAlignment::value to see if it is actually aligned.

§ ClientContextUniquePtr

template<typename T = ClientContext>
using osvr::common::ClientContextUniquePtr = typedef unique_ptr<T, ClientContextDeleter>

Template alias for a ClientContext unique_ptr with the correct deleter class.

§ ClientInterfaceFactory

using osvr::common::ClientInterfaceFactory = typedef std::function<ClientInterfacePtr(ClientContext &, const char[])>

A factory function type taking the client context and path, and returning a ClientInterfacePtr.

The ClientContext will handle notifying its internals about the new interface before returning it.

§ StateMap

Data structure mapping from a report type to an optional state value.

§ StateMapValueType

template<typename ReportType >
using osvr::common::StateMapValueType = typedef boost::optional<StateMapContents<ReportType>>

Alias taking a report type and returning a state map value type.

Function Documentation

§ addAlias()

bool osvr::common::addAlias ( PathNode node,
std::string const &  source,
AliasPriority  priority 
)
Todo:
signify invalid route in some other way?
Todo:
signify not to pass relative paths here in some other way?

§ addAliasFromSourceAndRelativeDest()

bool osvr::common::addAliasFromSourceAndRelativeDest ( PathNode node,
std::string const &  source,
std::string const &  dest,
AliasPriority  priority = ALIASPRIORITY_MANUAL 
)
Todo:
signify invalid route in some other way?
Todo:
signify invalid route in some other way?

§ addArticulation()

bool osvr::common::addArticulation ( PathNode node,
std::string const &  source,
std::string const &  dest 
)
Todo:
signify invalid route in some other way?
Todo:
signify invalid route in some other way?

§ addDevice()

PathNode & osvr::common::addDevice ( PathTree tree,
std::string const &  deviceName,
elements::DeviceElement  dev = elements::DeviceElement() 
)

Adds/updates nodes for the basic path to a device.

Parameters
treeYour path tree.
deviceNameA namespaced device name coming from a plugin, like /com_osvr_plugin/SampleDevice. If a leading slash is missing, it will be assumed and added.

Multiple levels are acceptable: for example, /com_osvr_plugin/SampleDriver/Instance1 is valid: Instance1 is the device, and com_osvr_plugin is the plugin.

Returns
The device node
Exceptions
osvr::common::exceptions::InvalidDeviceNameif an invalid device name (less than two components) was passed
osvr::common::exceptions::EmptyPathComponentif any component in the given path is empty after passing initial checks.
Todo:
remove added node here?
Todo:
What about intermediate paths between a plugin and a device? (device types, for instance) We leave them null for now.
Todo:
remove added node here?
Todo:
What about intermediate paths between a plugin and a device? (device types, for instance) We leave them null for now.

§ appendCurrentIface()

void osvr::common::appendCurrentIface ( Json::Value &  augInterface,
Json::Value &  currInterface 
)

appends json value for a given string

Todo:
mergeIdenticalInterfaces(currInterface, augInterface, detail)

§ applyPathNodeVisitor()

template<typename Visitor >
Visitor::result_type osvr::common::applyPathNodeVisitor ( Visitor &  v,
PathNode node 
)
inline

Visit a node's element's contained type, similar to boost::apply_visitor, but passing both the PathNode and the PathElement type.

§ applyPriorityToAlias()

Json::Value osvr::common::applyPriorityToAlias ( Json::Value const &  alias,
AliasPriority  priority 
)

Given a JSON object describing one or more aliases, set the priority of the alias(es).

Returns
Updated description, or input if unchanged/not applicable.

§ computeAlignmentPadding()

size_t osvr::common::computeAlignmentPadding ( size_t  alignment,
size_t  currentSize 
)
inline

Given an alignment in bytes, and a current size of a buffer, return the number of bytes of padding required to align the next field to be added to the buffer at the desired alignment within that buffer.

That is, return some padding such that (currentSize + padding) % alignment == 0 for alignment > 1.

Parameters
alignmentAlignment in bytes: both 0 and 1 are accepted to mean "no alignment"
currentSizeCurrent number of bytes in a buffer

No alignment requested

Buffer is already aligned

Buffer needs some padding

§ convertRouteToAlias()

Json::Value osvr::common::convertRouteToAlias ( Json::Value const &  val)

Given a single JSON object, if it's an old-fashioned "routing directive", convert it to a normal "alias".

Returns
Converted aliases, value unchanged if not a routing directive

§ createJSONAlias()

Json::Value osvr::common::createJSONAlias ( std::string const &  path,
Json::Value const &  destination 
)

Given a path and a destination, combine them into a JSON alias description.

Returns
A JSON object for your alias, or a null value if either input is invalid.

§ deleteContext()

void osvr::common::deleteContext ( ClientContext ctx)

Use the stored deleter to appropriately delete the client context.

§ deserialize()

template<typename BufferReaderType , typename MessageClass >
void osvr::common::deserialize ( BufferReaderType &  reader,
MessageClass &  msg 
)

Deserializes a message from a buffer, using a MessageClass

Your MessageClass class must implement a method template<typename T> void processMessage(T & process) that calls process() with each field (optionally providing a tag type). After each such call, the fields processed so far are guaranteed to contain valid data (in this case, the data deserialized from the buffer), in case your processMessage() method needs to perform computation.

§ for_each_cleanup_pointers()

template<typename T , typename F >
void osvr::common::for_each_cleanup_pointers ( T c,
F &&  f 
)
inline

Given a container of weak ptrs to some type and a functor that operates on references to that type, go through all elements of the container in a single pass, calling the functor on those elements still valid, and removing those invalid ones.

(Uses member function resize with two iterators)

§ getPathFromOldRouteSource()

std::string osvr::common::getPathFromOldRouteSource ( Json::Value  obj)
inline

Helper, converts old-style tracker source into normal.

For a little backward-compatibility.

Todo:
remove this method in the future.

§ getPathSeparator()

const char * osvr::common::getPathSeparator ( )

Gets the path separator - a slash - as a null-terminated string.

§ getStandardClientInterfaceFactory()

ClientInterfaceFactory osvr::common::getStandardClientInterfaceFactory ( )

Returns a client interface factory suitable for standard client use.

§ getTrackerSensorInfo()

TrackerSensorInfo osvr::common::getTrackerSensorInfo ( OriginalSource const &  source)
inline

Given a fully-parsed tracker source, determines what messages and subsets thereof it reports.

Get the named value from the object, using the given value reference as both a default value and a destination.

First see if there are device-global properties

Now check for a traits array - overrides device-global propertes

Todo:
Apply modifications based on transforms. translation causes report of position in orientation trackers, etc.

§ ifNullTryInferFromParent()

void osvr::common::ifNullTryInferFromParent ( common::PathNode node)
inline

Given a node, if it's null, try to infer from the parent what it should be.

Right now can only infer that the children of an interface are sensors.

Not null.

§ jsonToStyledString()

std::string osvr::common::jsonToStyledString ( Json::Value const &  val)
inline

Turns the JSON value into a pretty-printed, human-targeted string representation.

§ makeContext()

template<typename T , typename... Args>
T* osvr::common::makeContext ( Args...  args)
inline

Create a subclass object of ClientContext, setting the deleter appropriately by passing it as the last parameter.

Compare to std::make_shared.

§ mergeIdenticalInterfaces()

void osvr::common::mergeIdenticalInterfaces ( Json::Value &  existingIface,
Json::Value &  newIface,
std::string const &  detail 
)
Todo:
when appending interfaces you might encounter that there are independent interfaces that are same as subinterfaces for example, eyetracker device and tracker device plugin eyetracker breaks down into 4 interfaces including tracker so to avoid replacing tracker data, we need to safely merge them

§ normalizeDeviceDescriptor()

std::string osvr::common::normalizeDeviceDescriptor ( std::string const &  jsonDescriptor)

"Normalizes" a device descriptor by parsing it and adding implied interfaces to the existing device descriptor before serializing it back out to a string.

Contains logic for every interface that combines multiple other interfaces, such as eyetracker (direction, location2d, tracker, button)

Returns
a serialized JSON string (may be unmodified)
Todo:
process for tracker interface

if can't parse as json then leave unchanged, err will be handler later

no interfaces member so don't chanage anything

Todo:
for tracker
Todo:
for future interfaces

if can't parse as json then leave unchanged, err will be handler later

no interfaces member so don't chanage anything

Todo:
for tracker
Todo:
for future interfaces

§ outputPriority()

detail::AliasPriorityWrapper osvr::common::outputPriority ( AliasPriority  priority)
inline

Helper method to output a priority in a formatted way to a stream.

§ pathParseAndRetrieve() [1/2]

template<typename ValueType >
util::TreeNode<ValueType>& osvr::common::pathParseAndRetrieve ( util::TreeNode< ValueType > &  root,
std::string const &  path 
)
inline

Internal method for parsing a path and getting or creating the nodes along it.

Parameters
pathAn absolute path (beginning with /) - a trailing slash is trimmed silently
rootThe root node of a tree. This is not checked at runtime (just a debug assert) since this should only be called from safe, internal locations!

If nodes do not exist, they are created as default

Returns
a reference to the leaf node referred to by the path.
Exceptions
exceptions::PathNotAbsolute,exceptions::EmptyPath,exceptions::EmptyPathComponent,exceptions::ForbiddenParentPath

§ pathParseAndRetrieve() [2/2]

template<typename ValueType >
util::TreeNode<ValueType> const& osvr::common::pathParseAndRetrieve ( util::TreeNode< ValueType > const &  root,
std::string const &  path 
)
inline

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

§ processDeviceDescriptorForPathTree()

bool osvr::common::processDeviceDescriptorForPathTree ( PathTree tree,
std::string const &  deviceName,
std::string const &  jsonDescriptor,
int  listenPort,
std::string const &  host 
)

Set up a path tree based on a device descriptor.

Returns
true if changes were made

Set up device node

normalize device descriptor

Parse JSON to stuff into device node.

Todo:
warn about failed descriptor parse?
Todo:
no change in descriptor so no processing?

Set up device node

normalize device descriptor

Parse JSON to stuff into device node.

Todo:
warn about failed descriptor parse?
Todo:
no change in descriptor so no processing?

§ processDeviceDescriptorFromExistingDevice()

bool osvr::common::processDeviceDescriptorFromExistingDevice ( PathNode devNode,
elements::DeviceElement const &  devElt 
)

Set up a path tree based on a device descriptor from an existing DeviceElement node.

Returns
true if changes were made

§ readExternalBuffer()

template<typename CharType >
BufferReader<ExternalBufferReadingWrapper<CharType> > osvr::common::readExternalBuffer ( const CharType *  buf,
size_t  len 
)
inline

Constructs and returns a buffer reader for an externally-allocated buffer: it's on you to supply a valid pointer and length.

§ remove_if()

template<typename UnaryPredicate >
void osvr::common::remove_if ( GeneralizedTransform transform,
UnaryPredicate  pred 
)
inline

Remove levels from a generalized transform as dictated by an arbitrary predicate.

Acts just like std::remove_if except that it also resizes the container.

§ resolveFullTree()

std::vector< std::string > osvr::common::resolveFullTree ( PathTree tree)

Traverse the given path tree, resolving all aliases found to fully populate any generated sensor targets.

Returns
A vector of paths that are aliases that could not be resolved.

§ serialize()

template<typename BufferType , typename MessageClass >
void osvr::common::serialize ( BufferType &  buf,
MessageClass &  msg 
)

Serializes a message into a buffer, using a MessageClass

Your MessageClass class must implement a method template<typename T> void processMessage(T & process) that calls process() with each field (optionally providing a tag type). After each such call, the fields processed so far are guaranteed to contain valid data (in this case, the same data they started with), in case your processMessage() method needs to perform computation.

Todo:
add another functor to first compute message length and reserve buffer space?

§ treePathRetrieve() [1/2]

template<typename ValueType >
util::TreeNode<ValueType>& osvr::common::treePathRetrieve ( util::TreeNode< ValueType > &  node,
std::string  path,
bool  permitParent = false 
)
inline

Internal method for parsing a path and getting or creating the nodes along it.

Parameters
pathAn absolute path (beginning with /) or a path relative to the node (no leading /) - a trailing slash is trimmed silently
nodeA node of a tree. If a leading slash is found on the path, the node will be used to find the root, otherwise it is considered the place to which the given path is relative.
permitParentAn optional flag indicating if ".." is permitted as a component of the path, moving to the parent level.

If nodes do not exist, they are created as default. An empty path results in returning the same node provided. A component of a path equal to "." is effectively ignored ("current directory" behavior)

Returns
a reference to the node referred to by the path.
Exceptions
exceptions::EmptyPathComponent,exceptions::ForbiddenParentPath,exceptions::ImpossibleParentPath

§ treePathRetrieve() [2/2]

template<typename ValueType >
util::TreeNode<ValueType> const& osvr::common::treePathRetrieve ( util::TreeNode< ValueType > const &  node,
std::string  path,
bool  permitParent = false 
)
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 works with const trees, and does not create missing children: instead it throws util::tree::NoSuchChild.

§ wrapSharedContext()

template<typename T >
ClientContextSharedPtr osvr::common::wrapSharedContext ( T context)
inline

Wrap a client context pointer in a shared pointer with the correct custom deleter.