Line data Source code
1 : // This file is generated
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 : // Description of the protocol domain.
21 : class Domain;
22 :
23 : // ------------- Type and builder declarations.
24 :
25 : // Description of the protocol domain.
26 : class Domain : public Serializable, public API::Domain{
27 : PROTOCOL_DISALLOW_COPY(Domain);
28 : public:
29 : static std::unique_ptr<Domain> fromValue(protocol::Value* value, ErrorSupport* errors);
30 :
31 0 : ~Domain() override { }
32 :
33 : String getName() { return m_name; }
34 : void setName(const String& value) { m_name = value; }
35 :
36 : String getVersion() { return m_version; }
37 : void setVersion(const String& value) { m_version = value; }
38 :
39 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
40 0 : String serialize() override { return toValue()->serialize(); }
41 : std::unique_ptr<Domain> clone() const;
42 : std::unique_ptr<StringBuffer> toJSONString() const override;
43 :
44 : template<int STATE>
45 : class DomainBuilder {
46 : public:
47 : enum {
48 : NoFieldsSet = 0,
49 : NameSet = 1 << 1,
50 : VersionSet = 1 << 2,
51 : AllFieldsSet = (NameSet | VersionSet | 0)};
52 :
53 :
54 : DomainBuilder<STATE | NameSet>& setName(const String& value)
55 : {
56 : static_assert(!(STATE & NameSet), "property name should not be set yet");
57 : m_result->setName(value);
58 : return castState<NameSet>();
59 : }
60 :
61 : DomainBuilder<STATE | VersionSet>& setVersion(const String& value)
62 : {
63 : static_assert(!(STATE & VersionSet), "property version should not be set yet");
64 : m_result->setVersion(value);
65 : return castState<VersionSet>();
66 : }
67 :
68 : std::unique_ptr<Domain> build()
69 : {
70 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
71 : return std::move(m_result);
72 : }
73 :
74 : private:
75 : friend class Domain;
76 0 : DomainBuilder() : m_result(new Domain()) { }
77 :
78 : template<int STEP> DomainBuilder<STATE | STEP>& castState()
79 : {
80 : return *reinterpret_cast<DomainBuilder<STATE | STEP>*>(this);
81 : }
82 :
83 : std::unique_ptr<protocol::Schema::Domain> m_result;
84 : };
85 :
86 : static DomainBuilder<0> create()
87 : {
88 0 : return DomainBuilder<0>();
89 : }
90 :
91 : private:
92 : Domain()
93 0 : {
94 : }
95 :
96 : String m_name;
97 : String m_version;
98 : };
99 :
100 :
101 : // ------------- Backend interface.
102 :
103 4573 : class Backend {
104 : public:
105 4573 : virtual ~Backend() { }
106 :
107 : virtual DispatchResponse getDomains(std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* out_domains) = 0;
108 :
109 0 : virtual DispatchResponse disable()
110 : {
111 0 : return DispatchResponse::OK();
112 : }
113 : };
114 :
115 : // ------------- Frontend interface.
116 :
117 : class Frontend {
118 : public:
119 4573 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
120 :
121 : void flush();
122 : void sendRawNotification(const String&);
123 : private:
124 : FrontendChannel* m_frontendChannel;
125 : };
126 :
127 : // ------------- Dispatcher.
128 :
129 : class Dispatcher {
130 : public:
131 : static void wire(UberDispatcher*, Backend*);
132 :
133 : private:
134 : Dispatcher() { }
135 : };
136 :
137 : // ------------- Metainfo.
138 :
139 : class Metainfo {
140 : public:
141 : using BackendClass = Backend;
142 : using FrontendClass = Frontend;
143 : using DispatcherClass = Dispatcher;
144 : static const char domainName[];
145 : static const char commandPrefix[];
146 : static const char version[];
147 : };
148 :
149 : } // namespace Schema
150 : } // namespace v8_inspector
151 : } // namespace protocol
152 :
153 : #endif // !defined(v8_inspector_protocol_Schema_h)
|