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. */
28class Fact
29
30{
31public:
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
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
89public:
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>
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>
146 {
147 return template_name_;
148 }
149
150 /** Set template_name value.
151 * @param template_name new value
152 */
153 void
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
215 {
216 slots_.push_back(std::make_shared<SlotValue>(std::move(slots)));
217 }
218
219private:
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 representation for JSON transfer.
Definition: Fact.h:30
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: Fact.cpp:104
std::optional< std::string > kind() const
Get kind value.
Definition: Fact.h:94
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: Fact.cpp:144
static std::string api_version()
Get version of implemented API.
Definition: Fact.h:50
virtual ~Fact()
Destructor.
Definition: Fact.cpp:37
std::optional< std::string > apiVersion() const
Get apiVersion value.
Definition: Fact.h:111
void set_template_name(const std::string &template_name)
Set template_name value.
Definition: Fact.h:154
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: Fact.cpp:61
void set_index(const int64_t &index)
Set index value.
Definition: Fact.h:137
std::optional< std::string > template_name() const
Get template_name value.
Definition: Fact.h:145
void set_formatted(const std::string &formatted)
Set formatted value.
Definition: Fact.h:171
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
Definition: Fact.h:120
void set_kind(const std::string &kind)
Set kind value.
Definition: Fact.h:103
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: Fact.cpp:113
std::optional< std::string > formatted() const
Get formatted value.
Definition: Fact.h:162
std::optional< int64_t > index() const
Get index value.
Definition: Fact.h:128
Fact()
Constructor.
Definition: Fact.cpp:23
void addto_slots(const SlotValue &&slots)
Add element to slots array.
Definition: Fact.h:214
void addto_slots(const std::shared_ptr< SlotValue > &&slots)
Add element to slots array.
Definition: Fact.h:196
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: Fact.cpp:42
void addto_slots(const std::shared_ptr< SlotValue > &slots)
Add element to slots array.
Definition: Fact.h:206
std::vector< std::shared_ptr< SlotValue > > slots() const
Get slots value.
Definition: Fact.h:179
void set_slots(const std::vector< std::shared_ptr< SlotValue > > &slots)
Set slots value.
Definition: Fact.h:188
SlotValue representation for JSON transfer.
Definition: SlotValue.h:28