6 #ifndef __pinocchio_visitor_hpp__ 7 #define __pinocchio_visitor_hpp__ 9 #define BOOST_FUSION_INVOKE_MAX_ARITY 10 11 #include <boost/variant.hpp> 12 #include <boost/fusion/include/invoke.hpp> 13 #include <boost/fusion/container/generation/make_vector.hpp> 15 #include "pinocchio/multibody/joint/joint-base.hpp" 23 template<
typename T,
typename V>
24 typename result_of::push_front<V const, T>::type
25 append(T
const& t,V
const& v)
26 {
return push_front(v,t); }
29 template<
typename T1,
typename T2,
typename V>
30 typename result_of::push_front<typename result_of::push_front<V const, T2>::type
const, T1>::type
31 append2(T1
const& t1,T2
const& t2,V
const& v)
32 {
return push_front(push_front(v,t2),t1); }
43 typedef boost::blank NoArg;
45 template<
typename Jo
intVisitorDerived,
typename ReturnType =
void>
49 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ArgsTmp>
54 InternalVisitor<JointModelTpl<Scalar,Options,JointCollectionTpl>,ArgsTmp> visitor(jdata,args);
55 return boost::apply_visitor(visitor,jmodel);
58 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl>
62 InternalVisitor<JointModelTpl<Scalar,Options,JointCollectionTpl>,NoArg> visitor(jdata);
63 return boost::apply_visitor(visitor,jmodel);
66 template<
typename Jo
intModelDerived,
typename ArgsTmp>
71 InternalVisitor<JointModelDerived,ArgsTmp> visitor(jdata,args);
72 return visitor(jmodel.derived());
75 template<
typename Jo
intModelDerived>
79 InternalVisitor<JointModelDerived,NoArg> visitor(jdata);
80 return visitor(jmodel.derived());
83 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ArgsTmp>
87 ModelOnlyInternalVisitor<ArgsTmp> visitor(args);
88 return boost::apply_visitor(visitor,jmodel);
91 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl>
94 ModelOnlyInternalVisitor<NoArg> visitor;
95 return boost::apply_visitor(visitor,jmodel);
98 template<
typename Jo
intModelDerived,
typename ArgsTmp>
102 ModelOnlyInternalVisitor<ArgsTmp> visitor(args);
103 return visitor(jmodel.derived());
106 template<
typename Jo
intModelDerived>
109 ModelOnlyInternalVisitor<NoArg> visitor;
110 return visitor(jmodel.derived());
115 template<
typename Jo
intModel,
typename ArgType>
116 struct InternalVisitor
117 :
public boost::static_visitor<ReturnType>
119 typedef typename JointModel::JointDataDerived
JointData;
121 InternalVisitor(JointData & jdata, ArgType args)
122 : jdata(jdata), args(args)
125 template<
typename Jo
intModelDerived>
128 return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
129 bf::append2(boost::ref(jmodel),
140 template<
typename Jo
intModel>
141 struct InternalVisitor<JointModel,NoArg>
142 :
public boost::static_visitor<ReturnType>
144 typedef typename JointModel::JointDataDerived
JointData;
146 InternalVisitor(JointData & jdata)
150 template<
typename Jo
intModelDerived>
153 return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
154 bf::make_vector(boost::ref(jmodel),
162 template<
typename ArgType,
typename Dummy =
void>
163 struct ModelOnlyInternalVisitor :
public boost::static_visitor<ReturnType>
165 ModelOnlyInternalVisitor(ArgType args)
169 template<
typename Jo
intModelDerived>
172 return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
173 bf::append(boost::ref(jmodel),
182 template<
typename Dummy>
183 struct ModelOnlyInternalVisitor<NoArg,Dummy>
184 :
public boost::static_visitor<ReturnType>
186 ModelOnlyInternalVisitor() {}
188 template<
typename Jo
intModelDerived>
191 return JointVisitorDerived::template algo<JointModelDerived>(jmodel);
200 #endif // ifndef __pinocchio_visitor_hpp__
Main pinocchio namespace.