Line data Source code
1 : // This file is generated by TypeBuilder_h.template.
2 :
3 : // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 : // Use of this source code is governed by a BSD-style license that can be
5 : // found in the LICENSE file.
6 :
7 : #ifndef v8_inspector_protocol_Schema_h
8 : #define v8_inspector_protocol_Schema_h
9 :
10 : #include "src/inspector/protocol/Protocol.h"
11 : // For each imported domain we generate a ValueConversions struct instead of a full domain definition
12 : // and include Domain::API version from there.
13 : #include "include/inspector/Schema.h"
14 :
15 : namespace v8_inspector {
16 : namespace protocol {
17 : namespace Schema {
18 :
19 : // ------------- Forward and enum declarations.
20 : class Domain;
21 :
22 : // ------------- Type and builder declarations.
23 :
24 : class Domain : public Serializable, public API::Domain{
25 : PROTOCOL_DISALLOW_COPY(Domain);
26 : public:
27 : static std::unique_ptr<Domain> fromValue(protocol::Value* value, ErrorSupport* errors);
28 :
29 0 : ~Domain() override { }
30 :
31 : String getName() { return m_name; }
32 : void setName(const String& value) { m_name = value; }
33 :
34 : String getVersion() { return m_version; }
35 : void setVersion(const String& value) { m_version = value; }
36 :
37 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
38 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
39 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
40 : String toJSON() const { return toValue()->toJSONString(); }
41 : std::unique_ptr<Domain> clone() const;
42 : std::unique_ptr<StringBuffer> toJSONString() const override;
43 : void writeBinary(std::vector<uint8_t>* out) const override;
44 :
45 : template<int STATE>
46 0 : class DomainBuilder {
47 : public:
48 : enum {
49 : NoFieldsSet = 0,
50 : NameSet = 1 << 1,
51 : VersionSet = 1 << 2,
52 : AllFieldsSet = (NameSet | VersionSet | 0)};
53 :
54 :
55 : DomainBuilder<STATE | NameSet>& setName(const String& value)
56 : {
57 : static_assert(!(STATE & NameSet), "property name should not be set yet");
58 : m_result->setName(value);
59 : return castState<NameSet>();
60 : }
61 :
62 : DomainBuilder<STATE | VersionSet>& setVersion(const String& value)
63 : {
64 : static_assert(!(STATE & VersionSet), "property version should not be set yet");
65 : m_result->setVersion(value);
66 : return castState<VersionSet>();
67 : }
68 :
69 : std::unique_ptr<Domain> build()
70 : {
71 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
72 : return std::move(m_result);
73 : }
74 :
75 : private:
76 : friend class Domain;
77 0 : DomainBuilder() : m_result(new Domain()) { }
78 :
79 : template<int STEP> DomainBuilder<STATE | STEP>& castState()
80 : {
81 : return *reinterpret_cast<DomainBuilder<STATE | STEP>*>(this);
82 : }
83 :
84 : std::unique_ptr<protocol::Schema::Domain> m_result;
85 : };
86 :
87 : static DomainBuilder<0> create()
88 : {
89 0 : return DomainBuilder<0>();
90 : }
91 :
92 : private:
93 : Domain()
94 0 : {
95 : }
96 :
97 : String m_name;
98 : String m_version;
99 : };
100 :
101 :
102 : // ------------- Backend interface.
103 :
104 3879 : class Backend {
105 : public:
106 3879 : virtual ~Backend() { }
107 :
108 : virtual DispatchResponse getDomains(std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* out_domains) = 0;
109 :
110 0 : virtual DispatchResponse disable()
111 : {
112 0 : return DispatchResponse::OK();
113 : }
114 : };
115 :
116 : // ------------- Frontend interface.
117 :
118 : class Frontend {
119 : public:
120 3879 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
121 :
122 : void flush();
123 : void sendRawNotification(String);
124 : void sendRawNotification(std::vector<uint8_t>);
125 : private:
126 : FrontendChannel* m_frontendChannel;
127 : };
128 :
129 : // ------------- Dispatcher.
130 :
131 : class Dispatcher {
132 : public:
133 : static void wire(UberDispatcher*, Backend*);
134 :
135 : private:
136 : Dispatcher() { }
137 : };
138 :
139 : // ------------- Metainfo.
140 :
141 : class Metainfo {
142 : public:
143 : using BackendClass = Backend;
144 : using FrontendClass = Frontend;
145 : using DispatcherClass = Dispatcher;
146 : static const char domainName[];
147 : static const char commandPrefix[];
148 : static const char version[];
149 : };
150 :
151 : } // namespace Schema
152 : } // namespace v8_inspector
153 : } // namespace protocol
154 :
155 : #endif // !defined(v8_inspector_protocol_Schema_h)
|