5SOIL::Common::Common(std::shared_ptr<Common> parent, std::string uuid, std::string name, std::string description, std::string ontology) : parent(parent), uuid(uuid), name(name), description(description), ontology(ontology)
24#pragma warning( push )
25#pragma warning( disable : 4717)
28 std::vector<std::string> parent_fqid;
29 if (parent.use_count() > 0)
31 parent_fqid = parent->fqid();
33 parent_fqid.push_back(uuid);
40 if (fqid ==
"" || fqid ==
"/")
44 size_t path_length = fqid.size();
47 fqid = fqid.substr(1, path_length-1);
50 size_t first_delimiter = fqid.find(
"/");
51 if (first_delimiter == std::string::npos)
53 if (children.count(fqid) == 0)
55 if (this->uuid == fqid)
59 throw std::runtime_error(fqid +
" does not match any children of " + uuid);
61 return children[fqid];
65 std::string dock_off_path = fqid.substr(0, first_delimiter);
66 std::string continue_path = fqid.substr(first_delimiter + 1, path_length - first_delimiter - 1);
67 if (children.count(dock_off_path) == 0)
69 if (this->uuid == dock_off_path)
71 return (*self)[continue_path];
73 throw std::runtime_error(dock_off_path +
" does not match any children of " + uuid);
75 return (*children[dock_off_path])[continue_path];
81 bool exists = children.count(uuid) > 0;
82 children[uuid] = child;
88 return insert(uuid, std::shared_ptr<Common>(child));
93 bool exists = children.count(uuid) > 0;
100 return (uuid.substr(0, 3) ==
"OBJ");
105 return (uuid.substr(0, 3) ==
"VAR");
110 return (uuid.substr(0, 3) ==
"FUN");
115 return (uuid.substr(0, 3) ==
"PAR");
126 json_root[L
"ontology"] = HTTP::Json::null();
139 return utility::conversions::to_utf8string(content.serialize());
147 std::string path =
"";
148 if (match.size() > 0)
150 path = utility::conversions::to_utf8string(match.str(0));
153 size_t query_delimiter = path.find(
"?");
154 std::shared_ptr<Common> resource = (*self)[path.substr(0, query_delimiter)];
156 if (resource == self)
158 return Resource::handle(request, match);
162 return resource->Resource::handle(request, match);
166 catch (std::exception& exception)
168 return Resource::handle_exception(request, exception, match);
virtual std::string json(void)
bool is_function(void) const
bool is_parameter(void) const
virtual HTTP::Json wjson(void)
std::vector< std::string > fqid(void)
bool insert(std::string uuid, std::shared_ptr< Common > &child)
bool is_object(void) const
Common(std::shared_ptr< Common > parent, std::string uuid, std::string name, std::string description, std::string ontology="")
bool remove(std::string uuid)
std::shared_ptr< Common > operator[](std::string fqid)
std::shared_ptr< Common > parent
bool is_variable(void) const
HTTP::Response handle(HTTP::Request request, std::wsmatch match=std::wsmatch())
HTTP Handler.
std::shared_ptr< Common > self
web::json::value Json
HTTP JSON.
web::http::http_request Request
HTTP Request.
web::http::http_response Response
HTTP Response.
void null_deleter(SOIL::Common *)
DLL web::json::value to_json(const T &value)