sot-core  4.11.8
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>
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  static std::string getTypeInName(void) { return Operator::nameTypeIn(); }
37  static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
38  static const std::string CLASS_NAME;
39 
40  virtual const std::string &getClassName() const { return CLASS_NAME; }
41 
42  std::string getDocString() const { return op.getDocString(); }
43 
44  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  Self::getTypeOutName() + ")::sout") {
51  signalRegistration(SIN << SOUT);
52  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
Definition: unary-op.hh:29
Tout & computeOperation(Tout &res, int time)
Definition: unary-op.hh:62
static const std::string CLASS_NAME
Definition: unary-op.hh:38
UnaryOp(const std::string &name)
Definition: unary-op.hh:44
static std::string getTypeOutName(void)
Definition: unary-op.hh:37
static std::string getTypeInName(void)
Definition: unary-op.hh:36
SignalTimeDependent< Tout, int > SOUT
Definition: unary-op.hh:59
std::string getDocString() const
Definition: unary-op.hh:42
virtual ~UnaryOp(void)
Definition: unary-op.hh:55
virtual const std::string & getClassName() const
Definition: unary-op.hh:40
SignalPtr< Tin, int > SIN
Definition: unary-op.hh:55
Definition: abstract-sot-external-interface.hh:17