joint-unary-visitor.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_visitior_joint_unary_visitor_hpp__
6 #define __pinocchio_multibody_visitior_joint_unary_visitor_hpp__
7 
8 #include <boost/variant.hpp>
9 
10 #include "pinocchio/multibody/joint/joint-base.hpp"
11 #include "pinocchio/multibody/visitor/fusion.hpp"
12 
13 namespace pinocchio
14 {
15  namespace fusion
16  {
17  namespace bf = boost::fusion;
18 
19  typedef boost::blank NoArg;
20 
26  template<typename JointVisitorDerived, typename ReturnType = void>
28  {
29 
30  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
31  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel,
33  ArgsTmp args)
34  {
35  InternalVisitorModelAndData<JointModelTpl<Scalar,Options,JointCollectionTpl>,ArgsTmp> visitor(jdata,args);
36  return boost::apply_visitor(visitor,jmodel);
37  }
38 
39  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
40  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel,
42  {
43  InternalVisitorModelAndData<JointModelTpl<Scalar,Options,JointCollectionTpl>,NoArg> visitor(jdata);
44  return boost::apply_visitor(visitor,jmodel);
45  }
46 
47  template<typename JointModelDerived, typename ArgsTmp>
48  static ReturnType run(const JointModelBase<JointModelDerived> & jmodel,
50  ArgsTmp args)
51  {
52  InternalVisitorModelAndData<JointModelDerived,ArgsTmp> visitor(jdata,args);
53  return visitor(jmodel.derived());
54  }
55 
56  template<typename JointModelDerived>
57  static ReturnType run(const JointModelBase<JointModelDerived> & jmodel,
59  {
60  InternalVisitorModelAndData<JointModelDerived,NoArg> visitor(jdata);
61  return visitor(jmodel.derived());
62  }
63 
64  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
65  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel,
66  ArgsTmp args)
67  {
68  InternalVisitorModel<ArgsTmp> visitor(args);
69  return boost::apply_visitor(visitor,jmodel);
70  }
71 
72  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
73  static ReturnType run(const JointDataTpl<Scalar,Options,JointCollectionTpl> & jdata,
74  ArgsTmp args)
75  {
76  InternalVisitorModel<ArgsTmp> visitor(args);
77  return boost::apply_visitor(visitor,jdata);
78  }
79 
80  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
81  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel)
82  {
83  InternalVisitorModel<NoArg> visitor;
84  return boost::apply_visitor(visitor,jmodel);
85  }
86 
87  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
88  static ReturnType run(const JointDataTpl<Scalar,Options,JointCollectionTpl> & jdata)
89  {
90  InternalVisitorModel<NoArg> visitor;
91  return boost::apply_visitor(visitor,jdata);
92  }
93 
94  template<typename JointModelDerived, typename ArgsTmp>
95  static ReturnType run(const JointModelBase<JointModelDerived> & jmodel,
96  ArgsTmp args)
97  {
98  InternalVisitorModel<ArgsTmp> visitor(args);
99  return visitor(jmodel.derived());
100  }
101 
102  template<typename JointDataDerived, typename ArgsTmp>
103  static ReturnType run(const JointDataBase<JointDataDerived> & jdata,
104  ArgsTmp args)
105  {
106  InternalVisitorModel<ArgsTmp> visitor(args);
107  return visitor(jdata.derived());
108  }
109 
110  template<typename JointModelDerived>
111  static ReturnType run(const JointModelBase<JointModelDerived> & jmodel)
112  {
113  InternalVisitorModel<NoArg> visitor;
114  return visitor(jmodel.derived());
115  }
116 
117  template<typename JointDataDerived>
118  static ReturnType run(const JointDataBase<JointDataDerived> & jdata)
119  {
120  InternalVisitorModel<NoArg> visitor;
121  return visitor(jdata.derived());
122  }
123 
124  private:
125 
126  template<typename JointModel, typename ArgType>
128  : public boost::static_visitor<ReturnType>
129  {
130  typedef typename JointModel::JointDataDerived JointData;
131 
132  InternalVisitorModelAndData(JointData & jdata, ArgType args)
133  : jdata(jdata), args(args)
134  {}
135 
136  template<typename JointModelDerived>
137  ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
138  {
139  return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
140  bf::append(boost::ref(jmodel.derived()),
141  boost::ref(boost::get<typename JointModelBase<JointModelDerived>::JointDataDerived >(jdata)),
142  args));
143  }
144 
145  ReturnType operator()(const JointModelVoid) {return;}
146 
147  JointData & jdata;
148  ArgType args;
149  };
150 
151  template<typename JointModel>
153  : public boost::static_visitor<ReturnType>
154  {
155  typedef typename JointModel::JointDataDerived JointData;
156 
158  : jdata(jdata)
159  {}
160 
161  template<typename JointModelDerived>
162  ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
163  {
164  return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
165  bf::make_vector(boost::ref(jmodel.derived()),
166  boost::ref(boost::get<typename JointModelBase<JointModelDerived>::JointDataDerived >(jdata))));
167  }
168 
169  JointData & jdata;
170  };
171 
172  template<typename ArgType, typename Dummy = void>
174  : public boost::static_visitor<ReturnType>
175  {
177  : args(args)
178  {}
179 
180  template<typename JointModelDerived>
181  ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
182  {
183  return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived>,
184  bf::append(boost::ref(jmodel.derived()),
185  args));
186  }
187 
188  template<typename JointDataDerived>
190  {
191  return bf::invoke(&JointVisitorDerived::template algo<JointDataDerived>,
192  bf::append(boost::ref(jdata.derived()),
193  args));
194  }
195 
196  ReturnType operator()(const JointModelVoid) {return;}
197 
198  ArgType args;
199  };
200 
201  template<typename Dummy>
202  struct InternalVisitorModel<NoArg,Dummy>
203  : public boost::static_visitor<ReturnType>
204  {
206 
207  template<typename JointModelDerived>
208  ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
209  {
210  return JointVisitorDerived::template algo<JointModelDerived>(jmodel.derived());
211  }
212 
213  template<typename JointDataDerived>
215  {
216  return JointVisitorDerived::template algo<JointDataDerived>(jdata.derived());
217  }
218  };
219  }; // struct JointUnaryVisitorBase
220 
224  template<typename JointVisitorDerived, typename ReturnType = void>
225  struct PINOCCHIO_DEPRECATED JointVisitorBase
226  : JointUnaryVisitorBase<JointVisitorDerived,ReturnType>
227  {
229  using Base::run;
230  };
231 
232  } // namespace fusion
233 } // namespace pinocchio
234 
235 #endif // ifndef __pinocchio_multibody_visitior_joint_unary_visitor_hpp__
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
Definition: fusion.hpp:24
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
static ReturnType run(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
ReturnType operator()(const JointDataBase< JointDataDerived > &jdata) const
ReturnType operator()(const JointDataBase< JointDataDerived > &jdata) const
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, ArgsTmp args)
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
JointUnaryVisitorBase< JointVisitorDerived, ReturnType > Base
static ReturnType run(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, ArgsTmp args)
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, ArgsTmp args)
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
static ReturnType run(const JointDataBase< JointDataDerived > &jdata)
Base structure for Unary visitation of a JointModel. This structure provides runners to call the righ...
static ReturnType run(const JointDataBase< JointDataDerived > &jdata, ArgsTmp args)
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel)
This helper structure is now deprecated and has been replaced by JointUnaryVisitorBase.
JointModelDerived & derived()
Main pinocchio namespace.
Definition: timings.cpp:28
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, typename JointModelBase< JointModelDerived >::JointDataDerived &jdata, ArgsTmp args)
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, typename JointModelBase< JointModelDerived >::JointDataDerived &jdata)
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, ArgsTmp args)


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:31