Fawkes API  Fawkes Development Version
Fact.h
1 
2 /****************************************************************************
3  * Clips -- Schema Fact
4  * (auto-generated, do not modify directly)
5  *
6  * CLIPS REST API.
7  * Enables access to CLIPS environments.
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 "SlotValue.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 /** Fact representation for JSON transfer. */
28 class Fact
29 
30 {
31 public:
32  /** Constructor. */
33  Fact();
34  /** Constructor from JSON.
35  * @param json JSON string to initialize from
36  */
37  Fact(const std::string &json);
38  /** Constructor from JSON.
39  * @param v RapidJSON value object to initialize from.
40  */
41  Fact(const rapidjson::Value &v);
42 
43  /** Destructor. */
44  virtual ~Fact();
45 
46  /** Get version of implemented API.
47  * @return string representation of version
48  */
49  static std::string
50  api_version()
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: Fact
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 index value.
125  * @return index value
126  */
127  std::optional<int64_t>
128  index() const
129  {
130  return index_;
131  }
132 
133  /** Set index value.
134  * @param index new value
135  */
136  void
137  set_index(const int64_t &index)
138  {
139  index_ = index;
140  }
141  /** Get template_name value.
142  * @return template_name value
143  */
144  std::optional<std::string>
145  template_name() const
146  {
147  return template_name_;
148  }
149 
150  /** Set template_name value.
151  * @param template_name new value
152  */
153  void
154  set_template_name(const std::string &template_name)
155  {
156  template_name_ = template_name;
157  }
158  /** Get formatted value.
159  * @return formatted value
160  */
161  std::optional<std::string>
162  formatted() const
163  {
164  return formatted_;
165  }
166 
167  /** Set formatted value.
168  * @param formatted new value
169  */
170  void
171  set_formatted(const std::string &formatted)
172  {
173  formatted_ = formatted;
174  }
175  /** Get slots value.
176  * @return slots value
177  */
178  std::vector<std::shared_ptr<SlotValue>>
179  slots() const
180  {
181  return slots_;
182  }
183 
184  /** Set slots value.
185  * @param slots new value
186  */
187  void
188  set_slots(const std::vector<std::shared_ptr<SlotValue>> &slots)
189  {
190  slots_ = slots;
191  }
192  /** Add element to slots array.
193  * @param slots new value
194  */
195  void
196  addto_slots(const std::shared_ptr<SlotValue> &&slots)
197  {
198  slots_.push_back(std::move(slots));
199  }
200 
201  /** Add element to slots array.
202  * The move-semantics version (std::move) should be preferred.
203  * @param slots new value
204  */
205  void
206  addto_slots(const std::shared_ptr<SlotValue> &slots)
207  {
208  slots_.push_back(slots);
209  }
210  /** Add element to slots array.
211  * @param slots new value
212  */
213  void
214  addto_slots(const SlotValue &&slots)
215  {
216  slots_.push_back(std::make_shared<SlotValue>(std::move(slots)));
217  }
218 
219 private:
220  std::optional<std::string> kind_;
221  std::optional<std::string> apiVersion_;
222  std::optional<int64_t> index_;
223  std::optional<std::string> template_name_;
224  std::optional<std::string> formatted_;
225  std::vector<std::shared_ptr<SlotValue>> slots_;
226 };
Fact::addto_slots
void addto_slots(const std::shared_ptr< SlotValue > &&slots)
Add element to slots array.
Definition: Fact.h:195
Fact::from_json
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: Fact.cpp:103
Fact::from_json_value
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: Fact.cpp:112
Fact::set_formatted
void set_formatted(const std::string &formatted)
Set formatted value.
Definition: Fact.h:170
Fact::~Fact
virtual ~Fact()
Destructor.
Definition: Fact.cpp:36
Fact::set_kind
void set_kind(const std::string &kind)
Set kind value.
Definition: Fact.h:102
Fact::validate
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: Fact.cpp:143
Fact::apiVersion
std::optional< std::string > apiVersion() const
Get apiVersion value.
Definition: Fact.h:110
Fact::set_index
void set_index(const int64_t &index)
Set index value.
Definition: Fact.h:136
Fact::to_json
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: Fact.cpp:41
Fact::index
std::optional< int64_t > index() const
Get index value.
Definition: Fact.h:127
Fact::set_slots
void set_slots(const std::vector< std::shared_ptr< SlotValue >> &slots)
Set slots value.
Definition: Fact.h:187
Fact::formatted
std::optional< std::string > formatted() const
Get formatted value.
Definition: Fact.h:161
Fact::set_apiVersion
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
Definition: Fact.h:119
Fact::api_version
static std::string api_version()
Get version of implemented API.
Definition: Fact.h:49
Fact::kind
std::optional< std::string > kind() const
Get kind value.
Definition: Fact.h:93
Fact::slots
std::vector< std::shared_ptr< SlotValue > > slots() const
Get slots value.
Definition: Fact.h:178
SlotValue
SlotValue representation for JSON transfer.
Definition: SlotValue.h:25
Fact::template_name
std::optional< std::string > template_name() const
Get template_name value.
Definition: Fact.h:144
Fact::set_template_name
void set_template_name(const std::string &template_name)
Set template_name value.
Definition: Fact.h:153
Fact::to_json_value
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: Fact.cpp:60
Fact::Fact
Fact()
Constructor.
Definition: Fact.cpp:22
Fact
Fact representation for JSON transfer.
Definition: Fact.h:27