// This file is generated by TypeBuilder_h.template.

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef content_protocol_Schema_h
#define content_protocol_Schema_h

#include "content/common/content_export.h"
#include "content/browser/devtools/protocol/protocol.h"
// For each imported domain we generate a ValueConversions struct instead of a full domain definition
// and include Domain::API version from there.

namespace content {
namespace protocol {
namespace Schema {
class Domain;

// ------------- Forward and enum declarations.

// ------------- Type and builder declarations.

class CONTENT_EXPORT Domain : public ::crdtp::ProtocolObject<Domain> {
public:
    ~Domain() override;  // Defined below

    String GetName() { return m_name; }
    void SetName(const String& value);  // Defined below

    String GetVersion() { return m_version; }
    void SetVersion(const String& value);  // Defined below

    template<int STATE>
    class DomainBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            NameSet = 1 << 1,
            VersionSet = 1 << 2,
            AllFieldsSet = (NameSet | VersionSet | 0)};


        DomainBuilder<STATE | NameSet>& SetName(const String& value);  // Defined below

        DomainBuilder<STATE | VersionSet>& SetVersion(const String& value);  // Defined below

        std::unique_ptr<Domain> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class Domain;
        DomainBuilder() : m_result(new Domain()) { }

        template<int STEP> DomainBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<DomainBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Schema::Domain> m_result;
    };

    static DomainBuilder<0> Create()
    {
        return DomainBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    Domain();  // Defined below

    String m_name;
    String m_version;
};


// ------------- Type and builder method definitions.
//
// These methods separate from the type declaration because of
// https://github.com/llvm/llvm-project/issues/59966. The DevTools protocol has
// mutually recursive types, so we cannot simply reorder the types.
inline Domain::~Domain() = default;
inline void Domain::SetName(const String& value) { m_name = value; }
inline void Domain::SetVersion(const String& value) { m_version = value; }

template<int STATE>
inline Domain::DomainBuilder<STATE | Domain::DomainBuilder<STATE>::NameSet>&
Domain::DomainBuilder<STATE>::SetName(const String& value) {
  static_assert(!(STATE & NameSet), "property name should not be set yet");
  m_result->SetName(value);
  return castState<NameSet>();
}
template<int STATE>
inline Domain::DomainBuilder<STATE | Domain::DomainBuilder<STATE>::VersionSet>&
Domain::DomainBuilder<STATE>::SetVersion(const String& value) {
  static_assert(!(STATE & VersionSet), "property version should not be set yet");
  m_result->SetVersion(value);
  return castState<VersionSet>();
}

inline Domain::Domain() {
}

// ------------- Backend interface.

class CONTENT_EXPORT Backend {
public:
    virtual ~Backend() { }

    virtual DispatchResponse GetDomains(std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* out_domains) = 0;

    virtual DispatchResponse Disable()
    {
        return DispatchResponse::Success();
    }
};

// ------------- Frontend interface.

class CONTENT_EXPORT Frontend {
public:
  explicit Frontend(FrontendChannel* frontend_channel) : frontend_channel_(frontend_channel) {}

  void flush();
  void sendRawNotification(std::unique_ptr<Serializable>);
 private:
  FrontendChannel* frontend_channel_;
};

// ------------- Dispatcher.

class CONTENT_EXPORT Dispatcher {
public:
    static void wire(UberDispatcher*, Backend*);

private:
    Dispatcher() { }
};

// ------------- Metainfo.

class CONTENT_EXPORT Metainfo {
public:
    using BackendClass = Backend;
    using FrontendClass = Frontend;
    using DispatcherClass = Dispatcher;
    static const char domainName[];
    static const char commandPrefix[];
    static const char version[];
};

} // namespace Schema
} // namespace content
} // namespace protocol

#endif // !defined(content_protocol_Schema_h)
