Fawkes API  Fawkes Development Version
Plan.h
1 
2 /****************************************************************************
3  * ClipsExecutive -- Schema Plan
4  * (auto-generated, do not modify directly)
5  *
6  * CLIPS Executive REST API.
7  * Enables access to goals, plans, and all items in the domain model.
8  *
9  * API Contact: Tim Niemueller <niemueller@kbsg.rwth-aachen.de>
10  * API Version: v1beta1
11  * API License: Apache 2.0
12  ****************************************************************************/
13 
14 #pragma once
15 
16 #define RAPIDJSON_HAS_STDSTRING 1
17 #include "PlanAction.h"
18 
19 #include <rapidjson/fwd.h>
20 
21 #include <cstdint>
22 #include <memory>
23 #include <optional>
24 #include <string>
25 #include <vector>
26 
27 /** Plan representation for JSON transfer. */
28 class Plan
29 
30 {
31 public:
32  /** Constructor. */
33  Plan();
34  /** Constructor from JSON.
35  * @param json JSON string to initialize from
36  */
37  Plan(const std::string &json);
38  /** Constructor from JSON.
39  * @param v RapidJSON value object to initialize from.
40  */
41  Plan(const rapidjson::Value &v);
42 
43  /** Destructor. */
44  virtual ~Plan();
45 
46  /** Get version of implemented API.
47  * @return string representation of version
48  */
49  static std::string
51  {
52  return "v1beta1";
53  }
54 
55  /** Render object to JSON.
56  * @param pretty true to enable pretty printing (readable spacing)
57  * @return JSON string
58  */
59  virtual std::string to_json(bool pretty = false) const;
60  /** Render object to JSON.
61  * @param d RapidJSON document to retrieve allocator from
62  * @param v RapidJSON value to add data to
63  */
64  virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const;
65  /** Retrieve data from JSON string.
66  * @param json JSON representation suitable for this object.
67  * Will allow partial assignment and not validate automaticaly.
68  * @see validate()
69  */
70  virtual void from_json(const std::string &json);
71  /** Retrieve data from JSON string.
72  * @param v RapidJSON value suitable for this object.
73  * Will allow partial assignment and not validate automaticaly.
74  * @see validate()
75  */
76  virtual void from_json_value(const rapidjson::Value &v);
77 
78  /** Validate if all required fields have been set.
79  * @param subcall true if this is called from another class, e.g.,
80  * a sub-class or array holder. Will modify the kind of exception thrown.
81  * @exception std::vector<std::string> thrown if required information is
82  * missing and @p subcall is set to true. Contains a list of missing fields.
83  * @exception std::runtime_error informative message describing the missing
84  * fields
85  */
86  virtual void validate(bool subcall = false) const;
87 
88  // Schema: Plan
89 public:
90  /** Get kind value.
91  * @return kind value
92  */
93  std::optional<std::string>
94  kind() const
95  {
96  return kind_;
97  }
98 
99  /** Set kind value.
100  * @param kind new value
101  */
102  void
103  set_kind(const std::string &kind)
104  {
105  kind_ = kind;
106  }
107  /** Get apiVersion value.
108  * @return apiVersion value
109  */
110  std::optional<std::string>
111  apiVersion() const
112  {
113  return apiVersion_;
114  }
115 
116  /** Set apiVersion value.
117  * @param apiVersion new value
118  */
119  void
120  set_apiVersion(const std::string &apiVersion)
121  {
122  apiVersion_ = apiVersion;
123  }
124  /** Get id value.
125  * @return id value
126  */
127  std::optional<std::string>
128  id() const
129  {
130  return id_;
131  }
132 
133  /** Set id value.
134  * @param id new value
135  */
136  void
137  set_id(const std::string &id)
138  {
139  id_ = id;
140  }
141  /** Get goal-id value.
142  * @return goal-id value
143  */
144  std::optional<std::string>
145  goal_id() const
146  {
147  return goal_id_;
148  }
149 
150  /** Set goal-id value.
151  * @param goal_id new value
152  */
153  void
154  set_goal_id(const std::string &goal_id)
155  {
156  goal_id_ = goal_id;
157  }
158  /** Get cost value.
159  * @return cost value
160  */
161  std::optional<float>
162  cost() const
163  {
164  return cost_;
165  }
166 
167  /** Set cost value.
168  * @param cost new value
169  */
170  void
171  set_cost(const float &cost)
172  {
173  cost_ = cost;
174  }
175  /** Get actions value.
176  * @return actions value
177  */
178  std::vector<std::shared_ptr<PlanAction>>
179  actions() const
180  {
181  return actions_;
182  }
183 
184  /** Set actions value.
185  * @param actions new value
186  */
187  void
188  set_actions(const std::vector<std::shared_ptr<PlanAction>> &actions)
189  {
190  actions_ = actions;
191  }
192  /** Add element to actions array.
193  * @param actions new value
194  */
195  void
196  addto_actions(const std::shared_ptr<PlanAction> &&actions)
197  {
198  actions_.push_back(std::move(actions));
199  }
200 
201  /** Add element to actions array.
202  * The move-semantics version (std::move) should be preferred.
203  * @param actions new value
204  */
205  void
206  addto_actions(const std::shared_ptr<PlanAction> &actions)
207  {
208  actions_.push_back(actions);
209  }
210  /** Add element to actions array.
211  * @param actions new value
212  */
213  void
215  {
216  actions_.push_back(std::make_shared<PlanAction>(std::move(actions)));
217  }
218 
219 private:
220  std::optional<std::string> kind_;
221  std::optional<std::string> apiVersion_;
222  std::optional<std::string> id_;
223  std::optional<std::string> goal_id_;
224  std::optional<float> cost_;
225  std::vector<std::shared_ptr<PlanAction>> actions_;
226 };
PlanAction representation for JSON transfer.
Definition: PlanAction.h:32
Plan representation for JSON transfer.
Definition: Plan.h:30
Plan()
Constructor.
Definition: Plan.cpp:23
std::vector< std::shared_ptr< PlanAction > > actions() const
Get actions value.
Definition: Plan.h:179
void addto_actions(const std::shared_ptr< PlanAction > &&actions)
Add element to actions array.
Definition: Plan.h:196
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: Plan.cpp:61
void set_id(const std::string &id)
Set id value.
Definition: Plan.h:137
std::optional< std::string > goal_id() const
Get goal-id value.
Definition: Plan.h:145
void set_goal_id(const std::string &goal_id)
Set goal-id value.
Definition: Plan.h:154
virtual ~Plan()
Destructor.
Definition: Plan.cpp:37
std::optional< std::string > apiVersion() const
Get apiVersion value.
Definition: Plan.h:111
std::optional< std::string > id() const
Get id value.
Definition: Plan.h:128
static std::string api_version()
Get version of implemented API.
Definition: Plan.h:50
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: Plan.cpp:42
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: Plan.cpp:104
void set_kind(const std::string &kind)
Set kind value.
Definition: Plan.h:103
void set_actions(const std::vector< std::shared_ptr< PlanAction >> &actions)
Set actions value.
Definition: Plan.h:188
void addto_actions(const std::shared_ptr< PlanAction > &actions)
Add element to actions array.
Definition: Plan.h:206
std::optional< float > cost() const
Get cost value.
Definition: Plan.h:162
std::optional< std::string > kind() const
Get kind value.
Definition: Plan.h:94
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: Plan.cpp:144
void set_cost(const float &cost)
Set cost value.
Definition: Plan.h:171
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
Definition: Plan.h:120
void addto_actions(const PlanAction &&actions)
Add element to actions array.
Definition: Plan.h:214
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: Plan.cpp:113