Relational NT
A relational database kernel shaped around NT-style object management.
Loading...
Searching...
No Matches
ObjectManager.h
Go to the documentation of this file.
1#pragma once
2
3#include "Api.h"
4#include "Types.h"
5
6#include <cstdint>
7#include <functional>
8#include <map>
9#include <memory>
10#include <set>
11#include <string>
12#include <vector>
13
18
19namespace nt {
28 public:
30 class IObject {
31 public:
32 virtual ~IObject() = default;
33 };
34
52 class Multigroup : public IObject {
53 public:
54 std::string merkle_root;
55 };
56
63 class Relation : public IObject {
64 public:
65 std::string merkle_root;
66 };
67
96 class EphemeralRelation : public IObject {
97 public:
98 std::string merkle_root;
99 std::vector<std::string> dependencies;
100 };
101
102 class Transaction : public IObject {};
103
125 class Session : public IObject {
126 public:
127 void* connection_context = nullptr;
128 std::map<std::string, std::string> branch_overrides;
129 };
130
147 class Branch : public IObject {
148 public:
149 std::string name;
150 std::string target_hash;
151 };
152
165 class BranchTree : public IObject {
166 public:
167 std::string merkle_root;
168 };
169
187 struct object_type {
196 std::set<METHOD> methods;
203 bool exclusive = false;
204
205 virtual ~object_type() = default;
206 };
207
226 enum class Cardinality { Finite, ConstrainedFinite, AlephZero, Continuum };
227
234 using Generator = std::function<std::vector<Tuple>(
235 const std::vector<std::string>& args, std::size_t offset, std::size_t limit)>;
236
237 Cardinality cardinality;
238 Generator generator;
239 };
240
275 uint32_t reference_count = 0;
277 uint32_t handle_count = 0;
279 std::unique_ptr<object_type> type;
281 std::vector<std::string> path;
282 };
283
285 struct registry {
287 std::unique_ptr<registry_head> head;
289 std::unique_ptr<IObject> object;
299 std::unique_ptr<registry> next;
300 };
301
303 std::unique_ptr<registry> entries;
304
311 void Register(std::vector<std::string> path, std::unique_ptr<IObject> object,
312 std::unique_ptr<object_type> type);
313
319 registry* Find(const std::vector<std::string> object_path);
320
333 bool Unregister(const std::vector<std::string>& object_path);
334 };
335} // namespace nt
Defines symbol visibility for the Relational NT public API.
Shared enum types and core data types used by the runtime.
OBJECT_TYPE
Runtime object categories known by the object manager.
Definition Types.h:14
Registry object for a branch-tree blob.
Definition ObjectManager.h:165
A named mutable reference to a branch-tree root.
Definition ObjectManager.h:147
Registry object representing an ephemeral relation.
Definition ObjectManager.h:96
Base type for objects stored in the registry.
Definition ObjectManager.h:30
Registry object representing a multigroup snapshot.
Definition ObjectManager.h:52
Registry object representing a stored relation.
Definition ObjectManager.h:63
Registry object representing an active connection's session.
Definition ObjectManager.h:125
Abstract registry object representing a transaction.
Definition ObjectManager.h:102
Owns the registry used to locate and reference database objects.
Definition ObjectManager.h:27
void Register(std::vector< std::string > path, std::unique_ptr< IObject > object, std::unique_ptr< object_type > type)
Registers an object under the given path, taking ownership of it.
Definition ObjectManager.cpp:4
std::unique_ptr< registry > entries
Head of the registry linked list.
Definition ObjectManager.h:303
bool Unregister(const std::vector< std::string > &object_path)
Removes the entry registered at object_path, if any.
Definition ObjectManager.cpp:29
registry * Find(const std::vector< std::string > object_path)
Looks into this registry and attempts to retrieve an entry.
Definition ObjectManager.cpp:19
Contains the Relational NT runtime managers and API facade.
Object type descriptor for EPHEMERAL_RELATION objects.
Definition ObjectManager.h:225
std::function< std::vector< Tuple >( const std::vector< std::string > &args, std::size_t offset, std::size_t limit)> Generator
Produces a page of tuples for the given bound arguments.
Definition ObjectManager.h:234
Describes the behavior and capabilities of an object category.
Definition ObjectManager.h:187
bool exclusive
When true, only one write-mode handle may be open at a time.
Definition ObjectManager.h:203
std::set< METHOD > methods
Methods supported by this object type.
Definition ObjectManager.h:196
bool disposable
True when the object is not durable.
Definition ObjectManager.h:191
OBJECT_TYPE label
Object category label.
Definition ObjectManager.h:189
Shared metadata stored at the head of a registry entry.
Definition ObjectManager.h:268
uint32_t reference_count
Structural dependency count.
Definition ObjectManager.h:275
std::vector< std::string > path
Logical object path inside the namespace.
Definition ObjectManager.h:281
std::unique_ptr< object_type > type
Object type metadata.
Definition ObjectManager.h:279
uint32_t handle_count
Number of open handles.
Definition ObjectManager.h:277
Node in the object registry.
Definition ObjectManager.h:285
std::unique_ptr< registry > next
Next entry in the registry.
Definition ObjectManager.h:299
std::unique_ptr< IObject > object
Abstract object payload.
Definition ObjectManager.h:289
std::unique_ptr< registry_head > head
Shared metadata for this object.
Definition ObjectManager.h:287