The Util library: Functionality not necessarily coupled to any particular core library, serving more as a common base layer behind all systems. More...
Namespaces | |
container_policies | |
Flags or arguments to specify what features you want ContainerWrapper to provide publicly. Pass as template args to ContainerWrapper to request a feature. | |
eigen_interop | |
filters | |
Filters for use with Eigen datatypes. | |
time | |
Functionality related to time and the OSVR_TimeValue abstraction.Note that this is for C API-bordering areas. For purely C++ code, please use std::chrono for your time needs. | |
tree | |
Contains a generic tree. This namespace exists to assist in argument-dependent lookup with tree-related nonmembers, the class template TreeNode is imported into the parent namespace. | |
typesafeid_traits | |
Namespace for traits templates associated with ::osvr::util::TypeSafeId. | |
unique_container_policies | |
Policies controlling behavior of UniqueContainer. | |
Classes | |
class | AlignedAllocDeleter |
Deleter class matching alignedAlloc. More... | |
class | AnyMap |
A data structure storing "any" by name, to reduce coupling. More... | |
class | BasicKeyedOwnershipContainer |
Holds on to smart pointers by value, and lets you free them by providing the corresponding void *. More... | |
class | CallbackWrapper |
A class template turning a callback with some number of arguments, with a userdata pointer last, into a function object. More... | |
class | CellGroupProxy |
struct | Conditional |
Quick C++11-aligned conditional (if/then/elese) implementation. More... | |
class | CSV |
class | CSVBase |
class | DefaultBool |
A class template primarily useful for flags, that has a defined value at default initialization. More... | |
class | Deletable |
Base class for objects that just need to be generically deletable. More... | |
struct | EnableIf |
Quick C++11-aligned enable_if implementation. More... | |
class | FinalTask |
class | Flag |
A class that lightly wraps a bool, in order to provide easier maintenance of a "dirty" flag, for example, with sensible default initialization and no short-circuiting. More... | |
struct | GenericCaller |
Struct containing a single static function member named "call" that serves as a converter from a function call with an opaque userdata pointer to a functor call using the userdata pointer as "this". More... | |
class | GuardInterface |
An interface to a (deferred) guard class: after instantiation and lock returning true, some resource is locked and available until destruction. More... | |
struct | HashIdAggregate |
class | IndentingStream |
A boost::iostreams::filtering_ostream with a constructor that automatically sets it up to indent the first character after a newline the given number of spaces and forward the output to a std::ostream. More... | |
class | NumberTypeData |
Runtime data on numeric types. More... | |
class | PointerWrapper |
A wrapper to easily define structures that exist just to hold a pointer. More... | |
class | ResourcePath |
Class representing a host and resource path in the OSVR logical system. More... | |
class | StreamCSV |
class | StringBufferBuilder |
A utility class to adapt APIs that first provide a length, then place a string in a user-allocated buffer, to nearly transparently handle the buffer and convert into a std::string. More... | |
struct | this_first_t |
Tag type indicating the first parameter of the function contains the "this" pointer. More... | |
struct | this_last_t |
Tag type indicating the last parameter of the function contains the "this" pointer. More... | |
class | TypeSafeIdBase |
A generic typesafe (as long as you use differing tag types) wrapper for identifiers (typically integers). More... | |
class | UniqueContainer |
A "Unique Container" designed for composition, not inheritance. More... | |
class | UniqueContainerBase |
A policy-based generic "Unique Container", that wraps ContainerWrapper (and thus an underlying container) with set-like semantics/invariant: at most one instance of a value is in the container at a time. More... | |
class | ValueOrRange |
Class providing a unified container-like interface to either a single value or a range of integers. More... | |
Typedefs | |
template<typename System , typename Y = double> | |
using | AngleGeneric = boost::units::quantity< boost::units::unit< boost::units::plane_angle_dimension, System >, Y > |
Convenience template alias for a plane_angle quantity in an arbitrary system with arbitrary scalar. | |
template<typename Y > | |
using | AngleRadians = boost::units::quantity< boost::units::si::plane_angle, Y > |
Alias for an angle in radians with arbitrary scalar type. | |
template<typename Y > | |
using | AngleDegrees = boost::units::quantity< boost::units::degree::plane_angle, Y > |
Alias for an angle in degrees with arbitrary scalar type. | |
typedef AngleRadiansd | Angle |
Default angle type. | |
template<typename Container , typename... Args> | |
using | ContainerWrapper = detail::ContainerWrapper_t< Container, Args...> |
Parent class to inherit from to get a container with some functionality exposed. More... | |
template<std::size_t minBytes, bool isSigned = false> | |
using | sized_int_t = typename detail::sized_int< minBytes, isSigned >::type |
typedef shared_ptr< Deletable > | DeletablePtr |
Shared-ownership smart pointer to a Deletable. | |
typedef ::std::vector < DeletablePtr > | DeletableList |
Vector of shared-ownership smart pointers. | |
Enumerations | |
enum | { DefaultOSVRPort = 3883 } |
enum | { , OmitAppendingPort = -2 } |
Functions | |
void * | alignedAlloc (size_t bytes, size_t alignment=OSVR_DEFAULT_ALIGN_SIZE) |
Aligned allocation function, gives a pointer to a block of memory aligned to a memory boundary. | |
void | alignedFree (void *p) |
Aligned deallocation function, uses the pointer to the original memory block to deallocate it. | |
template<typename System , typename Y > | |
Y | getRadians (AngleGeneric< System, Y > const angle) |
Get the raw scalar value of your angle in radians. | |
template<typename System , typename Y > | |
Y | getDegrees (AngleGeneric< System, Y > const angle) |
Get the raw scalar value of your angle in degrees. | |
std::string | getBinaryLocation () |
template<typename T > | |
detail::Cell< T > | cell (const char *header, T const &data) |
Helper free function to make a CSV cell. | |
template<typename T > | |
detail::Cell< T > | cell (std::string const &header, T const &data) |
Helper free function to make a CSV cell. | |
template<typename RowProxyType , typename GroupTag , typename... CellArgs> | |
CellGroupProxy< RowProxyType, GroupTag > & | operator<< (CellGroupProxy< RowProxyType, GroupTag > &group, detail::Cell< CellArgs...> &¤tCell) |
template<typename T > | |
detail::CellGroup< T > | cellGroup (const char *groupHeader, T const &data) |
Helper function to create a cell group with a group header prefix. | |
template<typename T > | |
detail::CellGroup< T, std::string > | cellGroup (std::string const &groupHeader, T const &data) |
Helper function to create a cell group with a group header prefix. | |
template<typename Tag , typename T > | |
detail::CellGroup< T, const char *, Tag > | cellGroup (const char *groupHeader, T const &data, Tag *=static_cast< Tag * >(nullptr)) |
template<typename Tag , typename T > | |
detail::CellGroup< T, std::string, Tag > | cellGroup (std::string const &groupHeader, T const &data, Tag *=static_cast< Tag * >(nullptr)) |
template<typename T > | |
detail::CellGroup< T > | cellGroup (T const &data) |
template<typename Tag , typename T > | |
detail::CellGroup< T, const char *, Tag > | cellGroup (T const &data, Tag *=static_cast< Tag * >(nullptr)) |
template<typename Derived > | |
detail::SameLayoutVector < 4, Derived > | makeHomogeneousPoint (Eigen::MatrixBase< Derived > const &vec) |
Makes a 3D vector into a 4D homogeneous point, with the same options (scalar, row vs col vector) as the input. | |
template<typename Derived > | |
detail::SameLayoutVector < 4, Derived > | makeHomogeneousVector (Eigen::MatrixBase< Derived > const &vec) |
Makes a 3D vector into a 4D homogeneous vector, with the same options (scalar, row vs col vector) as the input. | |
template<typename Derived > | |
detail::SameLayoutVector < 3, Derived > | extractPoint (Eigen::MatrixBase< Derived > const &homogenous) |
Pulls the 3D point or vector from a 4D vec, performing division by w if it is nonzero. | |
template<typename Derived1 , typename Derived2 > | |
Isometry3< typename Derived1::Scalar > | makeIsometry (Eigen::MatrixBase< Derived1 > const &translation, Eigen::RotationBase< Derived2, 3 > const &rotation) |
A simpler, functional-style alternative to .fromPositionOrientationScale when no scaling is performed. | |
Eigen::Map< Eigen::Vector3d > | vecMap (OSVR_Vec3 &vec) |
Wrap an OSVR_Vec3 in an Eigen object that allows it to interoperate with Eigen as though it were an Eigen::Vector3d. More... | |
Eigen::Map< const Eigen::Vector3d > | vecMap (OSVR_Vec3 const &vec) |
Eigen::Quaterniond | fromQuat (OSVR_Quaternion const &q) |
Convert an OSVR_Quaternion to an Eigen::Quaterniond. | |
void | toQuat (Eigen::Quaterniond const &src, OSVR_Quaternion &q) |
Convert an Eigen::Quaterniond to a OSVR_Quaternion. | |
Eigen::Isometry3d | fromPose (OSVR_Pose3 const &pose) |
Turn an OSVR_Pose3 into an Eigen::Transform. More... | |
void | toPose (Eigen::Isometry3d const &xform, OSVR_Pose3 &pose) |
Turn an Eigen::Isometry3d (transform) into an OSVR_Pose3. More... | |
void | toPose (Eigen::Matrix4d const &mat, OSVR_Pose3 &pose) |
Turn an Eigen::Matrix4d (transform) into an OSVR_Pose3. More... | |
template<typename T > | |
auto | extractYaw (T const &quat) -> decltype(std::atan(quat.w())) |
template<typename F > | |
FinalTask< F > | finally (F &&f) |
template<typename F > | |
FinalTask< F > | finally (F const &f) |
template<typename FunctionPtr , typename FunctionObjectType , typename ThisLocation > | |
FunctionPtr | getCaller () |
Get a generic functor caller: a pointer to a function that will call an object of your specific function object type, expecting the function object address passed as a void * as a parameter. More... | |
template<typename FunctionPtr , typename FunctionObjectType , typename ThisLocation > | |
FunctionPtr | getCaller (ThisLocation const &) |
Get a generic functor caller. Specify the location of "this" through the argument: results in automatic type deduction for ThisLocation. More... | |
template<typename FunctionPtr , typename FunctionObjectType , typename ThisLocation > | |
FunctionPtr | getCaller (FunctionObjectType const *, ThisLocation const &) |
Get a generic functor caller. Pass a pointer to a function object and specify the location of "this" through the argument: results in automatic type deduction for FunctionObjectType and ThisLocation. More... | |
template<typename T > | |
void | generic_deleter (void *obj) |
Generic deleter function, wrapping the stock delete call. More... | |
boost::optional< std::string > | getEnvironmentVariable (std::string const &var) |
Gets an environment variable's value. On systems that don't distinguish between having a variable defined and having it non-empty (like Windows), empty will imply not defined and thus an empty boost::optional return value. | |
template<typename Scalar , typename T > | |
void | matrixEigenAssign (T const &src, OSVR_MatrixConventions flags, Scalar *dest) |
Helper function template to assign/convert matrices as required. More... | |
template<typename Functor > | |
bool | opencvTypeDispatch (int openCVType, Functor &f) |
Given an OpenCV type depth and a reference to a functor, calls that functor with a single parameter: the corresponding type wrapped in boost::mpl::identity. More... | |
int | cvTypeFromData (bool isSigned, bool isFloat, size_t depth) |
Computes the OpenCV "type" (also known as depth - as in CV_8U) for a given combination of signed, float, and byte depth. | |
int | computeOpenCVMatType (OSVR_ImagingMetadata const &metadata) |
Computes the OpenCV matrix type (as in CV_8UC3) from a metadata struct. | |
std::pair< std::string, std::string > | convertProgramOptionShowHideIntoTrueFalse (std::string s) |
An "additional parser" for Boost.Program_options that will turn any –hide-xyz into –xyz false and –show-xyz into –xyz true. | |
Eigen::Matrix4d | createProjectionMatrix (Rectd const &bounds, double near, double far) |
Takes in points at the near clipping plane, as well as the near and far clipping planes. Result matrix maps [l, r] and [b, t] to [-1, 1], and [n, f] to [-1, 1] (should be configurable) More... | |
template<projection_options::OptionType options = projection_options::ZOutputSigned | projection_options::RightHandedInput> | |
Eigen::Matrix4d | parameterizedCreateProjectionMatrix (Rectd const &bounds, double near, double far) |
Takes in points at the near clipping plane, as well as the near and far clipping planes. Result matrix maps [l, r] and [b, t] to [-1, 1], and [n, f] to [-1, 1] or [0, 1] depending on presence/absence of ZOutputUnsigned flag bit, taking in right- or left-handed input also as configured. | |
template<typename System > | |
Rectd | computeSymmetricFOVRect (AngleGeneric< System > hFov, AngleGeneric< System > vFov) |
Compute a rectangle at unit distance for the given fov values. | |
template<typename System > | |
Rectd | computeSymmetricFOVRect (AngleGeneric< System > hFov, AngleGeneric< System > vFov, double near) |
Compute a rectangle at the near clipping plane for the given fov values. | |
template<typename System > | |
Eigen::Matrix4d | createSymmetricProjectionMatrix (AngleGeneric< System > hFov, AngleGeneric< System > vFov, double near, double far) |
template<typename RangeType > | |
void | resetPointerRange (RangeType range) |
Reset every smart pointer in a container one by one. | |
template<size_t N> | |
std::string | makeString (const char(&arrayLiteral)[N]) |
Safely and easily convert a literal array of characters (like from osvr_json_to_c) into a std::string. | |
The Util library: Functionality not necessarily coupled to any particular core library, serving more as a common base layer behind all systems.
using osvr::util::ContainerWrapper = typedef detail::ContainerWrapper_t<Container, Args...> |
Parent class to inherit from to get a container with some functionality exposed.
Container | the underlying container you want, reference accessible via Base::container() |
Args | 0 or more tag types from osvr::util::container_policies indicating the features you want publicly exposed |
Definition at line 232 of file ContainerWrapper.h.
using osvr::util::sized_int_t = typedef typename detail::sized_int<minBytes, isSigned>::type |
Alias providing an integer type (signed or unsigned, your choice) containing at least as many bytes as you requested.
Definition at line 80 of file SizedInt.h.
anonymous enum |
Enumerator | |
---|---|
DefaultOSVRPort |
Definition at line 42 of file DefaultPort.h.
anonymous enum |
Enumerator | |
---|---|
OmitAppendingPort |
For use when there may not actually be a port in use: some single process situations, etc. |
Definition at line 43 of file PortFlags.h.
std::string osvr::util::getBinaryLocation | ( | ) |
Get this binary's location, often as a step in finding the "root" and search paths.
|
inline |
Handles user results from overloading operator<<(CellGroupProxy<RowProxyType, GroupTag> &group, TheirThing)
and sending in cell
calls within it.
Definition at line 73 of file CSVCellGroup.h.
|
inline |
Helper function to create a cell group with a group header prefix and explicit (non-default) tag.
Definition at line 175 of file CSVCellGroup.h.
|
inline |
Helper function to create a cell group with a group header prefix and explicit (non-default) tag.
Definition at line 184 of file CSVCellGroup.h.
|
inline |
Helper function to create a cell group with no group header prefix - warning: column headers must be unique!
Definition at line 190 of file CSVCellGroup.h.
|
inline |
Helper function to create a cell group with no group header prefix and explicit (non-default) tag - warning: column headers must be unique!
Definition at line 198 of file CSVCellGroup.h.
|
inline |
A utility function to extract "yaw" out of a quaternion, of any representation as long as it responds to .w()
, .x()
, .y()
, and .z()
. Uses atan2() internally, and the return type is automatically deduced based on the scalar type in use in your quaternion class.
Reference: http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
Definition at line 47 of file ExtractYaw.h.
|
inline |
Creation free function for final tasks to run on scope exit. Works great when paired with lambdas (particularly with [&]
reference capture). Use like: auto f = finally([&]{ dothis(); });
to have dothis()
called when f
goes out of scope, no matter how.
Perfect forwarding version.
|
inline |
|
inline |
Get a generic functor caller: a pointer to a function that will call an object of your specific function object type, expecting the function object address passed as a void * as a parameter.
FunctionPtr | Desired function pointer type |
FunctionObjectType | Type of your function object |
ThisLocation | one of this_first_t or this_last_t indicating which parameter is the "userdata" this pointer. |
Function wrapper around GenericCaller.
Definition at line 259 of file GenericCaller.h.
|
inline |
Get a generic functor caller. Specify the location of "this" through the argument: results in automatic type deduction for ThisLocation.
FunctionPtr | Desired function pointer type |
FunctionObjectType | Type of your function object |
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 275 of file GenericCaller.h.
|
inline |
Get a generic functor caller. Pass a pointer to a function object and specify the location of "this" through the argument: results in automatic type deduction for FunctionObjectType and ThisLocation.
Note that nothing is actually done with your function object pointer: you still need to pass it along with this function pointer as userdata.
FunctionPtr | Desired function pointer type |
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 294 of file GenericCaller.h.
|
inline |
Generic deleter function, wrapping the stock delete call.
Used in header-only C++ wrappers over C APIs.
Definition at line 33 of file GenericDeleter.h.
|
inline |
Helper function template to assign/convert matrices as required.
Handles memory ordering (transpose) and scalar type conversion automatically/based on the flags passed in.
src | An Eigen 4x4 fixed-size matrix or matrix expression (source) |
flags | Some matrix convention flags - only the first two (the ones that affect if a transpose is needed) are observed. |
dest | A pointer to a contiguous 16-element array (destination for the copy) |
Definition at line 51 of file MatrixEigenAssign.h.
|
inline |
Given an OpenCV type depth and a reference to a functor, calls that functor with a single parameter: the corresponding type wrapped in boost::mpl::identity.
Definition at line 54 of file OpenCVTypeDispatch.h.
|
inline |
Takes in points at the near clipping plane, as well as the near and far clipping planes. Result matrix maps [l, r] and [b, t] to [-1, 1], and [n, f] to [-1, 1] (should be configurable)
Resulting matrix operates on Eigen::Vector4d, which are row-matrices - transpose if you want it to work on column matrices.
Definition at line 48 of file ProjectionMatrix.h.
|
inline |
Note that because we delegate to the fully-generic projection matrix code, we'll end up computing two entries in the third column that will always be zero (and other computations may include an unnecessary addition/subtraction). But, only one place to introduce bugs.
Definition at line 81 of file ProjectionMatrixFromFOV.h.