Fawkes API Fawkes Development Version
InterfaceMessageType.h
1
2/****************************************************************************
3 * Blackboard -- Schema InterfaceMessageType
4 * (auto-generated, do not modify directly)
5 *
6 * Fawkes Blackboard REST API.
7 * Access blackboard data through a REST API.
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 "InterfaceFieldType.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/** InterfaceMessageType representation for JSON transfer. */
29
30{
31public:
32 /** Constructor. */
34 /** Constructor from JSON.
35 * @param json JSON string to initialize from
36 */
37 InterfaceMessageType(const std::string &json);
38 /** Constructor from JSON.
39 * @param v RapidJSON value object to initialize from.
40 */
41 InterfaceMessageType(const rapidjson::Value &v);
42
43 /** Destructor. */
44 virtual ~InterfaceMessageType();
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: InterfaceMessageType
89public:
90 /** Get name value.
91 * @return name value
92 */
93 std::optional<std::string>
94 name() const
95 {
96 return name_;
97 }
98
99 /** Set name value.
100 * @param name new value
101 */
102 void
103 set_name(const std::string &name)
104 {
105 name_ = name;
106 }
107 /** Get fields value.
108 * @return fields value
109 */
110 std::vector<std::shared_ptr<InterfaceFieldType>>
111 fields() const
112 {
113 return fields_;
114 }
115
116 /** Set fields value.
117 * @param fields new value
118 */
119 void
120 set_fields(const std::vector<std::shared_ptr<InterfaceFieldType>> &fields)
121 {
122 fields_ = fields;
123 }
124 /** Add element to fields array.
125 * @param fields new value
126 */
127 void
128 addto_fields(const std::shared_ptr<InterfaceFieldType> &&fields)
129 {
130 fields_.push_back(std::move(fields));
131 }
132
133 /** Add element to fields array.
134 * The move-semantics version (std::move) should be preferred.
135 * @param fields new value
136 */
137 void
138 addto_fields(const std::shared_ptr<InterfaceFieldType> &fields)
139 {
140 fields_.push_back(fields);
141 }
142 /** Add element to fields array.
143 * @param fields new value
144 */
145 void
147 {
148 fields_.push_back(std::make_shared<InterfaceFieldType>(std::move(fields)));
149 }
150
151private:
152 std::optional<std::string> name_;
153 std::vector<std::shared_ptr<InterfaceFieldType>> fields_;
154};
InterfaceFieldType representation for JSON transfer.
InterfaceMessageType representation for JSON transfer.
void addto_fields(const InterfaceFieldType &&fields)
Add element to fields array.
void addto_fields(const std::shared_ptr< InterfaceFieldType > &&fields)
Add element to fields array.
void set_name(const std::string &name)
Set name value.
InterfaceMessageType()
Constructor.
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
static std::string api_version()
Get version of implemented API.
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
std::optional< std::string > name() const
Get name value.
std::vector< std::shared_ptr< InterfaceFieldType > > fields() const
Get fields value.
void set_fields(const std::vector< std::shared_ptr< InterfaceFieldType > > &fields)
Set fields value.
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
virtual ~InterfaceMessageType()
Destructor.
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
void addto_fields(const std::shared_ptr< InterfaceFieldType > &fields)
Add element to fields array.