5SOIL::Element::Element(std::shared_ptr<Element> 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];
79std::shared_ptr<SOIL::Element>
SOIL::Element::add(std::string uuid, std::shared_ptr<Element> child)
81 bool exists = children.count(uuid) > 0;
82 children[uuid] = child;
88 return add(uuid, std::shared_ptr<Element>(child));
93 bool exists = children.count(uuid) > 0;
94 this->add(uuid, child);
100 return insert(uuid, std::shared_ptr<Element>(child));
105 bool exists = children.count(uuid) > 0;
106 children.erase(uuid);
112 return (uuid.substr(0, 3) ==
"OBJ");
117 return (uuid.substr(0, 3) ==
"VAR");
122 return (uuid.substr(0, 3) ==
"FUN");
127 return (uuid.substr(0, 3) ==
"PAR");
138 json_root[U(
"ontology")] = HTTP::Json::null();
151 return utility::conversions::to_utf8string(content.serialize());
159 std::string path =
"";
160 if (match.size() > 0)
165 size_t query_delimiter = path.find(
"?");
166 std::shared_ptr<Element> resource = (*self)[path.substr(0, query_delimiter)];
168 if (resource == self)
170 return Resource::handle(request, match);
174 return resource->Resource::handle(request, match);
178 catch (std::exception& exception)
180 return Resource::handle_exception(request, exception, match);
bool insert(std::string uuid, std::shared_ptr< Element > child)
Add Child Element.
HTTP::Response handle(HTTP::Request request, std::smatch match=std::smatch())
HTTP Handler.
std::shared_ptr< Element > operator[](std::string fqid)
Access Operator.
virtual ~Element()
Destructor.
bool is_parameter(void) const
Is Parameter?
std::shared_ptr< Element > add(std::string uuid, std::shared_ptr< Element > child)
Add Child Element.
std::string uuid
Local UUID.
bool is_object(void) const
Is Object?
virtual HTTP::Json wjson(void)
HTTP JSON.
bool is_variable(void) const
Is Variable?
bool is_function(void) const
Is Function?
std::vector< std::string > fqid(void)
FQID.
virtual std::string json(void)
JSON string.
Element(std::shared_ptr< Element > parent, std::string uuid, std::string name, std::string description, std::string ontology="")
Constructor.
bool remove(std::string uuid)
Remove Child element.
std::shared_ptr< Element > parent
Parent Pointer.
std::shared_ptr< Element > self
Self Pointer.
web::json::value Json
HTTP JSON.
web::http::http_request Request
HTTP Request.
web::http::http_response Response
HTTP Response.
DLL web::json::value to_json(const T &value)
Value to JSON.
void null_deleter(SOIL::Element *ptr)
Null deleter.