sot-core  4.11.6
Hierarchical task solver plug-in for dynamic-graph.
sequencer.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef __SOT_SOTSEQUENCER_H__
11 #define __SOT_SOTSEQUENCER_H__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 
20 /* SOT */
21 #include <dynamic-graph/all-signals.h>
22 #include <dynamic-graph/entity.h>
24 
25 /* STD */
26 #include <list>
27 #include <map>
28 #include <string>
29 
30 /* --------------------------------------------------------------------- */
31 /* --- API ------------------------------------------------------------- */
32 /* --------------------------------------------------------------------- */
33 
34 #if defined(WIN32)
35 #if defined(sequencer_EXPORTS)
36 #define SOTSEQUENCER_EXPORT __declspec(dllexport)
37 #else
38 #define SOTSEQUENCER_EXPORT __declspec(dllimport)
39 #endif
40 #else
41 #define SOTSEQUENCER_EXPORT
42 #endif
43 
44 namespace dynamicgraph {
45 namespace sot {
46 
47 /* --------------------------------------------------------------------- */
48 /* --- CLASS ----------------------------------------------------------- */
49 /* --------------------------------------------------------------------- */
50 
51 class Sot;
52 
53 class SOTSEQUENCER_EXPORT Sequencer : public dynamicgraph::Entity {
54  DYNAMIC_GRAPH_ENTITY_DECL();
55 
56 public:
58  public:
59  enum sotEventType { EVENT_ADD, EVENT_RM, EVENT_CMD };
60 
61  protected:
62  std::string name;
63  void setName(const std::string &name_) { name = name_; }
64  int eventType;
65 
66  public:
67  sotEventAbstract(const std::string &name) : name(name){};
68  virtual ~sotEventAbstract(void) {}
69  virtual const std::string &getName() const { return name; }
70  int getEventType() const { return eventType; }
71  virtual void operator()(Sot *sotPtr) = 0;
72  virtual void display(std::ostream &os) const { os << name; }
73  };
74 
75 protected:
77  typedef std::list<sotEventAbstract *> TaskList;
78  typedef std::map<unsigned int, TaskList> TaskMap;
79 
81  /* All the events are counting wrt to this t0. If t0 is -1, it
82  * is set to the first time of trig. */
83  int timeInit;
84  bool playMode;
85  std::ostream *outputStreamPtr;
86  bool noOutput;
88 public: /* --- CONSTRUCTION --- */
89  Sequencer(const std::string &name);
90  virtual ~Sequencer(void);
91 
92 public: /* --- TASK MANIP --- */
93  void setSotRef(Sot *sot) { sotPtr = sot; }
94  void addTask(sotEventAbstract *task, const unsigned int time);
95  void rmTask(int eventType, const std::string &name, const unsigned int time);
96  void clearAll();
97 
98 public: /* --- SIGNAL --- */
99  dynamicgraph::SignalTimeDependent<int, int> triggerSOUT;
100 
101 public: /* --- FUNCTIONS --- */
102  int &trigger(int &dummy, const int &time);
103 
104 public: /* --- PARAMS --- */
105  virtual void display(std::ostream &os) const;
106 };
107 } // namespace sot
108 } // namespace dynamicgraph
109 
110 #endif // #ifndef __SOT_SOTSEQUENCER_H__
dynamicgraph::sot::Sequencer::sotEventAbstract::setName
void setName(const std::string &name_)
Definition: sequencer.hh:63
dynamicgraph::sot::Sequencer::sotEventAbstract
Definition: sequencer.hh:57
dynamicgraph::sot::Sequencer
Definition: sequencer.hh:53
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
dynamicgraph::sot::Sequencer::sotPtr
Sot * sotPtr
Definition: sequencer.hh:76
dynamicgraph::sot::Sequencer::sotEventAbstract::eventType
int eventType
Definition: sequencer.hh:64
dynamicgraph::sot::Sequencer::sotEventAbstract::getName
virtual const std::string & getName() const
Definition: sequencer.hh:69
dynamicgraph::sot::Sot
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
Definition: sot.hh:56
dynamicgraph::sot::Sequencer::sotEventAbstract::sotEventType
sotEventType
Definition: sequencer.hh:59
dynamicgraph::sot::Sequencer::triggerSOUT
dynamicgraph::SignalTimeDependent< int, int > triggerSOUT
Definition: sequencer.hh:99
dynamicgraph::sot::Sequencer::TaskMap
std::map< unsigned int, TaskList > TaskMap
Definition: sequencer.hh:78
SOTSEQUENCER_EXPORT
#define SOTSEQUENCER_EXPORT
Definition: sequencer.hh:41
dynamicgraph::sot::Sequencer::sotEventAbstract::sotEventAbstract
sotEventAbstract(const std::string &name)
Definition: sequencer.hh:67
dynamicgraph::sot::Sequencer::sotEventAbstract::~sotEventAbstract
virtual ~sotEventAbstract(void)
Definition: sequencer.hh:68
dynamicgraph::sot::Sequencer::sotEventAbstract::display
virtual void display(std::ostream &os) const
Definition: sequencer.hh:72
dynamicgraph::sot::Sequencer::outputStreamPtr
std::ostream * outputStreamPtr
Definition: sequencer.hh:85
dynamicgraph::sot::Sequencer::TaskList
std::list< sotEventAbstract * > TaskList
Definition: sequencer.hh:77
dynamicgraph::sot::Sequencer::sotEventAbstract::getEventType
int getEventType() const
Definition: sequencer.hh:70
dynamicgraph::sot::Sequencer::setSotRef
void setSotRef(Sot *sot)
Definition: sequencer.hh:93
dynamicgraph::sot::Sequencer::sotEventAbstract::name
std::string name
Definition: sequencer.hh:62
dynamicgraph::sot::Sequencer::timeInit
int timeInit
Definition: sequencer.hh:83
task-abstract.hh
dynamicgraph::sot::Sequencer::taskMap
TaskMap taskMap
Definition: sequencer.hh:80
dynamicgraph::sot::Sequencer::noOutput
bool noOutput
Definition: sequencer.hh:86
dynamicgraph::sot::Sequencer::playMode
bool playMode
Definition: sequencer.hh:84