test_dep.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 using namespace std;
18 using namespace dynamicgraph;
19 
20 template <class Res = double>
21 class DummyClass {
22  public:
23  DummyClass(void) : res(), appel(0), timedata(0) {}
24 
25  Res &fun(Res &res, int t) {
26  appel++;
27  timedata = t;
28 
29  cout << "Inside " << endl;
30  for (list<SignalTimeDependent<double, sigtime_t> *>::iterator it =
31  inputsig.begin();
32  it != inputsig.end(); ++it) {
33  cout << *(*it) << endl;
34  (*it)->access(timedata);
35  }
37  it = inputsigV.begin();
38  it != inputsigV.end(); ++it) {
39  cout << *(*it) << endl;
40  (*it)->access(timedata);
41  }
42 
43  return res = (*this)();
44  }
45 
46  list<SignalTimeDependent<double, sigtime_t> *> inputsig;
47  list<SignalTimeDependent<dynamicgraph::Vector, sigtime_t> *> inputsigV;
48 
50  inputsig.push_back(&sig);
51  }
53  inputsigV.push_back(&sig);
54  }
55 
56  Res operator()(void);
57 
58  Res res;
59  int appel;
60  int timedata;
61 };
62 
63 template <class Res>
65  return this->res;
66 }
67 
68 template <>
69 double DummyClass<double>::operator()(void) {
70  res = appel * timedata;
71  return res;
72 }
73 template <>
75  res.resize(3);
76  res.fill(appel * timedata);
77  return res;
78 }
79 
80 #include <vector>
81 int main(void) {
82  DummyClass<double> pro1, pro3, pro5;
83  DummyClass<dynamicgraph::Vector> pro2, pro4, pro6;
84 
87 
90  sig4 << sig4 << sig4 << sig6, "Sig2");
91  SignalTimeDependent<double, sigtime_t> sig3(sig2 << sig5 << sig6, "Sig3");
93  boost::bind(&DummyClass<double>::fun, pro1, _1, _2), sig2 << sig3,
94  "Sig1");
95 
96  sig2.setFunction(
97  boost::bind(&DummyClass<dynamicgraph::Vector>::fun, pro2, _1, _2));
98  sig3.setFunction(boost::bind(&DummyClass<double>::fun, pro3, _1, _2));
99  sig4.setFunction(
100  boost::bind(&DummyClass<dynamicgraph::Vector>::fun, pro4, _1, _2));
101  sig5.setFunction(boost::bind(&DummyClass<double>::fun, pro5, _1, _2));
102  sig6.setFunction(
103  boost::bind(&DummyClass<dynamicgraph::Vector>::fun, pro6, _1, _2));
104 
105  // sig1.addDependency(sig2);
106  // sig1.addDependency(sig3);
107  // sig2.addDependency(sig4);
108  // sig2.addDependency(sig4);
109  // sig2.addDependency(sig4);
110  // sig3.addDependency(sig2);
111  // sig4.addDependency(sig5);
112  // sig2.addDependency(sig6);
113  // sig3.addDependency(sig5);
114  // sig3.addDependency(sig6);
115 
116  pro1.add(sig2);
117  pro1.add(sig3);
118  pro2.add(sig4);
119  pro2.add(sig4);
120  pro2.add(sig4);
121  pro3.add(sig2);
122  pro4.add(sig5);
123  pro2.add(sig6);
124  pro3.add(sig5);
125  pro3.add(sig6);
126 
127  // sig5.setDependencyType(TimeDependency<sigtime_t>::ALWAYS_READY);
128  // sig6.setDependencyType(TimeDependency<sigtime_t>::BOOL_DEPENDENT);
129 
130  sig6.setReady();
131 
132  sig1.displayDependencies(cout) << endl;
133 
134  cout << "Needs update?" << endl << sig1.needUpdate(2) << endl;
135  sig1.access(2);
136  sig1.displayDependencies(cout) << endl;
137  sig2.access(4);
138  sig1.displayDependencies(cout) << endl;
139  sig1.access(4);
140  sig1.displayDependencies(cout) << endl;
141  sig1.needUpdate(6);
142  sig1.needUpdate(6);
143 
144  return 0;
145 }
DummyClass
Definition: test_dep.cpp:21
dynamicgraph::SignalTimeDependent::displayDependencies
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
dynamicgraph::SignalTimeDependent::access
const T & access(const Time &t1)
main
int main(void)
Definition: test_dep.cpp:81
dynamicgraph
DummyClass::add
void add(sigDouble_t &sig)
fun
dynamicgraph::Vector & fun(dynamicgraph::Vector &res, double)
Definition: test_signal.cpp:33
res
res
all-signals.h
dynamicgraph::Vector
Eigen::VectorXd Vector
linear-algebra.h
dynamicgraph::SignalTimeDependent< double, sigtime_t >
t
Transform3f t
sig
Signal< dynamicgraph::Matrix, sigtime_t > sig("matrix")
dynamicgraph::SignalTimeDependent::needUpdate
virtual bool needUpdate(const Time &t) const
DummyClass::operator()
T operator()()
Definition: test_dep.cpp:64


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