libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
Sem_Actions.hpp
1 #ifndef SEM_ACTIONS_H
2 #define SEM_ACTIONS_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 
8 #include "Logging/Logger.h"
9 #include "Sem_PlanParts.hpp"
10 
11 
12 namespace Sem {
13 
15 {
16  MOVE3D_STATIC_LOGGER;
17 public:
18  ActionType();
19  ActionType(const std::string &s);
20  virtual ~ActionType();
21  bool isDefined() const;
22 
23  std::string toString() const;
24 
25  friend bool operator==(ActionType const &v1 , ActionType const &v2) {return v1._value==v2._value;}
26  friend bool operator!=(ActionType const &v1 , ActionType const &v2) {return v1._value!=v2._value;}
27  friend bool operator<(ActionType const &v1 , ActionType const &v2) {return v1._value<v2._value;}
28  friend bool operator>(ActionType const &v1 , ActionType const &v2) {return v1._value>v2._value;}
29 
30  static std::vector<ActionType> currentlyDefinedActionTypes();
31 
32 protected:
33  ActionType(int val);
34  static std::vector<std::string> __stringValues;
35 private:
36  int _value;
37 };
38 
40 {
41  MOVE3D_STATIC_LOGGER;
42 public:
45  virtual ~ActionDefinition();
46 
47  std::vector<PlanningType> const &requiredParts() const;
48  void setRequiredParts(const std::vector<PlanningType> &requiredParts);
49 
50  ActionType actionType() const;
51  void setActionType(const ActionType &actionType);
52 
53  std::vector<PlanningType> hriParts() const;
54  void setHriParts(const std::vector<PlanningType> &hriParts);
55 
56 
57  const std::set<AgentType> &include() const;
58  std::set<AgentType> &include();
59  void setInclude(const std::set<AgentType> &include);
60  void addInclude(AgentType agent_type);
61 
62  const std::set<AgentType> &exclude() const;
63  std::set<AgentType> &exclude();
64  void setExclude(const std::set<AgentType> &exclude);
65  void addExclude(AgentType agent_type);
66 
68  bool isWhiteListed(AgentType agent_type) const;
69 
70 private:
71  ActionType _actionType;
72  std::vector<PlanningType> _requiredParts;
73  std::vector<PlanningType> _hriParts;
74 
75  std::set<AgentType> _include;
76  std::set<AgentType> _exclude;
77 
78 };
79 
80 class Actions
81 {
82  MOVE3D_STATIC_LOGGER;
83 public:
84  Actions( std::string global_json_path,bool proactive=false);
85  ~Actions();
86 
87  ActionDefinition const* getActionDefinition(ActionType t );
88 
89  //json import/export
90  //.global
91  std::string getPath();
92  std::string getPath(ActionType t);
93  //.import
94  bool fetchData();
95  bool fetchAction(ActionType t);
96  bool importJsonFile(const std::string &path);
97  bool importJsonFile(const std::string &path, ActionType t);
98 
99  bool addActionDef(ActionType t, Json::Value const & value);
100  void addActionDef(ActionDefinition *action);
101 
102  //.export
103  bool save();
104  bool appendActionToJson(Json::Value &root,ActionDefinition const & act);
105 
106  //.json conversion
107  Json::Value actionToJson(ActionDefinition const &act);
108  ActionDefinition *jsonToActionDefinition(ActionType t,Json::Value const & value);
109 
110 
114  bool proactive() const;
115  void setProactive(bool proactive);
116 private:
117  bool _proactive;
118  std::string _global_json_path;
119  std::map<ActionType,ActionDefinition*> _actions;
120 };
121 
122 } // namespace Sem
123 
124 #endif // SEM_ACTIONS_H
Definition: Sem_AgentType.hpp:12
This file implements macros to help with the logging, in a way similar to ROS, using log4cxx...
bool proactive() const
proactive means that json data will be loaded on creation, otherwise it is read on getPlanPart() call...
Definition: Sem_Actions.cpp:470
bool isWhiteListed(AgentType agent_type) const
consider include and exclude lists
Definition: Sem_Actions.cpp:162
Definition: Sem_Actions.hpp:14
Definition: Sem_Actions.hpp:80
Definition: Sem_Actions.hpp:39