GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/sot/core/binary-op.hh Lines: 0 15 0.0 %
Date: 2023-03-13 12:09:37 Branches: 0 86 0.0 %

Line Branch Exec Source
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 */
18
#include <dynamic-graph/linear-algebra.h>
19
20
/* SOT */
21
#include <dynamic-graph/all-signals.h>
22
#include <dynamic-graph/entity.h>
23
24
#include <sot/core/flags.hh>
25
#include <sot/core/matrix-geometry.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;
45
  typedef BinaryOp<Operator> Self;
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") {
64
    signalRegistration(SIN1 << SIN2 << SOUT);
65
    op.addSpecificCommands(*this, commandMap);
66
  }
67
68
  virtual ~BinaryOp(void){};
69
70
 public: /* --- SIGNAL --- */
71
  SignalPtr<Tin1, int> SIN1;
72
  SignalPtr<Tin2, int> SIN2;
73
  SignalTimeDependent<Tout, int> SOUT;
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