C++ Unified Device Interface
Common.h
Go to the documentation of this file.
1#pragma once
2#include "constants.h"
3#include "REST\constants.h"
4#include <memory>
5#include <vector>
6#include <map>
7#include <mutex>
8#include <REST\Resource.h>
9#include <regex>
10#include <string>
11
12namespace SOIL
13{
14 class DLL Common : public HTTP::Resource
15 {
16 private:
17 public:
18 std::map<std::string, std::shared_ptr<Common> > children;
19 std::shared_ptr<Common> parent;
20 std::shared_ptr<Common> self;
21 std::string uuid;
22 std::string name;
23 std::string description;
24 std::string ontology;
25
26 std::recursive_mutex mutex;
27 Common(std::shared_ptr<Common> parent, std::string uuid, std::string name, std::string description, std::string ontology ="");
28 virtual ~Common();
29
30 std::vector<std::string> fqid(void);
31 std::shared_ptr<Common> operator[] (std::string fqid);
32 bool insert(std::string uuid, std::shared_ptr<Common>& child);
33 bool insert(std::string uuid, Common* child);
34 bool remove(std::string uuid);
35 template<typename T> T* cast(void);
36
37 bool is_object(void) const;
38 bool is_variable(void) const;
39 bool is_function(void) const;
40 bool is_parameter(void) const;
41
42 virtual HTTP::Json wjson(void);
43 virtual std::string json(void);
44
45 HTTP::Response handle(HTTP::Request request, std::wsmatch match = std::wsmatch());
46
47 };
48 template<typename T>
49 T* Common::cast(void)
50 {
51 return dynamic_cast<T*>(self.get());
52 }
53
54 inline void null_deleter(SOIL::Common*) {};
55
56}
57
nlohmann::json json
HTTP Resource base class.
Definition: Resource.h:21
std::string description
Definition: Common.h:23
std::map< std::string, std::shared_ptr< Common > > children
Definition: Common.h:18
std::recursive_mutex mutex
Definition: Common.h:26
std::string name
Definition: Common.h:22
T * cast(void)
Definition: Common.h:49
std::shared_ptr< Common > parent
Definition: Common.h:19
std::shared_ptr< Common > self
Definition: Common.h:20
std::string ontology
Definition: Common.h:24
std::string uuid
Definition: Common.h:21
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
Definition: Common.h:13
void null_deleter(SOIL::Common *)
Definition: Common.h:54