sot-core  4.11.2
Hierarchical task solver plug-in for dynamic-graph.
unary-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_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> class UnaryOp : public Entity {
29  Operator op;
30  typedef typename Operator::Tin Tin;
31  typedef typename Operator::Tout Tout;
32  typedef UnaryOp<Operator> Self;
33 
34 public: /* --- CONSTRUCTION --- */
35  static std::string getTypeInName(void) { return Operator::nameTypeIn(); }
36  static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
37  static const std::string CLASS_NAME;
38 
39  virtual const std::string &getClassName() const { return CLASS_NAME; }
40 
41  std::string getDocString() const { return op.getDocString(); }
42 
43  UnaryOp(const std::string &name)
44  : Entity(name), SIN(NULL, Self::CLASS_NAME + "(" + name + ")::input(" +
45  Self::getTypeInName() + ")::sin"),
46  SOUT(boost::bind(&Self::computeOperation, this, _1, _2), SIN,
47  Self::CLASS_NAME + "(" + name + ")::output(" +
48  Self::getTypeOutName() + ")::sout") {
49  signalRegistration(SIN << SOUT);
50  op.addSpecificCommands(*this, commandMap);
51  }
52 
53  virtual ~UnaryOp(void){};
54 
55 public: /* --- SIGNAL --- */
56  SignalPtr<Tin, int> SIN;
57  SignalTimeDependent<Tout, int> SOUT;
58 
59 protected:
60  Tout &computeOperation(Tout &res, int time) {
61  const Tin &x1 = SIN(time);
62  op(x1, res);
63  return res;
64  }
65 
66 public: /* --- PARAMS --- */
67 };
68 } /* namespace sot */
69 } /* namespace dynamicgraph */
70 
71 #endif // #ifndef SOT_CORE_UNARYOP_HH
virtual ~UnaryOp(void)
Definition: unary-op.hh:53
UnaryOp(const std::string &name)
Definition: unary-op.hh:43
static std::string getTypeOutName(void)
Definition: unary-op.hh:36
SignalPtr< Tin, int > SIN
Definition: unary-op.hh:53
static std::string getTypeInName(void)
Definition: unary-op.hh:35
static const std::string CLASS_NAME
Definition: unary-op.hh:37
Definition: unary-op.hh:28
virtual const std::string & getClassName() const
Definition: unary-op.hh:39
std::string getDocString() const
Definition: unary-op.hh:41
Definition: abstract-sot-external-interface.hh:17
Tout & computeOperation(Tout &res, int time)
Definition: unary-op.hh:60
SignalTimeDependent< Tout, int > SOUT
Definition: unary-op.hh:57