chromium/third_party/perfetto/include/perfetto/trace_processor/ref_counted.h

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INCLUDE_PERFETTO_TRACE_PROCESSOR_REF_COUNTED_H_
#define INCLUDE_PERFETTO_TRACE_PROCESSOR_REF_COUNTED_H_

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "perfetto/base/logging.h"

// A non-thread-safe refcounted implementation.
// Unlike std::shared_ptr The target class needs to explicitly derive
// RefCounted.

// Usage:
// class MyRefcountedThing : public RefCounted {};
// ...
// RefPtr<MyRefcountedThing> shareable_ptr(new MyRefcountedThing());
// auto copy = shareable_ptr;

namespace perfetto {
namespace trace_processor {

// The base class that refcounted classes should inherit.
class RefCounted {};

// The RAII smart-pointer.
template <typename T>
class RefPtr {};

}  // namespace trace_processor
}  // namespace perfetto

#endif  // INCLUDE_PERFETTO_TRACE_PROCESSOR_REF_COUNTED_H_