OSVR-Core
|
Header providing templated functions to automate the process of calling a C++ member function (specifically the function call operator) from a facility that accepts a C function pointer and an opaque "userdata" pointer. More...
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/if.hpp>
#include <boost/preprocessor/enum.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#include <boost/function_types/function_arity.hpp>
#include <boost/function_types/result_type.hpp>
#include <boost/function_types/parameter_types.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/next_prior.hpp>
#include <boost/static_assert.hpp>
Go to the source code of this file.
Classes | |
struct | osvr::util::functor_trampolines::this_last_t |
Tag type indicating the last parameter of the function contains the "this" pointer. More... | |
struct | osvr::util::functor_trampolines::this_first_t |
Tag type indicating the first parameter of the function contains the "this" pointer. More... | |
struct | osvr::util::functor_trampolines::detail::param_at< F, C > |
Convenience metafunction to simplify computing the type of a particular argument to a function F. More... | |
struct | osvr::util::functor_trampolines::detail::Caller< ThisLocation, Arity, Return > |
Template that will be specialized to contain callers for functors with the "this" pointer as a void * argument. More... | |
struct | osvr::util::functor_trampolines::detail::ComputeGenericCaller< FunctionPtr, FunctionObjectType, ThisLocation > |
Internal metafunction to compute which caller you need based on the pointer types and this location. More... | |
struct | osvr::util::functor_trampolines::GenericCaller< FunctionPtr, FunctionObjectType, ThisLocation > |
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... | |
Namespaces | |
osvr | |
The main namespace for all C++ elements of the framework, internal and external. | |
osvr::util | |
The Util library: Functionality not necessarily coupled to any particular core library, serving more as a common base layer behind all systems. | |
Macros | |
#define | OSVR_UTIL_CALLER_MAX_ARITY 3 |
#define | OSVR_PARAM_STEM p |
what do we call our pass-through parameters | |
#define | OSVR_MAKE_PARAMLIST(Z, N, unused) typename param_at<FPtr, N>::type BOOST_PP_CAT(OSVR_PARAM_STEM, N) |
Macro for use with BOOST_PP_ENUM to generate pass-through argument list. | |
#define | OSVR_RETURNTYPE(R) |
Expands to the result type computation if R==1, void if R==0. More... | |
#define | OSVR_RETURNSTATEMENT(R) BOOST_PP_IF(R, return, BOOST_PP_EMPTY()) |
Expands to "return" if R==1, nothing if R==0. More... | |
#define | OSVR_MAKE_CALLERS(Z, ARITY, RETURNS) |
Generates specializations of CallerThisLast and CallerThisFirst for the given values of ARITY and RETURNS (matching the template parameters). More... | |
Functions | |
template<typename FunctionPtr , typename FunctionObjectType , typename ThisLocation > | |
FunctionPtr | osvr::util::functor_trampolines::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 | osvr::util::functor_trampolines::getCaller (ThisLocation const &) |
Get a generic functor caller. More... | |
template<typename FunctionPtr , typename FunctionObjectType , typename ThisLocation > | |
FunctionPtr | osvr::util::functor_trampolines::getCaller (FunctionObjectType const *, ThisLocation const &) |
Get a generic functor caller. More... | |
Variables | |
BOOST_CONSTEXPR_OR_CONST this_last_t | this_last = {} |
Pass as an argument to a getCaller() overload to indicate the last parameter of the function contains the "this" pointer. More... | |
BOOST_CONSTEXPR_OR_CONST this_first_t | this_first = {} |
Pass as an argument to a getCaller() overload to indicate the first parameter of the function contains the "this" pointer. More... | |
Header providing templated functions to automate the process of calling a C++ member function (specifically the function call operator) from a facility that accepts a C function pointer and an opaque "userdata" pointer.
#define OSVR_MAKE_CALLERS | ( | Z, | |
ARITY, | |||
RETURNS | |||
) |
Generates specializations of CallerThisLast and CallerThisFirst for the given values of ARITY and RETURNS (matching the template parameters).
Intended for use with BOOST_PP_REPEAT, passing a value (0 or 1) for RETURNS in the third, "data" parameter.
#define OSVR_RETURNSTATEMENT | ( | R | ) | BOOST_PP_IF(R, return, BOOST_PP_EMPTY()) |
Expands to "return" if R==1, nothing if R==0.
R | value of RETURNS |
#define OSVR_RETURNTYPE | ( | R | ) |
Expands to the result type computation if R==1, void if R==0.
R | value of RETURNS |
|
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.
|
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.
|
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.
BOOST_CONSTEXPR_OR_CONST this_first_t this_first = {} |
Pass as an argument to a getCaller() overload to indicate the first parameter of the function contains the "this" pointer.
()
BOOST_CONSTEXPR_OR_CONST this_last_t this_last = {} |
Pass as an argument to a getCaller() overload to indicate the last parameter of the function contains the "this" pointer.
()