binary-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_BINARYOP_HH
11 #define SOT_CORE_BINARYOP_HH
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
19 
20 /* SOT */
22 #include <dynamic-graph/entity.h>
23 
24 #include <sot/core/flags.hh>
26 #include <sot/core/pool.hh>
27 
28 /* STD */
29 #include <boost/function.hpp>
30 #include <string>
31 
32 namespace dynamicgraph {
33 namespace sot {
34 
35 /* --------------------------------------------------------------------- */
36 /* --- CLASS ----------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
39 template <typename Operator>
40 class BinaryOp : public Entity {
41  Operator op;
42  typedef typename Operator::Tin1 Tin1;
43  typedef typename Operator::Tin2 Tin2;
44  typedef typename Operator::Tout Tout;
46 
47  public: /* --- CONSTRUCTION --- */
48  static std::string getTypeIn1Name(void) { return Operator::nameTypeIn1(); }
49  static std::string getTypeIn2Name(void) { return Operator::nameTypeIn2(); }
50  static std::string getTypeOutName(void) { return Operator::nameTypeOut(); }
51  static const std::string CLASS_NAME;
52  virtual const std::string &getClassName() const { return CLASS_NAME; }
53  std::string getDocString() const { return op.getDocString(); }
54 
55  BinaryOp(const std::string &name)
56  : Entity(name),
57  SIN1(NULL, BinaryOp::CLASS_NAME + "(" + name + ")::input(" +
58  getTypeIn1Name() + ")::sin1"),
59  SIN2(NULL, CLASS_NAME + "(" + name + ")::input(" + getTypeIn2Name() +
60  ")::sin2"),
61  SOUT(boost::bind(&Self::computeOperation, this, _1, _2), SIN1 << SIN2,
62  CLASS_NAME + "(" + name + ")::output(" + getTypeOutName() +
63  ")::sout") {
65  op.addSpecificCommands(*this, commandMap);
66  }
67 
68  virtual ~BinaryOp(void){};
69 
70  public: /* --- SIGNAL --- */
74 
75  protected:
77  const Tin1 &x1 = SIN1(time);
78  const Tin2 &x2 = SIN2(time);
79  op(x1, x2, res);
80  return res;
81  }
82 };
83 } // namespace sot
84 } // namespace dynamicgraph
85 
86 #endif // #ifndef SOT_CORE_BINARYOP_HH
dynamicgraph::sot::BinaryOp::Tout
Operator::Tout Tout
Definition: binary-op.hh:44
dynamicgraph::sot::BinaryOp::BinaryOp
BinaryOp(const std::string &name)
Definition: binary-op.hh:55
dynamicgraph::sot::BinaryOp::computeOperation
Tout & computeOperation(Tout &res, sigtime_t time)
Definition: binary-op.hh:76
dynamicgraph::SignalPtr< Tin1, sigtime_t >
dynamicgraph
dynamicgraph::Entity::commandMap
CommandMap_t commandMap
x2
x2
dynamicgraph::Entity
boost
dynamicgraph::sot::BinaryOp::SIN2
SignalPtr< Tin2, sigtime_t > SIN2
Definition: binary-op.hh:72
dynamicgraph::Entity::name
std::string name
dynamicgraph::sot::BinaryOp::getTypeIn1Name
static std::string getTypeIn1Name(void)
Definition: binary-op.hh:48
res
res
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::BinaryOp::getDocString
std::string getDocString() const
Definition: binary-op.hh:53
dynamicgraph::sot::BinaryOp
Definition: binary-op.hh:40
dynamicgraph::sot::BinaryOp::Tin2
Operator::Tin2 Tin2
Definition: binary-op.hh:43
dynamicgraph::sot::BinaryOp::op
Operator op
Definition: binary-op.hh:41
dynamicgraph::sot::BinaryOp::SIN1
SignalPtr< Tin1, sigtime_t > SIN1
Definition: binary-op.hh:68
dynamicgraph::sot::BinaryOp::~BinaryOp
virtual ~BinaryOp(void)
Definition: binary-op.hh:68
dynamicgraph::sot::BinaryOp::Tin1
Operator::Tin1 Tin1
Definition: binary-op.hh:42
all-signals.h
dynamicgraph::sot::BinaryOp::Self
BinaryOp< Operator > Self
Definition: binary-op.hh:45
flags.hh
linear-algebra.h
pool.hh
dynamicgraph::sot::BinaryOp::getTypeOutName
static std::string getTypeOutName(void)
Definition: binary-op.hh:50
matrix-geometry.hh
dynamicgraph::SignalTimeDependent< Tout, sigtime_t >
dynamicgraph::sot::BinaryOp::getClassName
virtual const std::string & getClassName() const
Definition: binary-op.hh:52
dynamicgraph::sot::BinaryOp::CLASS_NAME
static const std::string CLASS_NAME
Definition: binary-op.hh:51
dynamicgraph::sot::BinaryOp::getTypeIn2Name
static std::string getTypeIn2Name(void)
Definition: binary-op.hh:49
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
dynamicgraph::sot::BinaryOp::SOUT
SignalTimeDependent< Tout, sigtime_t > SOUT
Definition: binary-op.hh:73


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31