Newer
Older
//
// Copyright (c) 2015 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.

Nicolas Mansard
committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef __se3_visitor_hpp__
#define __se3_visitor_hpp__
#define BOOST_FUSION_INVOKE_MAX_ARITY 10
#include <boost/fusion/include/invoke.hpp>
#include <boost/fusion/include/algorithm.hpp>
namespace boost {
namespace fusion {
template<typename T,typename V>
typename result_of::push_front<V const, T>::type
append(T const& t,V const& v) { return push_front(v,t); }
template<typename T1,typename T2,typename V>
typename result_of::push_front<typename result_of::push_front<V const, T2>::type const, T1>::type
append2(T1 const& t1,T2 const& t2,V const& v) { return push_front(push_front(v,t2),t1); }
}
}
namespace se3
{
namespace fusion
{
namespace bf = boost::fusion;
template<typename Visitor>
struct JointVisitor : public boost::static_visitor<>
{
template<typename D>
void operator() (const JointModelBase<D> & jmodel) const
{
JointDataVariant& jdataSpec = static_cast<const Visitor*>(this)->jdata;
bf::invoke(&Visitor::template algo<D>,
bf::append2(jmodel,
boost::ref(boost::get<typename D::JointData>(jdataSpec)),

Nicolas Mansard
committed
static_cast<const Visitor*>(this)->args));
}
template<typename ArgsTmp>
static void run(const JointModelVariant & jmodel,
JointDataVariant & jdata,
ArgsTmp args)
{
return boost::apply_visitor( Visitor(jdata,args),jmodel );
}
};
} // namespace fusion
} // namespace se3
#define JOINT_VISITOR_INIT(VISITOR) \
VISITOR( JointDataVariant & jdata,ArgsType args ) : jdata(jdata),args(args) {} \
using se3::fusion::JointVisitor< VISITOR >::run; \

Nicolas Mansard
committed
JointDataVariant & jdata; \
ArgsType args
#endif // ifndef __se3_visitor_hpp__