test_ptr.cpp
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 /* -------------------------------------------------------------------------- */
11 /* --- INCLUDES ------------------------------------------------------------- */
12 /* -------------------------------------------------------------------------- */
15 
16 #include <iostream>
17 #include <sot/core/debug.hh>
20 
21 using namespace std;
22 using namespace dynamicgraph::sot;
23 using namespace dynamicgraph;
24 
25 template <class Res = double>
26 class DummyClass {
27  public:
28  DummyClass(void) : res(), appel(0), timedata(0) {}
29 
30  Res &fun(Res &res, int t) {
31  appel++;
32  timedata = t;
33 
34  sotDEBUG(5) << "Inside " << typeid(Res).name() << endl;
35  for (list<SignalTimeDependent<double, sigtime_t> *>::iterator it =
36  inputsig.begin();
37  it != inputsig.end(); ++it) {
38  sotDEBUG(5) << *(*it) << endl;
39  (*it)->access(timedata);
40  }
42  it = inputsigV.begin();
43  it != inputsigV.end(); ++it) {
44  sotDEBUG(5) << *(*it) << endl;
45  (*it)->access(timedata);
46  }
47 
48  return res = (*this)();
49  }
50 
51  list<SignalTimeDependent<double, sigtime_t> *> inputsig;
52  list<SignalTimeDependent<dynamicgraph::Vector, sigtime_t> *> inputsigV;
53 
55  inputsig.push_back(&sig);
56  }
58  inputsigV.push_back(&sig);
59  }
60 
61  Res operator()(void);
62 
63  Res res;
64  int appel;
65  int timedata;
66 };
67 
68 template <class Res>
70  return this->res;
71 }
72 
73 template <>
74 double DummyClass<double>::operator()(void) {
75  res = appel * timedata;
76  return res;
77 }
78 template <>
80  res.resize(3);
81  res.fill(appel * timedata);
82  return res;
83 }
84 template <>
86  res.angle() = 0.26;
87  res.axis() = Eigen::Vector3d::UnitX();
88  return res;
89 }
90 
91 void funtest(dynamicgraph::Vector & /*v*/) {}
92 
93 #include <vector>
94 int main(void) {
97  SignalPtr<Eigen::AngleAxisd, sigtime_t> sigTo3(NULL, "SigTo3");
99  VectorUTheta v3;
100  funtest(v);
101 
102  sig3.setFunction(boost::bind(&DummyClass<VectorUTheta>::fun, pro3, _1, _2));
103  try {
104  sigTo3.plug(&sig3);
105  } catch (sot::ExceptionAbstract &e) {
106  cout << "Plugin error " << e << endl;
107  exit(1);
108  }
109  sig3.access(1);
110  sig3.setReady();
111  sigTo3.access(2);
112  cout << sigTo3.access(2);
113 
114  return 0;
115 }
DummyClass
Definition: test_dep.cpp:21
dynamicgraph::SignalTimeDependent::access
const T & access(const Time &t1)
dynamicgraph::sot::ExceptionAbstract
Definition: exception-abstract.hh:37
dynamicgraph::SignalPtr
dynamicgraph
dynamicgraph::SignalPtr::plug
virtual void plug(SignalBase< Time > *ref)
fun
dynamicgraph::Vector & fun(dynamicgraph::Vector &res, double)
Definition: test_signal.cpp:33
main
int main(void)
Definition: test_ptr.cpp:94
debug.hh
res
res
funtest
void funtest(dynamicgraph::Vector &)
Definition: test_ptr.cpp:91
dynamicgraph::SignalPtr::access
virtual const T & access(const Time &t)
all-signals.h
dynamicgraph::Vector
Eigen::VectorXd Vector
linear-algebra.h
matrix-geometry.hh
dynamicgraph::SignalTimeDependent< double, sigtime_t >
dynamicgraph::sot
v
v
exception-abstract.hh
t
Transform3f t
sig
Signal< dynamicgraph::Matrix, sigtime_t > sig("matrix")
sotNOSIGNAL
DYNAMIC_GRAPH_DLLAPI SignalArray< sigtime_t > sotNOSIGNAL
DummyClass::operator()
T operator()()
Definition: test_dep.cpp:64
compile.name
name
Definition: compile.py:23
VectorUTheta
Eigen::AngleAxis< double > VectorUTheta
sotDEBUG
#define sotDEBUG(level)
Definition: debug.hh:168


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