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 */
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;
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") {
52  op.addSpecificCommands(*this, commandMap);
53  }
54 
55  virtual ~UnaryOp(void){};
56 
57  public: /* --- SIGNAL --- */
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
void signalRegistration(const SignalArray< int > &signals)
virtual ~UnaryOp(void)
Definition: unary-op.hh:55
UnaryOp(const std::string &name)
Definition: unary-op.hh:44
static std::string getTypeOutName(void)
Definition: unary-op.hh:37
SignalPtr< Tin, int > SIN
Definition: unary-op.hh:55
static std::string getTypeInName(void)
Definition: unary-op.hh:36
CommandMap_t commandMap
static const std::string CLASS_NAME
Definition: unary-op.hh:38
virtual const std::string & getClassName() const
Definition: unary-op.hh:40
UnaryOp< Operator > Self
Definition: unary-op.hh:33
std::string getDocString() const
Definition: unary-op.hh:42
Operator::Tout Tout
Definition: unary-op.hh:32
Tout & computeOperation(Tout &res, int time)
Definition: unary-op.hh:62
SignalTimeDependent< Tout, int > SOUT
Definition: unary-op.hh:59


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26