sot-core  4.11.8
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>
23 
25 
26 /* STD */
27 #include <list>
28 #include <map>
29 #include <string>
30 
31 /* --------------------------------------------------------------------- */
32 /* --- API ------------------------------------------------------------- */
33 /* --------------------------------------------------------------------- */
34 
35 #if defined(WIN32)
36 #if defined(sequencer_EXPORTS)
37 #define SOTSEQUENCER_EXPORT __declspec(dllexport)
38 #else
39 #define SOTSEQUENCER_EXPORT __declspec(dllimport)
40 #endif
41 #else
42 #define SOTSEQUENCER_EXPORT
43 #endif
44 
45 namespace dynamicgraph {
46 namespace sot {
47 
48 /* --------------------------------------------------------------------- */
49 /* --- CLASS ----------------------------------------------------------- */
50 /* --------------------------------------------------------------------- */
51 
52 class Sot;
53 
54 class SOTSEQUENCER_EXPORT Sequencer : public dynamicgraph::Entity {
55  DYNAMIC_GRAPH_ENTITY_DECL();
56 
57  public:
59  public:
60  enum sotEventType { EVENT_ADD, EVENT_RM, EVENT_CMD };
61 
62  protected:
63  std::string name;
64  void setName(const std::string &name_) { name = name_; }
65  int eventType;
66 
67  public:
68  sotEventAbstract(const std::string &name) : name(name){};
69  virtual ~sotEventAbstract(void) {}
70  virtual const std::string &getName() const { return name; }
71  int getEventType() const { return eventType; }
72  virtual void operator()(Sot *sotPtr) = 0;
73  virtual void display(std::ostream &os) const { os << name; }
74  };
75 
76  protected:
78  typedef std::list<sotEventAbstract *> TaskList;
79  typedef std::map<unsigned int, TaskList> TaskMap;
80 
82  /* All the events are counting wrt to this t0. If t0 is -1, it
83  * is set to the first time of trig. */
84  int timeInit;
85  bool playMode;
86  std::ostream *outputStreamPtr;
87  bool noOutput;
89  public: /* --- CONSTRUCTION --- */
90  Sequencer(const std::string &name);
91  virtual ~Sequencer(void);
92 
93  public: /* --- TASK MANIP --- */
94  void setSotRef(Sot *sot) { sotPtr = sot; }
95  void addTask(sotEventAbstract *task, const unsigned int time);
96  void rmTask(int eventType, const std::string &name, const unsigned int time);
97  void clearAll();
98 
99  public: /* --- SIGNAL --- */
100  dynamicgraph::SignalTimeDependent<int, int> triggerSOUT;
101 
102  public: /* --- FUNCTIONS --- */
103  int &trigger(int &dummy, const int &time);
104 
105  public: /* --- PARAMS --- */
106  virtual void display(std::ostream &os) const;
107 };
108 } // namespace sot
109 } // namespace dynamicgraph
110 
111 #endif // #ifndef __SOT_SOTSEQUENCER_H__
virtual ~sotEventAbstract(void)
Definition: sequencer.hh:69
void setName(const std::string &name_)
Definition: sequencer.hh:64
int getEventType() const
Definition: sequencer.hh:71
sotEventAbstract(const std::string &name)
Definition: sequencer.hh:68
@ EVENT_ADD
Definition: sequencer.hh:60
std::string name
Definition: sequencer.hh:63
virtual void display(std::ostream &os) const
Definition: sequencer.hh:73
virtual const std::string & getName() const
Definition: sequencer.hh:70
int eventType
Definition: sequencer.hh:65
Definition: sequencer.hh:54
Sot * sotPtr
Definition: sequencer.hh:77
int & trigger(int &dummy, const int &time)
bool noOutput
Definition: sequencer.hh:87
void setSotRef(Sot *sot)
Definition: sequencer.hh:94
dynamicgraph::SignalTimeDependent< int, int > triggerSOUT
Definition: sequencer.hh:100
Sequencer(const std::string &name)
std::ostream * outputStreamPtr
Definition: sequencer.hh:86
void addTask(sotEventAbstract *task, const unsigned int time)
virtual void display(std::ostream &os) const
std::map< unsigned int, TaskList > TaskMap
Definition: sequencer.hh:79
void rmTask(int eventType, const std::string &name, const unsigned int time)
bool playMode
Definition: sequencer.hh:85
TaskMap taskMap
Definition: sequencer.hh:81
int timeInit
Definition: sequencer.hh:84
std::list< sotEventAbstract * > TaskList
Definition: sequencer.hh:78
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
Definition: sot.hh:57
Definition: abstract-sot-external-interface.hh:17
#define SOTSEQUENCER_EXPORT
Definition: sequencer.hh:42