Nebula
Loading...
Searching...
No Matches
database.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11//------------------------------------------------------------------------------
12#include "core/refcounted.h"
13#include "util/arrayallocator.h"
14#include "table.h"
15#include "util/stringatom.h"
17#include "attributeid.h"
18#include "attributeregistry.h"
19#include "dataset.h"
20#include "filterset.h"
21#include "util/blob.h"
22
23namespace MemDb
24{
25class Database;
26
28{
30
31public:
33 Database();
35 ~Database();
36
40 void DeleteTable(TableId table);
42 bool IsValid(TableId table) const;
46 TableId FindTable(TableSignature const& signature) const;
48 SizeT GetNumTables() const;
50 void ForEachTable(std::function<void(TableId)> const& callback);
51
53 void Reset();
54
56 Dataset Query(FilterSet const& filterset);
58 Util::Array<TableId> Query(TableSignature const& inclusive, TableSignature const& exclusive);
59
61 void Copy(Ptr<MemDb::Database> const& dst) const;
62
63 // @note Keep this a fixed size array, because we want to be able to keep persistent references to the tables, and their buffers within
64 static constexpr uint32_t MAX_NUM_TABLES = 512;
65
66private:
69
72
75};
76
77//------------------------------------------------------------------------------
80inline SizeT
82{
83 return this->numTables;
84}
85
86} // namespace MemDb
The common base class of Nebula.
Definition refcounted.h:38
Provides a system for creating array friendly id numbers with reuse and generations.
Definition idgenerationpool.h:43
Definition database.h:28
Ids::IdGenerationPool tableIdPool
id pool for table ids
Definition database.h:68
void Copy(Ptr< MemDb::Database > const &dst) const
copy the database into dst
Definition database.cc:227
SizeT numTables
number of tables existing currently
Definition database.h:74
bool IsValid(TableId table) const
check if table is valid
Definition database.cc:84
void Reset()
performs Clean on all tables.
Definition database.cc:121
static constexpr uint32_t MAX_NUM_TABLES
Definition database.h:64
void ForEachTable(std::function< void(TableId)> const &callback)
run a callback for each table in the db
Definition database.cc:289
Table tables[MAX_NUM_TABLES]
all tables within the database
Definition database.h:71
Table & GetTable(TableId tid)
retrieve a table.
Definition database.cc:93
TableId FindTable(TableSignature const &signature) const
find table by signature
Definition database.cc:103
void DeleteTable(TableId table)
delete table
Definition database.cc:72
TableId CreateTable(TableCreateInfo const &info)
create new table
Definition database.cc:40
__DeclareClass(MemDb::Database)
Dataset Query(FilterSet const &filterset)
Query the database for a dataset of tables.
Definition database.cc:133
~Database()
destructor
Definition database.cc:27
Database()
constructor
Definition database.cc:19
SizeT GetNumTables() const
retrieve the number of tables
Definition database.h:81
Definition filterset.h:20
Definition table.h:44
Basically a bitfield with packed ComponentIds.
Definition tablesignature.h:26
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
Contains declarations for tables.
Attribute.
Definition attribute.h:26
Definition dataset.h:20
information for creating a table
Definition table.h:31
Table identifier.
Definition tableid.h:14
int SizeT
Definition types.h:49