2 #include <ossia/network/base/protocol.hpp>
3 #include <ossia/network/generic/wrapped_parameter.hpp>
5 #include <ossia-qt/js_utilities.hpp>
16 class QNetworkAccessManager;
22 struct http_parameter_data_base
24 http_parameter_data_base() =
default;
25 http_parameter_data_base(
const http_parameter_data_base&) =
default;
26 http_parameter_data_base(http_parameter_data_base&&) =
default;
27 http_parameter_data_base& operator=(
const http_parameter_data_base&) =
default;
28 http_parameter_data_base& operator=(http_parameter_data_base&&) =
default;
29 http_parameter_data_base(
const QJSValue& val)
31 auto r = val.property(
"request");
34 request = r.toString();
36 auto a = val.property(
"answer");
48 struct http_parameter_data
49 :
public parameter_data
50 ,
public http_parameter_data_base
52 using base_data_type = http_parameter_data_base;
53 http_parameter_data() =
default;
54 http_parameter_data(
const http_parameter_data&) =
default;
55 http_parameter_data(http_parameter_data&&) =
default;
56 http_parameter_data& operator=(
const http_parameter_data&) =
default;
57 http_parameter_data& operator=(http_parameter_data&&) =
default;
59 http_parameter_data(
const std::string& name)
60 : parameter_data{name}
64 http_parameter_data(
const QJSValue& val)
65 : parameter_data{
ossia::qt::make_parameter_data(val)}
66 , http_parameter_data_base{val}
70 bool valid() const noexcept {
return !request.isEmpty() || type; }
73 using http_parameter = wrapped_parameter<http_parameter_data>;
74 using http_node = ossia::net::wrapped_node<http_parameter_data, http_parameter>;
75 class OSSIA_EXPORT http_protocol final
79 W_OBJECT(http_protocol)
82 http_protocol(QByteArray code);
84 http_protocol(
const http_protocol&) =
delete;
85 http_protocol(http_protocol&&) =
delete;
86 http_protocol& operator=(
const http_protocol&) =
delete;
87 http_protocol& operator=(http_protocol&&) =
delete;
89 ~http_protocol()
override;
103 static http_parameter_data read_data(
const QJSValue& js) {
return js; }
106 void sig_push(
const http_parameter* arg_1,
const ossia::value& v)
107 E_SIGNAL(OSSIA_EXPORT, sig_push, arg_1, v)
109 private :
void slot_push(
const http_parameter*,
const ossia::value& v);
113 void apply_reply(QJSValue);
115 QQmlEngine* m_engine{};
116 QQmlComponent* m_component{};
118 QNetworkAccessManager* m_access{};
122 ossia::hash_map<QNetworkReply*, const http_parameter*> m_replies;
124 using http_device = ossia::net::wrapped_device<http_node, http_protocol>;
125 class OSSIA_EXPORT HTTP :
public QObject
130 Q_DECLARE_METATYPE(ossia::net::http_parameter*)
131 W_REGISTER_ARGTYPE(ossia::net::http_parameter*)
132 W_REGISTER_ARGTYPE(
const ossia::net::http_parameter*)
Root of a device tree.
Definition: ossia/network/base/device.hpp:58
The node_base class.
Definition: network/base/node.hpp:48
The parameter_base class.
Definition: ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition: protocol.hpp:40
The value class.
Definition: value.hpp:173
Full information about a parameter.
Definition: parameter_data.hpp:61