1 #ifndef RAPP_CLOUD_ONTOLOGY
2 #define RAPP_CLOUD_ONTOLOGY
23 std::string ontology_class,
25 std::function<
void(std::vector<std::string>)> callback,
30 boost::property_tree::ptree tree;
31 tree.put(
"ontology_class", ontology_class);
32 tree.put(
"recursive", boost::lexical_cast<std::string>(recursive));
34 boost::property_tree::write_json(ss, tree,
false);
36 header_ =
"POST /hop/ontology_subclasses_of HTTP/1.1\r\n";
45 std::vector<std::string> classes;
46 std::stringstream ss(json);
48 boost::property_tree::ptree tree;
49 boost::property_tree::read_json(ss, tree);
51 for (
auto child : tree.get_child(
"results")) {
52 classes.push_back(child.second.get_value<std::string>());
55 for (
auto child : tree.get_child(
"error")) {
56 const std::string value = child.second.get_value<std::string>();
58 std::cerr <<
"ontology_subclasses_of JSON error: " << value << std::endl;
62 catch (boost::property_tree::json_parser::json_parser_error & je) {
63 std::cerr <<
"ontology_subclasses_of::handle_reply Error parsing: " << je.filename()
64 <<
" on line: " << je.line() << std::endl;
65 std::cerr << je.message() << std::endl;
70 std::function<void(std::vector<std::string> classes)>
delegate__;
88 const std::string ontology_class,
90 std::function<
void(std::vector<std::string>)> callback,
95 boost::property_tree::ptree tree;
96 tree.put(
"ontology_class", ontology_class);
97 tree.put(
"recursive", boost::lexical_cast<std::string>(recursive));
99 boost::property_tree::write_json(ss, tree,
false);
101 header_ =
"POST /hop/ontology_superclasses_of HTTP/1.1\r\n";
110 std::vector<std::string> classes;
111 std::stringstream ss(json);
113 boost::property_tree::ptree tree;
114 boost::property_tree::read_json(ss, tree);
116 for (
auto child : tree.get_child(
"results")) {
117 classes.push_back(child.second.get_value<std::string>());
120 for (
auto child : tree.get_child(
"error")) {
121 const std::string value = child.second.get_value<std::string>();
122 if (!value.empty()) {
123 std::cerr <<
"ontology_superclasses_of JSON error: " << value << std::endl;
127 catch (boost::property_tree::json_parser::json_parser_error & je) {
128 std::cerr <<
"ontology_superclasses_of::handle_reply Error parsing: " << je.filename()
129 <<
" on line: " << je.line() << std::endl;
130 std::cerr << je.message() << std::endl;
135 std::function<void(std::vector<std::string> classes)>
delegate__;
156 const std::string parent_class,
157 const std::string child_class,
159 std::function<
void(
bool result)> callback,
160 const std::string token
164 boost::property_tree::ptree tree;
165 tree.put(
"parent_class", parent_class);
166 tree.put(
"child_class", child_class);
167 tree.put(
"recursive", boost::lexical_cast<std::string>(recursive));
168 std::stringstream ss;
169 boost::property_tree::write_json(ss, tree,
false);
171 header_ =
"POST /hop/ontology_is_subsuperclass_of HTTP/1.1\r\n";
180 std::vector<std::string> classes;
181 std::stringstream ss(json);
184 boost::property_tree::ptree tree;
185 boost::property_tree::read_json(ss, tree);
187 for (
auto child : tree.get_child(
"result")) {
188 result = child.second.get_value<
bool>();
191 for (
auto child : tree.get_child(
"error")) {
192 const std::string value = child.second.get_value<std::string>();
193 if (!value.empty()) {
194 std::cerr <<
"ontology_is_subsuperclass_of JSON error: " << value << std::endl;
198 catch (boost::property_tree::json_parser::json_parser_error & je) {
199 std::cerr <<
"ontology_is_subsuperclass_of::handle_reply Error parsing: " << je.filename()
200 <<
" on line: " << je.line() << std::endl;
201 std::cerr << je.message() << std::endl;
ontology_superclasses_of(const std::string ontology_class, bool recursive, std::function< void(std::vector< std::string >)> callback, std::string token)
std::string header_
Header that will be used.
query if sub class is a super class of param
get ontology super-classes of query
std::string post_
Actual post Data.
get ontology subclass of a query
std::function< void(std::vector< std::string > classes)> delegate__
The callback called upon completion of receiving the detected faces.
void handle_reply(std::string json)
handle and parse JSON reply
std::function< void(std::string)> callback_
Callback Handler - use with std::bind or boost variant.
ontology_is_subsuperclass_of(const std::string parent_class, const std::string child_class, bool recursive, std::function< void(bool result)> callback, const std::string token)
query if a class is the superclass of a subclass
void handle_reply(std::string json)
handle and parse JSON reply
ontology_subclasses_of(std::string ontology_class, bool recursive, std::function< void(std::vector< std::string >)> callback, std::string token)
constructor for this handler
base class for asynchronous http websockets used for connecting to cloud services ...
std::function< void(std::vector< std::string > classes)> delegate__
The callback called upon completion of receiving the detected faces.
std::function< void(bool result)> delegate__
The callback called upon completion of receiving the detected faces.
void handle_reply(std::string json)
handle and parse JSON reply