binary-op.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef SOT_CORE_BINARYOP_HH
11 #define SOT_CORE_BINARYOP_HH
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
19 
20 /* SOT */
22 #include <dynamic-graph/entity.h>
23 
24 #include <sot/core/flags.hh>
26 #include <sot/core/pool.hh>
27 
28 /* STD */
29 #include <boost/function.hpp>
30 #include <string>
31 
32 namespace dynamicgraph {
33 namespace sot {
34 
35 /* --------------------------------------------------------------------- */
36 /* --- CLASS ----------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
39 template <typename Operator>
40 class BinaryOp : public Entity {
41  Operator op;
42  typedef typename Operator::Tin1 Tin1;
43  typedef typename Operator::Tin2 Tin2;
44  typedef typename Operator::Tout Tout;
46 
47  public: /* --- CONSTRUCTION --- */
48  static std::string getTypeIn1Name(void) { return Operator::nameTypeIn1(); }
49  static std::string getTypeIn2Name(void) { return Operator::nameTypeIn2(); }
50  static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
51  static const std::string CLASS_NAME;
52  virtual const std::string &getClassName() const { return CLASS_NAME; }
53  std::string getDocString() const { return op.getDocString(); }
54 
55  BinaryOp(const std::string &name)
56  : Entity(name),
57  SIN1(NULL, BinaryOp::CLASS_NAME + "(" + name + ")::input(" +
58  getTypeIn1Name() + ")::sin1"),
59  SIN2(NULL, CLASS_NAME + "(" + name + ")::input(" + getTypeIn2Name() +
60  ")::sin2"),
61  SOUT(boost::bind(&Self::computeOperation, this, _1, _2), SIN1 << SIN2,
62  CLASS_NAME + "(" + name + ")::output(" + getTypeOutName() +
63  ")::sout") {
65  op.addSpecificCommands(*this, commandMap);
66  }
67 
68  virtual ~BinaryOp(void){};
69 
70  public: /* --- SIGNAL --- */
74 
75  protected:
76  Tout &computeOperation(Tout &res, int time) {
77  const Tin1 &x1 = SIN1(time);
78  const Tin2 &x2 = SIN2(time);
79  op(x1, x2, res);
80  return res;
81  }
82 };
83 } // namespace sot
84 } // namespace dynamicgraph
85 
86 #endif // #ifndef SOT_CORE_BINARYOP_HH
static std::string getTypeIn1Name(void)
Definition: binary-op.hh:48
virtual const std::string & getClassName() const
Definition: binary-op.hh:52
static std::string getTypeIn2Name(void)
Definition: binary-op.hh:49
void signalRegistration(const SignalArray< int > &signals)
BinaryOp< Operator > Self
Definition: binary-op.hh:45
BinaryOp(const std::string &name)
Definition: binary-op.hh:55
x2
SignalPtr< Tin1, int > SIN1
Definition: binary-op.hh:68
CommandMap_t commandMap
static std::string getTypeOutName(void)
Definition: binary-op.hh:50
SignalPtr< Tin2, int > SIN2
Definition: binary-op.hh:72
std::string getDocString() const
Definition: binary-op.hh:53
SignalTimeDependent< Tout, int > SOUT
Definition: binary-op.hh:73
static const std::string CLASS_NAME
Definition: binary-op.hh:51
Tout & computeOperation(Tout &res, int time)
Definition: binary-op.hh:76


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26