chromium/third_party/ipcz/src/ipcz/api_object.h

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

#ifndef IPCZ_SRC_IPCZ_API_OBJECT_H_
#define IPCZ_SRC_IPCZ_API_OBJECT_H_

#include "ipcz/ipcz.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#include "util/ref_counted.h"

namespace ipcz {

class Router;

// Base class for any object which can be referenced by an IpczHandle.
//
// A subclass T should inherit from APIObjectImpl<T, U> rather than inheriting
// this base class directly. See APIObjectImpl below.
class APIObject : public RefCounted<APIObject> {};

// Strongly-typed base class for any object which can be referenced by an
// IpczHandle. This is templated over the more specific subclass type, as well
// as an appropriate ObjectType value to use for runtime type idenitification.
template <typename T, APIObject::ObjectType kType>
class APIObjectImpl : public APIObject {};

}  // namespace ipcz

#endif  // IPCZ_SRC_IPCZ_API_OBJECT_H_