6 #ifndef DYNAMIC_GRAPH_TIME_DEPENDENCY_H
7 #define DYNAMIC_GRAPH_TIME_DEPENDENCY_H
8 #include <dynamic-graph/signal-array.h>
9 #include <dynamic-graph/signal-base.h>
11 #include <dynamic-graph/fwd.hh>
19 class TimeDependency {
21 enum DependencyType { TIME_DEPENDENT, BOOL_DEPENDENT, ALWAYS_READY };
23 mutable Time lastAskForUpdate;
26 SignalBase<Time> &leader;
28 typedef std::list<const SignalBase<Time> *> Dependencies;
29 static const DependencyType DEPENDENCY_TYPE_DEFAULT = TIME_DEPENDENT;
31 Dependencies dependencies;
32 bool updateFromAllChildren;
33 static const bool ALL_READY_DEFAULT =
false;
35 DependencyType dependencyType;
38 static const Time PERIOD_TIME_DEFAULT = 1;
41 TimeDependency(SignalBase<Time> *sig,
42 const DependencyType dep = DEPENDENCY_TYPE_DEFAULT);
43 TimeDependency(SignalBase<Time> *sig,
const SignalArray_const<Time> &arr,
44 const DependencyType dep = DEPENDENCY_TYPE_DEFAULT);
45 virtual ~TimeDependency() {}
47 void addDependencies(
const SignalArray_const<Time> &arr);
48 void addDependency(
const SignalBase<Time> &sig);
49 void removeDependency(
const SignalBase<Time> &sig);
50 void clearDependency();
52 virtual std::ostream &writeGraph(std::ostream &os)
const;
53 std::ostream &displayDependencies(std::ostream &os,
const int depth = -1,
54 std::string space =
"",
55 std::string next1 =
"",
56 std::string next2 =
"")
const;
58 bool needUpdate(
const Time &t1)
const;
60 void setDependencyType(DependencyType dep) { dependencyType = dep; }
62 void setNeedUpdateFromAllChildren(
const bool b =
true) {
63 updateFromAllChildren = b;
65 bool getNeedUpdateFromAllChildren()
const {
return updateFromAllChildren; }
67 void setPeriodTime(
const Time &p) { periodTime = p; }
68 Time getPeriodTime()
const {
return periodTime; }
73 #include <dynamic-graph/time-dependency.t.cpp>