1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/catalog/dependency.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/common.hpp"
12#include "duckdb/common/unordered_set.hpp"
13
14namespace duckdb {
15class CatalogEntry;
16
17enum class DependencyType {
18 DEPENDENCY_REGULAR = 0,
19 DEPENDENCY_AUTOMATIC = 1,
20 DEPENDENCY_OWNS = 2,
21 DEPENDENCY_OWNED_BY = 3
22};
23
24struct Dependency {
25 Dependency(CatalogEntry &entry, DependencyType dependency_type = DependencyType::DEPENDENCY_REGULAR)
26 : // NOLINT: Allow implicit conversion from `CatalogEntry`
27 entry(entry), dependency_type(dependency_type) {
28 }
29
30 //! The catalog entry this depends on
31 reference<CatalogEntry> entry;
32 //! The type of dependency
33 DependencyType dependency_type;
34};
35
36struct DependencyHashFunction {
37 uint64_t operator()(const Dependency &a) const {
38 std::hash<void *> hash_func;
39 return hash_func((void *)&a.entry.get());
40 }
41};
42
43struct DependencyEquality {
44 bool operator()(const Dependency &a, const Dependency &b) const {
45 return RefersToSameObject(A: a.entry, B: b.entry);
46 }
47};
48using dependency_set_t = unordered_set<Dependency, DependencyHashFunction, DependencyEquality>;
49
50} // namespace duckdb
51