SOIL C++
C++ Unified Device Interface
Element.h
Go to the documentation of this file.
1#pragma once
2#include "constants.h"
3#include "REST/constants.h"
4#include "REST/Resource.h"
5#include <memory>
6#include <vector>
7#include <map>
8#include <mutex>
9#include <regex>
10#include <string>
11
12namespace SOIL
13{
23 class DLL Element : public HTTP::Resource
24 {
25 private:
26 public:
32 std::map<std::string, std::shared_ptr<Element> > children;
33
39 std::shared_ptr<Element> parent;
40
46 std::shared_ptr<Element> self;
47
53 std::string uuid;
54
60 std::string name;
61
67 std::string description;
68
76 std::string ontology;
77
83 std::recursive_mutex mutex;
84
96 Element(std::shared_ptr<Element> parent, std::string uuid, std::string name, std::string description, std::string ontology ="");
97
105 virtual ~Element();
106
113 std::vector<std::string> fqid(void);
114
126 std::shared_ptr<Element> operator[] (std::string fqid);
127
136 std::shared_ptr<Element> add(std::string uuid, std::shared_ptr<Element> child);
137
147 std::shared_ptr<Element> add(std::string uuid, Element* child);
148
158 bool insert(std::string uuid, std::shared_ptr<Element> child);
159
170 bool insert(std::string uuid, Element* child);
171
180 bool remove(std::string uuid);
181
191 template<typename T> T* cast(void);
192
201 bool is_object(void) const;
202
211 bool is_variable(void) const;
212
221 bool is_function(void) const;
222
231 bool is_parameter(void) const;
232
240 virtual HTTP::Json wjson(void);
241
249 virtual std::string json(void);
250
260 HTTP::Response handle(HTTP::Request request, std::smatch match = std::smatch());
261
262 };
263 template<typename T>
265 {
266 return dynamic_cast<T*>(self.get());
267 }
268
278 inline void null_deleter(SOIL::Element* ptr) {};
279
280}
281
nlohmann::json json
HTTP Resource base class.
Definition: Resource.h:21
SOIL Base Element.
Definition: Element.h:24
std::map< std::string, std::shared_ptr< Element > > children
Children Map.
Definition: Element.h:32
T * cast(void)
Get dynamically casted pointer.
Definition: Element.h:264
std::string uuid
Local UUID.
Definition: Element.h:53
std::string description
Description.
Definition: Element.h:67
std::string ontology
Ontology identifier.
Definition: Element.h:76
std::string name
Name.
Definition: Element.h:60
std::shared_ptr< Element > parent
Parent Pointer.
Definition: Element.h:39
std::recursive_mutex mutex
Element Mutex.
Definition: Element.h:83
std::shared_ptr< Element > self
Self Pointer.
Definition: Element.h:46
web::json::value Json
HTTP JSON.
Definition: Types.h:39
web::http::http_request Request
HTTP Request.
Definition: Types.h:11
web::http::http_response Response
HTTP Response.
Definition: Types.h:18
Type definitions.
Definition: Container.h:7
void null_deleter(SOIL::Element *ptr)
Null deleter.
Definition: Element.h:278