chromium/ui/ozone/platform/wayland/common/wayland_object.h

// 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 UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_
#define UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_

#include <memory>

#include "base/check.h"
#include "ui/ozone/platform/wayland/common/wayland.h"

struct wl_proxy;

namespace ui {
class WaylandConnection;
}

namespace wl {

template <typename T>
struct ObjectTraits;

GlobalObjectFactory;

// This template forces T to declare a static Instantiate() method.  The
// subclass must implement it as follows:
//
// void Instantiate(WaylandConnection* connection,
//                  wl_registry* registry,
//                  uint32_t name,
//                  const std::string& interface,
//                  uint32_t version)
// - must bind the Wayland object and store it in the connection.
template <typename T>
class GlobalObjectRegistrar {};

struct Deleter {};

template <typename T>
class Object : public std::unique_ptr<T, Deleter> {};

template <typename T>
wl::Object<T> Bind(wl_registry* registry, uint32_t name, uint32_t version) {}

template <>
struct ObjectTraits<wl_proxy> {};

// Checks the given |available_version| exposed by the server against
// |min_version| and |max_version| supported by the client.
// Returns false (with rendering a warning) if |available_version| is less than
// the minimum supported version.
// Returns true otherwise, renders an info message if |available_version| is
// greater than the maximum supported one.
bool CanBind(const std::string& interface,
             uint32_t available_version,
             uint32_t min_version,
             uint32_t max_version);

}  // namespace wl

// Puts the forward declaration for struct TYPE and declares the template
// specialisation of ObjectTraits<TYPE>.
#define DECLARE_WAYLAND_OBJECT_TRAITS(TYPE)

// For convenience, keep aphabetical order in this list.
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()
DECLARE_WAYLAND_OBJECT_TRAITS()

#endif  // UI_OZONE_PLATFORM_WAYLAND_COMMON_WAYLAND_OBJECT_H_