Verified Commit 51840667 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add Unirary visitor on JointDataBase<Derived> objects

parent 91d0bda3
//
// Copyright (c) 2015-2019 CNRS INRIA
// Copyright (c) 2015-2021 CNRS INRIA
//
#ifndef __pinocchio_multibody_visitior_joint_unary_visitor_hpp__
......@@ -69,6 +69,14 @@ namespace pinocchio
return boost::apply_visitor(visitor,jmodel);
}
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
static ReturnType run(const JointDataTpl<Scalar,Options,JointCollectionTpl> & jdata,
ArgsTmp args)
{
InternalVisitorModel<ArgsTmp> visitor(args);
return boost::apply_visitor(visitor,jdata);
}
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel)
{
......@@ -76,6 +84,13 @@ namespace pinocchio
return boost::apply_visitor(visitor,jmodel);
}
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
static ReturnType run(const JointDataTpl<Scalar,Options,JointCollectionTpl> & jdata)
{
InternalVisitorModel<NoArg> visitor;
return boost::apply_visitor(visitor,jdata);
}
template<typename JointModelDerived, typename ArgsTmp>
static ReturnType run(const JointModelBase<JointModelDerived> & jmodel,
ArgsTmp args)
......@@ -84,6 +99,14 @@ namespace pinocchio
return visitor(jmodel.derived());
}
template<typename JointDataDerived, typename ArgsTmp>
static ReturnType run(const JointDataBase<JointDataDerived> & jdata,
ArgsTmp args)
{
InternalVisitorModel<ArgsTmp> visitor(args);
return visitor(jdata.derived());
}
template<typename JointModelDerived>
static ReturnType run(const JointModelBase<JointModelDerived> & jmodel)
{
......@@ -91,6 +114,13 @@ namespace pinocchio
return visitor(jmodel.derived());
}
template<typename JointDataDerived>
static ReturnType run(const JointDataBase<JointDataDerived> & jdata)
{
InternalVisitorModel<NoArg> visitor;
return visitor(jdata.derived());
}
private:
template<typename JointModel, typename ArgType>
......@@ -155,6 +185,14 @@ namespace pinocchio
args));
}
template<typename JointDataDerived>
ReturnType operator()(const JointDataBase<JointDataDerived> & jdata) const
{
return bf::invoke(&JointVisitorDerived::template algo<JointDataDerived>,
bf::append(boost::ref(jdata.derived()),
args));
}
ReturnType operator()(const JointModelVoid) {return;}
ArgType args;
......@@ -171,6 +209,12 @@ namespace pinocchio
{
return JointVisitorDerived::template algo<JointModelDerived>(jmodel.derived());
}
template<typename JointDataDerived>
ReturnType operator()(const JointDataBase<JointDataDerived> & jdata) const
{
return JointVisitorDerived::template algo<JointDataDerived>(jdata.derived());
}
};
}; // struct JointUnaryVisitorBase
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment