Kùzu C++ API
Loading...
Searching...
No Matches
catalog_entry.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
6#include "assert.h"
7#include "copy_constructors.h"
8#include "serializer.h"
9#include "types.h"
10
11namespace kuzu {
12namespace main {
13class ClientContext;
14} // namespace main
15
16namespace catalog {
17
19public:
20 //===--------------------------------------------------------------------===//
21 // constructor & destructor
22 //===--------------------------------------------------------------------===//
23 CatalogEntry() = default;
24 CatalogEntry(CatalogEntryType type, std::string name)
25 : type{type}, name{std::move(name)}, timestamp{common::INVALID_TRANSACTION} {}
27 virtual ~CatalogEntry() = default;
28
29 //===--------------------------------------------------------------------===//
30 // getter & setter
31 //===--------------------------------------------------------------------===//
32 CatalogEntryType getType() const { return type; }
33 void rename(std::string name_) { this->name = std::move(name_); }
34 std::string getName() const { return name; }
35 common::transaction_t getTimestamp() const { return timestamp; }
36 void setTimestamp(common::transaction_t timestamp_) { this->timestamp = timestamp_; }
37 bool isDeleted() const { return deleted; }
38 void setDeleted(bool deleted_) { this->deleted = deleted_; }
39 bool hasParent() const { return hasParent_; }
40 void setHasParent(bool hasParent) { hasParent_ = hasParent; }
42 KU_ASSERT(prev);
43 return prev.get();
44 }
45 std::unique_ptr<CatalogEntry> movePrev() {
46 if (this->prev) {
47 this->prev->setNext(nullptr);
48 }
49 return std::move(prev);
50 }
51 void setPrev(std::unique_ptr<CatalogEntry> prev_) {
52 this->prev = std::move(prev_);
53 if (this->prev) {
54 this->prev->setNext(this);
55 }
56 }
57 CatalogEntry* getNext() const { return next; }
58 void setNext(CatalogEntry* next_) { this->next = next_; }
59
60 //===--------------------------------------------------------------------===//
61 // serialization & deserialization
62 //===--------------------------------------------------------------------===//
63 virtual void serialize(common::Serializer& serializer) const;
64 static std::unique_ptr<CatalogEntry> deserialize(common::Deserializer& deserializer);
65
66 virtual std::string toCypher(main::ClientContext* /*clientContext*/) const { KU_UNREACHABLE; }
67
68 template<class TARGET>
69 const TARGET& constCast() const {
70 return common::ku_dynamic_cast<const CatalogEntry&, const TARGET&>(*this);
71 }
72 template<class TARGET>
73 const TARGET* constPtrCast() const {
74 return common::ku_dynamic_cast<const CatalogEntry*, const TARGET*>(this);
75 }
76 template<class TARGET>
77 TARGET* ptrCast() {
78 return common::ku_dynamic_cast<CatalogEntry*, TARGET*>(this);
79 }
80
81protected:
82 virtual void copyFrom(const CatalogEntry& other);
83
84protected:
86 std::string name;
88 bool deleted = false;
89 bool hasParent_ = false;
90 // Older versions.
91 std::unique_ptr<CatalogEntry> prev;
92 // Newer versions.
93 CatalogEntry* next = nullptr;
94};
95
96} // namespace catalog
97} // namespace kuzu
#define KUZU_API
Definition api.h:25
#define KU_ASSERT(condition)
Definition assert.h:19
#define KU_UNREACHABLE
Definition assert.h:28
Definition catalog_entry.h:18
void setPrev(std::unique_ptr< CatalogEntry > prev_)
Definition catalog_entry.h:51
static std::unique_ptr< CatalogEntry > deserialize(common::Deserializer &deserializer)
void setTimestamp(common::transaction_t timestamp_)
Definition catalog_entry.h:36
void setNext(CatalogEntry *next_)
Definition catalog_entry.h:58
void setHasParent(bool hasParent)
Definition catalog_entry.h:40
virtual std::string toCypher(main::ClientContext *) const
Definition catalog_entry.h:66
CatalogEntry(CatalogEntryType type, std::string name)
Definition catalog_entry.h:24
bool isDeleted() const
Definition catalog_entry.h:37
virtual void serialize(common::Serializer &serializer) const
CatalogEntry()=default
DELETE_COPY_DEFAULT_MOVE(CatalogEntry)
bool hasParent() const
Definition catalog_entry.h:39
CatalogEntryType getType() const
Definition catalog_entry.h:32
common::transaction_t getTimestamp() const
Definition catalog_entry.h:35
const TARGET & constCast() const
Definition catalog_entry.h:69
void setDeleted(bool deleted_)
Definition catalog_entry.h:38
std::unique_ptr< CatalogEntry > movePrev()
Definition catalog_entry.h:45
void rename(std::string name_)
Definition catalog_entry.h:33
CatalogEntry * getNext() const
Definition catalog_entry.h:57
common::transaction_t timestamp
Definition catalog_entry.h:87
std::string name
Definition catalog_entry.h:86
CatalogEntry * getPrev() const
Definition catalog_entry.h:41
const TARGET * constPtrCast() const
Definition catalog_entry.h:73
std::string getName() const
Definition catalog_entry.h:34
TARGET * ptrCast()
Definition catalog_entry.h:77
virtual ~CatalogEntry()=default
CatalogEntryType type
Definition catalog_entry.h:85
virtual void copyFrom(const CatalogEntry &other)
std::unique_ptr< CatalogEntry > prev
Definition catalog_entry.h:91
Definition deserializer.h:15
Definition serializer.h:15
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:51
CatalogEntryType
Definition catalog_entry_type.h:9
uint64_t transaction_t
Definition types.h:57
Definition alter_type.h:5