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
dynamicgraph::SignalTimeDependent::displayDependencies
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
Definition: signal-time-dependent.h:86
dynamicgraph::Signal
Signals link I/O ports of entities. They can be constant-valued signals, or copy the value of a heap ...
Definition: fwd.hh:44
dynamicgraph::SignalTimeDependent::setPeriodTime
virtual void setPeriodTime(const Time &p)
Definition: signal-time-dependent.h:158
dynamicgraph::TimeDependency
A helper class for setting and specifying dependencies between signals.
Definition: fwd.hh:60
dynamicgraph::SignalTimeDependent::operator()
const T & operator()(const Time &t1)
Definition: signal-time-dependent.h:77
dynamicgraph::SignalTimeDependent::access
const T & access(const Time &t1)
Definition: signal-time-dependent.h:119
dynamicgraph
dynamicgraph::TimeDependency::displayDependencies
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
Definition: time-dependency.t.cpp:121
dynamicgraph::SignalArray_const
TODO.
Definition: fwd.hh:50
dynamicgraph::SignalTimeDependent::~SignalTimeDependent
virtual ~SignalTimeDependent()
Definition: signal-time-dependent.h:75
time-dependency.h
dynamicgraph::SignalTimeDependent::addDependency
virtual void addDependency(const SignalBase< Time > &signal)
Definition: signal-time-dependent.h:136
sig
dynamicgraph::SignalArray_const< double > sig
Definition: signal-all.cpp:25
dynamicgraph::SignalTimeDependent::removeDependency
virtual void removeDependency(const SignalBase< Time > &signal)
Definition: signal-time-dependent.h:142
dynamicgraph::SignalTimeDependent::SignalTimeDependent
SignalTimeDependent(std::string name="")
Definition: signal-time-dependent.h:102
dynamicgraph::SignalTimeDependent
A type of signal that enforces a time dependency between other signals, making sure its inputs are up...
Definition: fwd.hh:58
dynamicgraph::SignalTimeDependent::clearDependencies
virtual void clearDependencies()
Definition: signal-time-dependent.h:148
dynamicgraph::SignalTimeDependent::needUpdate
virtual bool needUpdate(const Time &t) const
Definition: signal-time-dependent.h:153
dynamicgraph::SignalBase
The base class for signals: not to be used as such.
Definition: fwd.hh:53
signal.h
compile.name
name
Definition: compile.py:23
dynamicgraph::SignalTimeDependent::writeGraph
std::ostream & writeGraph(std::ostream &os) const
Definition: signal-time-dependent.h:84
dynamicgraph::SignalTimeDependent::getPeriodTime
virtual Time getPeriodTime() const
Definition: signal-time-dependent.h:162


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38