GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/dynamic-graph/time-dependency.h Lines: 4 4 100.0 %
Date: 2023-03-15 12:04:10 Branches: 0 0 - %

Line Branch Exec Source
1
// -*- mode: c++ -*-
2
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
3
// JRL, CNRS/AIST.
4
//
5
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>
10
11
#include <dynamic-graph/fwd.hh>
12
#include <list>
13
14
namespace dynamicgraph {
15
/** \brief A helper class for setting and specifying dependencies
16
    between signals.
17
*/
18
template <class Time>
19
class TimeDependency {
20
 public:
21
  enum DependencyType { TIME_DEPENDENT, BOOL_DEPENDENT, ALWAYS_READY };
22
23
  mutable Time lastAskForUpdate;
24
25
 public:
26
  SignalBase<Time> &leader;
27
28
  typedef std::list<const SignalBase<Time> *> Dependencies;
29
  static const DependencyType DEPENDENCY_TYPE_DEFAULT = TIME_DEPENDENT;
30
31
  Dependencies dependencies;
32
  bool updateFromAllChildren;
33
  static const bool ALL_READY_DEFAULT = false;
34
35
  DependencyType dependencyType;
36
37
  Time periodTime;
38
  static const Time PERIOD_TIME_DEFAULT = 1;
39
40
 public:
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
16
  virtual ~TimeDependency() {}
46
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();
51
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;
57
58
  bool needUpdate(const Time &t1) const;
59
60
2
  void setDependencyType(DependencyType dep) { dependencyType = dep; }
61
62
  void setNeedUpdateFromAllChildren(const bool b = true) {
63
    updateFromAllChildren = b;
64
  }
65
  bool getNeedUpdateFromAllChildren() const { return updateFromAllChildren; }
66
67
1
  void setPeriodTime(const Time &p) { periodTime = p; }
68
1
  Time getPeriodTime() const { return periodTime; }
69
};
70
71
}  // end of namespace dynamicgraph
72
73
#include <dynamic-graph/time-dependency.t.cpp>
74
#endif  //! DYNAMIC_GRAPH_TIME_DEPENDENCY_H