-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathunary-op.hh
73 lines (58 loc) · 2.09 KB
/
unary-op.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef SOT_CORE_UNARYOP_HH
#define SOT_CORE_UNARYOP_HH
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* SOT */
#include <dynamic-graph/all-signals.h>
#include <dynamic-graph/entity.h>
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
template <typename Operator>
class UnaryOp : public Entity {
Operator op;
typedef typename Operator::Tin Tin;
typedef typename Operator::Tout Tout;
typedef UnaryOp<Operator> Self;
public: /* --- CONSTRUCTION --- */
static std::string getTypeInName(void) { return Operator::nameTypeIn(); }
static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
std::string getDocString() const { return op.getDocString(); }
UnaryOp(const std::string &name)
: Entity(name),
SIN(NULL, Self::CLASS_NAME + "(" + name + ")::input(" +
Self::getTypeInName() + ")::sin"),
SOUT(boost::bind(&Self::computeOperation, this, _1, _2), SIN,
Self::CLASS_NAME + "(" + name + ")::output(" +
Self::getTypeOutName() + ")::sout") {
signalRegistration(SIN << SOUT);
op.addSpecificCommands(*this, commandMap);
}
virtual ~UnaryOp(void) {};
public: /* --- SIGNAL --- */
SignalPtr<Tin, sigtime_t> SIN;
SignalTimeDependent<Tout, sigtime_t> SOUT;
protected:
Tout &computeOperation(Tout &res, sigtime_t time) {
const Tin &x1 = SIN(time);
op(x1, res);
return res;
}
public: /* --- PARAMS --- */
};
} /* namespace sot */
} /* namespace dynamicgraph */
#endif // #ifndef SOT_CORE_UNARYOP_HH