Parasol Planning Library (PPL)
SemanticTask.h
Go to the documentation of this file.
1 #ifndef PPL_SEMANTIC_TASK_H_
2 #define PPL_SEMANTIC_TASK_H_
3 
4 #include "MPProblem/GroupTask.h"
5 #include "MPProblem/MPTask.h"
6 
7 #include <unordered_map>
8 #include <unordered_set>
9 
10 class Decomposition;
11 class MPProblem;
12 
13 class SemanticTask {
14 
15  public:
16 
19 
21  XOR,
22  AND
23  };
24 
30  None
31  };
32 
33  typedef std::unordered_map<DependencyType, std::unordered_set<SemanticTask*>,
34  std::hash<int>> DependencyMap;
35 
39 
40  SemanticTask();
41 
45  SemanticTask(MPProblem* _problem, XMLNode& _node, Decomposition* _decomp);
46 
54  SemanticTask(std::string _label, SemanticTask* _parent, Decomposition* _decomp,
55  SubtaskRelation _relation, bool _decomposable, bool _fixedAssign,
56  std::shared_ptr<MPTask> _motionTask = nullptr);
57 
66  SemanticTask(std::string _label, SemanticTask* _parent, Decomposition* _decomp,
67  SubtaskRelation _relation, bool _decomposable, bool _fixedAssign,
68  std::shared_ptr<GroupTask> _groupMotionTask);
69 
74  SemanticTask(SemanticTask* _parent, Decomposition* _decomp,
75  std::shared_ptr<MPTask> _motionTask, bool _decomposable=true);
76 
82  SemanticTask(SemanticTask* _parent, Decomposition* _decomp,
83  std::shared_ptr<GroupTask> _groupMotionTask, bool _decomposable=true);
84 
90  SemanticTask(std::string _label, SemanticTask* _parent, Decomposition* _decomp,
91  std::shared_ptr<MPTask> _motionTask = nullptr, bool _decomposable=true);
92 
99  SemanticTask(std::string _label, SemanticTask* _parent, Decomposition* _decomp,
100  std::shared_ptr<GroupTask> _groupMotionTask, bool _decomposable=true);
101 
102  ~SemanticTask();
103 
107 
109  std::string GetLabel() const;
110 
112  std::vector<SemanticTask*> SetDependencies();
113 
115  bool IsDecomposable();
116 
119  void SetMotionTask(std::shared_ptr<MPTask> _motion);
120 
122  std::shared_ptr<MPTask> GetMotionTask();
123 
126  void SetGroupMotionTask(std::shared_ptr<GroupTask> _motion);
127 
129  std::shared_ptr<GroupTask> GetGroupMotionTask();
130 
133 
136  void SetParent(SemanticTask* _parent);
137 
141  std::unordered_set<SemanticTask*> AddDependency(SemanticTask* _task, DependencyType _type);
142 
145 
147  bool IsFixedAssignment();
148 
151  void AddSubtask(SemanticTask* _task);
152 
154  std::vector<SemanticTask*> GetSubtasks();
155 
158 
160 
161  private:
164 
169  void ParseDependency(MPProblem* _problem, XMLNode& _node, Decomposition* _decomp);
170 
174 
176  std::string m_label;
177 
179  SemanticTask* m_parent{nullptr};
180 
182  std::shared_ptr<MPTask> m_motionTask;
183 
185  std::shared_ptr<GroupTask> m_groupMotionTask;
186 
188  bool m_fixedAssignment{false};
189 
191  bool m_decomposable{true};
192 
194  std::vector<SemanticTask*> m_subtasks;
195 
197  SubtaskRelation m_subtasksRelation;
198 
200  DependencyMap m_dependencyMap;
201 
203 };
204 
205 #endif
Definition: Decomposition.h:9
Definition: MPProblem.h:34
Definition: SemanticTask.h:13
std::shared_ptr< GroupTask > GetGroupMotionTask()
Return the corresponding group motion task.
Definition: SemanticTask.cpp:284
void SetParent(SemanticTask *_parent)
Definition: SemanticTask.cpp:296
bool IsFixedAssignment()
Return flag for fixed assignment status.
Definition: SemanticTask.cpp:317
SemanticTask * GetParent()
Return the parent of this task in the decomposition tree.
Definition: SemanticTask.cpp:290
void SetGroupMotionTask(std::shared_ptr< GroupTask > _motion)
Definition: SemanticTask.cpp:278
std::unordered_set< SemanticTask * > AddDependency(SemanticTask *_task, DependencyType _type)
Definition: SemanticTask.cpp:302
std::shared_ptr< MPTask > GetMotionTask()
Return the corresponding motion task.
Definition: SemanticTask.cpp:272
SubtaskRelation GetSubtaskRelation()
Return the relationship between this task's subtasks.
Definition: SemanticTask.cpp:335
bool IsDecomposable()
Indicates if this task can be decomposed.
Definition: SemanticTask.cpp:260
~SemanticTask()
Definition: SemanticTask.cpp:164
void AddSubtask(SemanticTask *_task)
Definition: SemanticTask.cpp:323
std::vector< SemanticTask * > SetDependencies()
Sets the dependencies of all the semantic tasks below this in the hierarchy,.
Definition: SemanticTask.cpp:211
std::unordered_map< DependencyType, std::unordered_set< SemanticTask * >, std::hash< int > > DependencyMap
Definition: SemanticTask.h:34
DependencyType
Definition: SemanticTask.h:25
@ Initiation
Task A must be complete to start task B.
Definition: SemanticTask.h:27
@ Asynchronous
Task A and task B must be start simultaneously.
Definition: SemanticTask.h:29
@ None
TODO::Might be the same as none?
Definition: SemanticTask.h:30
@ Synchronous
Task A must be started to start task B.
Definition: SemanticTask.h:28
@ Completion
Definition: SemanticTask.h:26
void SetMotionTask(std::shared_ptr< MPTask > _motion)
Definition: SemanticTask.cpp:266
std::string GetLabel() const
Return referencing label for this task.
Definition: SemanticTask.cpp:205
SemanticTask()
Definition: SemanticTask.cpp:11
SubtaskRelation
Definition: SemanticTask.h:20
@ AND
Any subtask can be complete to satisfy this task.
Definition: SemanticTask.h:22
@ XOR
Definition: SemanticTask.h:21
DependencyMap & GetDependencies()
Return the map of all dependencies this task has.
Definition: SemanticTask.cpp:311
std::vector< SemanticTask * > GetSubtasks()
Return the set of all subtasks.
Definition: SemanticTask.cpp:329
Definition: XMLNode.h:27