6 #ifndef DYNAMIC_GRAPH_TIME_DEPENDENCY_H 7 #define DYNAMIC_GRAPH_TIME_DEPENDENCY_H 10 #include <dynamic-graph/fwd.hh> 11 #include <dynamic-graph/signal-array.h> 12 #include <dynamic-graph/signal-base.h> 18 template <
class Time>
class TimeDependency {
20 enum DependencyType { TIME_DEPENDENT, BOOL_DEPENDENT, ALWAYS_READY };
22 mutable Time lastAskForUpdate;
25 SignalBase<Time> &leader;
27 typedef std::list<const SignalBase<Time> *> Dependencies;
28 static const DependencyType DEPENDENCY_TYPE_DEFAULT = TIME_DEPENDENT;
30 Dependencies dependencies;
31 bool updateFromAllChildren;
32 static const bool ALL_READY_DEFAULT =
false;
34 DependencyType dependencyType;
37 static const Time PERIOD_TIME_DEFAULT = 1;
40 TimeDependency(SignalBase<Time> *sig,
41 const DependencyType dep = DEPENDENCY_TYPE_DEFAULT);
42 TimeDependency(SignalBase<Time> *sig,
const SignalArray_const<Time> &arr,
43 const DependencyType dep = DEPENDENCY_TYPE_DEFAULT);
44 virtual ~TimeDependency() {}
46 void addDependencies(
const SignalArray_const<Time> &arr);
47 void addDependency(
const SignalBase<Time> &sig);
48 void removeDependency(
const SignalBase<Time> &sig);
49 void clearDependency();
51 virtual std::ostream &writeGraph(std::ostream &os)
const;
52 std::ostream &displayDependencies(std::ostream &os,
const int depth = -1,
53 std::string space =
"",
54 std::string next1 =
"",
55 std::string next2 =
"")
const;
57 bool needUpdate(
const Time &t1)
const;
59 void setDependencyType(DependencyType dep) { dependencyType = dep; }
61 void setNeedUpdateFromAllChildren(
const bool b =
true) {
62 updateFromAllChildren = b;
64 bool getNeedUpdateFromAllChildren()
const {
return updateFromAllChildren; }
66 void setPeriodTime(
const Time &p) { periodTime = p; }
67 Time getPeriodTime()
const {
return periodTime; }
72 #include <dynamic-graph/time-dependency.t.cpp>