signal-time-dependent.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 // Copyright 2010, Fran├žois Bleibel, Thomas Moulard, Olivier Stasse,
3 // JRL, CNRS/AIST.
4 //
5 
6 #ifndef DYNAMIC_GRAPH_SIGNAL_TIME_DEPENDENT_H
7 #define DYNAMIC_GRAPH_SIGNAL_TIME_DEPENDENT_H
8 #include <dynamic-graph/signal.h>
10 
11 namespace dynamicgraph {
62 template <class T, class Time>
63 class SignalTimeDependent : public virtual Signal<T, Time>,
64  public TimeDependency<Time> {
65  // TimeDependency<Time> timeDependency;
66 
67  public:
68  SignalTimeDependent(std::string name = "");
69  SignalTimeDependent(const SignalArray_const<Time> &arr,
70  std::string name = "");
71  SignalTimeDependent(boost::function2<T &, T &, Time> t,
72  const SignalArray_const<Time> &sig,
73  std::string name = "");
74 
75  virtual ~SignalTimeDependent() {}
76 
77  inline const T &operator()(const Time &t1) { return access(t1); }
78  const T &access(const Time &t1);
79 
80  virtual void addDependency(const SignalBase<Time> &signal);
81  virtual void removeDependency(const SignalBase<Time> &signal);
82  virtual void clearDependencies();
83 
84  std::ostream &writeGraph(std::ostream &os) const { return os; }
85 
86  std::ostream &displayDependencies(std::ostream &os, const int depth = -1,
87  std::string space = "",
88  std::string next1 = "",
89  std::string next2 = "") const {
90  return TimeDependency<Time>::displayDependencies(os, depth, space, next1,
91  next2);
92  }
93 
94  virtual bool needUpdate(const Time &t) const;
95  virtual void setPeriodTime(const Time &p);
96  virtual Time getPeriodTime() const;
97 };
98 
99 /* -------------------------------------------- */
100 
101 template <class T, class Time>
103  : Signal<T, Time>(name), TimeDependency<Time>(this) {}
104 
105 template <class T, class Time>
107  const SignalArray_const<Time> &arr, std::string name)
108  : Signal<T, Time>(name), TimeDependency<Time>(this, arr) {}
109 
110 template <class T, class Time>
112  boost::function2<T &, T &, Time> t, const SignalArray_const<Time> &sig,
113  std::string name)
114  : Signal<T, Time>(name), TimeDependency<Time>(this, sig) {
115  this->setFunction(t);
116 }
117 
118 template <class T, class Time>
119 const T &SignalTimeDependent<T, Time>::access(const Time &t1) {
120  const bool up = TimeDependency<Time>::needUpdate(t1);
121  // SignalBase<Time>::setReady(false);
122 
123  /* std::cout << "Time before: "<< signalTime << " -- " */
124  /* << t1<< " -> Up: "<<up <<std::endl ; */
125  if (up) {
127  const T &Tres = Signal<T, Time>::access(t1);
129  return Tres;
130  } else {
132  }
133 }
134 
135 template <class T, class Time>
137  const SignalBase<Time> &signal) {
139 }
140 
141 template <class T, class Time>
143  const SignalBase<Time> &signal) {
145 }
146 
147 template <class T, class Time>
150 }
151 
152 template <class T, class Time>
153 bool SignalTimeDependent<T, Time>::needUpdate(const Time &t) const {
155 }
156 
157 template <class T, class Time>
160 }
161 template <class T, class Time>
164 }
165 
166 } // end of namespace dynamicgraph
167 
168 #endif
const T & operator()(const Time &t1)
std::ostream & writeGraph(std::ostream &os) const
A helper class for setting and specifying dependencies between signals.
Definition: fwd.hh:58
A type of signal that enforces a time dependency between other signals, making sure its inputs are up...
Definition: fwd.hh:56
dynamicgraph::SignalArray_const< double > sig
Definition: signal-all.cpp:25
Signals link I/O ports of entities. They can be constant-valued signals, or copy the value of a heap ...
Definition: fwd.hh:42
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
The base class for signals: not to be used as such.
Definition: fwd.hh:51
virtual void removeDependency(const SignalBase< Time > &signal)
virtual void addDependency(const SignalBase< Time > &signal)
virtual bool needUpdate(const Time &t) const
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
virtual void setPeriodTime(const Time &p)


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03