GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/sot/core/unary-op.hh Lines: 8 13 61.5 %
Date: 2023-03-13 12:09:37 Branches: 37 57 64.9 %

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_UNARYOP_HH
11
#define SOT_CORE_UNARYOP_HH
12
13
/* --------------------------------------------------------------------- */
14
/* --- INCLUDE --------------------------------------------------------- */
15
/* --------------------------------------------------------------------- */
16
17
/* SOT */
18
#include <dynamic-graph/all-signals.h>
19
#include <dynamic-graph/entity.h>
20
21
/* --------------------------------------------------------------------- */
22
/* --- CLASS ----------------------------------------------------------- */
23
/* --------------------------------------------------------------------- */
24
25
namespace dynamicgraph {
26
namespace sot {
27
28
template <typename Operator>
29
class UnaryOp : public Entity {
30
  Operator op;
31
  typedef typename Operator::Tin Tin;
32
  typedef typename Operator::Tout Tout;
33
  typedef UnaryOp<Operator> Self;
34
35
 public: /* --- CONSTRUCTION --- */
36
12
  static std::string getTypeInName(void) { return Operator::nameTypeIn(); }
37
6
  static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
38
  static const std::string CLASS_NAME;
39
40
6
  virtual const std::string &getClassName() const { return CLASS_NAME; }
41
42
4
  std::string getDocString() const { return op.getDocString(); }
43
44
6
  UnaryOp(const std::string &name)
45
      : Entity(name),
46
        SIN(NULL, Self::CLASS_NAME + "(" + name + ")::input(" +
47
                      Self::getTypeInName() + ")::sin"),
48
        SOUT(boost::bind(&Self::computeOperation, this, _1, _2), SIN,
49
             Self::CLASS_NAME + "(" + name + ")::output(" +
50












6
                 Self::getTypeOutName() + ")::sout") {
51

6
    signalRegistration(SIN << SOUT);
52
6
    op.addSpecificCommands(*this, commandMap);
53
  }
54
55
  virtual ~UnaryOp(void){};
56
57
 public: /* --- SIGNAL --- */
58
  SignalPtr<Tin, int> SIN;
59
  SignalTimeDependent<Tout, int> SOUT;
60
61
 protected:
62
  Tout &computeOperation(Tout &res, int time) {
63
    const Tin &x1 = SIN(time);
64
    op(x1, res);
65
    return res;
66
  }
67
68
 public: /* --- PARAMS --- */
69
};
70
} /* namespace sot */
71
} /* namespace dynamicgraph */
72
73
#endif  // #ifndef SOT_CORE_UNARYOP_HH