12 #if defined(_MSC_VER) && (_MSC_VER < 1900) 15 #define NOEXCEPT noexcept 64 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
74 mxArray *plhs[],
int nrhs,
const mxArray *prhs[]) {
76 toMex(func(), plhs, nlhs);
82 mxArray *plhs[],
int nrhs,
const mxArray *prhs[]) {
87 template <
typename R,
typename Arg0,
typename... Args>
89 mxArray *plhs[],
int nrhs,
const mxArray *prhs[]) {
91 auto partially_applied = [&](Args &&... tail) {
92 return std::move(func)(
94 std::forward<Args>(tail)...);
99 nlhs, plhs, nrhs - 1, &prhs[1]);
115 template <
typename Arg0,
typename... Args>
117 int arg_num, std::ostream *
log, Arg0 *,
121 const int expected_num_args =
sizeof...(Args) + 1;
122 if (nrhs != expected_num_args) {
124 *
log <<
"Expected " << expected_num_args <<
" arguments, but got " 133 <<
"Error occurred while checking argument " << arg_num <<
" of " 148 template <
typename R,
typename... Args>
150 bool throw_on_error, std::function<R(Args...)> func) {
152 nrhs, prhs, 0,
nullptr,
156 }
else if (throw_on_error) {
157 std::ostringstream
log;
158 log <<
"mexCallFunction: unable to convert mex arguments:" << std::endl;
161 throw std::runtime_error(log.str());
179 template <
typename R0,
typename... Args0,
typename... Funcs>
181 int nrhs,
const mxArray *prhs[], std::ostream &
log,
int function_num,
182 std::function<R0(Args0...)> function0, Funcs... functions) {
185 <<
"Trying function number " << function_num << std::endl;
199 const mxArray *prhs[],
bool throw_on_error) {
204 template <
typename Func0,
typename... Funcs>
206 const mxArray *prhs[],
bool throw_on_error,
207 Func0 function0, Funcs... functions) {
215 if (throw_on_error && !success) {
216 std::ostringstream
log;
217 log <<
"mexTryToCallFunctions: failed to find a function to call after " 218 "trying " <<
sizeof...(Funcs) + 1 <<
" options. Errors:";
221 throw std::runtime_error(log.str());
233 template <
typename T>
234 auto fromMex(
const mxArray *source, T *trigger_type)
239 std::ostringstream
log;
241 throw std::runtime_error(log.str());
void mexCallFunctionUnsafe(std::function< R(void)> func, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexCallFunctionUnsafe Converts arguments and calls function without checking whether arguments are co...
Definition: mexify.h:73
bool mexTryToCallFunctions(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], bool throw_on_error)
mexTryToCallFunctions keep trying functions in order until one is called without error.
Definition: mexify.h:198
FunctionalForm log(FunctionalForm const &x)
Definition: functional_form.cc:198
bool areArgumentsConvertibleFromMex(int nrhs, const mxArray *prhs[], int arg_num, std::ostream *log) NOEXCEPT
areArgumentsConvertibleFromMex Checks whether the Matlab input arguments match the function signature...
Definition: mexify.h:109
RigidBodyTree & fromMexUnsafe(const mxArray *source, RigidBodyTree *)
Definition: rigidBodyTreeMexConversions.h:55
bool isConvertibleFromMex(const mxArray *source, RigidBodyTree *ptr, std::ostream *log) NOEXCEPT
fromMex specializations
Definition: rigidBodyTreeMexConversions.h:50
void toMex(const KinematicPath &path, mxArray *dest[], int nlhs)
toMex specializations
Definition: rigidBodyTreeMexConversions.h:90
typename std::remove_cv< typename std::remove_reference< T >::type >::type FromMexType
Functions that make it easy to create a mex file that calls a std::function.
Definition: mexify.h:64
auto fromMex(const mxArray *source, T *trigger_type) -> decltype(fromMexUnsafe(source, trigger_type))
fromMex For if you only want to convert a single argument.
Definition: mexify.h:234
bool mexCallFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], bool throw_on_error, std::function< R(Args...)> func)
mexCallFunction checks whether arguments are convertible, and then calls mexCallFunctionUnsafe.
Definition: mexify.h:149
#define NOEXCEPT
Definition: mexify.h:15
void collectMexTryCallFunctionsErrorDiagnostics(int nrhs, const mxArray *prhs[], std::ostream &log, int function_num)
collectMexTryCallFunctionsErrorDiagnostics write diagnostic information to log; called after mexTryTo...
Definition: mexify.h:172