Joedb 9.1.3
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
tutorial::Database Class Reference

Store all the tables of the database. More...

#include <tutorial/Database.h>

Inheritance diagram for tutorial::Database:
Inheritance graph
[legend]
Collaboration diagram for tutorial::Database:
Collaboration graph
[legend]

Public Member Functions

void set_max_record_id (size_t record_id)
 
bool is_valid (id_of_city id) const
 
bool is_valid (id_of_person id) const
 
 Database ()
 
int64_t get_schema_checkpoint () const
 
void initialize_with_readonly_journal (joedb::Readonly_Journal &journal)
 
container_of_city get_city_table () const
 
id_of_city next (id_of_city id) const
 
id_of_city previous (id_of_city id) const
 
template<class Comparator >
std::vector< id_of_citysorted_city (Comparator comparator) const
 
const std::string & get_name (id_of_city record) const
 
container_of_person get_person_table () const
 
id_of_person next (id_of_person id) const
 
id_of_person previous (id_of_person id) const
 
template<class Comparator >
std::vector< id_of_personsorted_person (Comparator comparator) const
 
const std::string & get_first_name (id_of_person record) const
 
const std::string & get_last_name (id_of_person record) const
 
id_of_city get_home (id_of_person record) const
 
const std::map< std::string, id_of_city > & get_index_of_city_by_name ()
 
const std::multimap< std::tuple< std::string, std::string >, id_of_person > & get_index_of_person_by_name ()
 
id_of_city next_city_by_name (id_of_city id)
 
id_of_city previous_city_by_name (id_of_city id)
 
id_of_city find_city_by_name (const std::string &field_value_of_name) const
 
range_of_person_by_name find_person_by_name (const std::string &field_value_of_last_name, const std::string &field_value_of_first_name) const
 
- Public Member Functions inherited from joedb::Writable
 Writable (Commit_Level default_commit_level=Commit_Level::no_commit)
 
virtual void drop_table (Table_Id table_id)
 
virtual void rename_table (Table_Id table_id, const std::string &name)
 
virtual void add_field (Table_Id table_id, const std::string &name, Type type)
 
virtual void drop_field (Table_Id table_id, Field_Id field_id)
 
virtual void rename_field (Table_Id table_id, Field_Id field_id, const std::string &name)
 
virtual void flush ()
 
virtual void checkpoint (Commit_Level commit_level)
 
Commit_Level get_default_commit_level () const
 
void default_checkpoint ()
 
virtual void insert_into (Table_Id table_id, Record_Id record_id)
 
virtual void insert_vector (Table_Id table_id, Record_Id record_id, size_t size)
 
virtual void delete_from (Table_Id table_id, Record_Id record_id)
 
virtual void on_blob (Blob blob)
 
virtual bool wants_blob_data () const
 
virtual Blob write_blob_data (const std::string &data)
 
virtual ~Writable ()=default
 

Static Public Member Functions

template<typename E = joedb::Exception>
static void throw_exception (const std::string &message)
 
static id_of_city null_city ()
 
static id_of_person null_person ()
 

Public Attributes

size_t max_record_id
 
Table_Id current_table_id = Table_Id{0}
 

Protected Member Functions

bool is_valid_record_id_for_city (Record_Id record_id) const
 
bool is_valid_record_id_for_person (Record_Id record_id) const
 
void remove_index_of_city_by_name (Record_Id record_id)
 
void add_index_of_city_by_name (Record_Id record_id)
 
void remove_index_of_person_by_name (Record_Id record_id)
 
void add_index_of_person_by_name (Record_Id record_id)
 
void internal_delete_city (Record_Id record_id)
 
void internal_delete_person (Record_Id record_id)
 
void internal_insert_city (Record_Id record_id)
 
void internal_vector_insert_city (Record_Id record_id, size_t size)
 
void internal_insert_person (Record_Id record_id)
 
void internal_vector_insert_person (Record_Id record_id, size_t size)
 
void internal_update_city__name (Record_Id record_id, const std::string &field_value_of_name)
 
void internal_update_vector_city__name (Record_Id record_id, size_t size, const std::string *value)
 
void internal_update_person__first_name (Record_Id record_id, const std::string &field_value_of_first_name)
 
void internal_update_vector_person__first_name (Record_Id record_id, size_t size, const std::string *value)
 
void internal_update_person__last_name (Record_Id record_id, const std::string &field_value_of_last_name)
 
void internal_update_vector_person__last_name (Record_Id record_id, size_t size, const std::string *value)
 
void internal_update_person__home (Record_Id record_id, id_of_city field_value_of_home)
 
void internal_update_vector_person__home (Record_Id record_id, size_t size, const id_of_city *value)
 
void delete_from (Table_Id table_id, Record_Id record_id) final
 
void insert_into (Table_Id table_id, Record_Id record_id) final
 
void insert_vector (Table_Id table_id, Record_Id record_id, size_t size) final
 
void update_string (Table_Id table_id, Record_Id record_id, Field_Id field_id, const std::string &value) final
 
void update_reference (Table_Id table_id, Record_Id record_id, Field_Id field_id, joedb::Record_Id value) final
 
void update_vector_string (Table_Id table_id, Record_Id record_id, Field_Id field_id, size_t size, const std::string *value) final
 
void update_vector_reference (Table_Id table_id, Record_Id record_id, Field_Id field_id, size_t size, const joedb::Record_Id *value) final
 
std::string * get_own_string_storage (Table_Id table_id, Record_Id record_id, Field_Id field_id, size_t &capacity) final
 
joedb::Record_Idget_own_reference_storage (Table_Id table_id, Record_Id record_id, Field_Id field_id, size_t &capacity) final
 
void comment (const std::string &comment) override
 
void timestamp (int64_t timestamp) override
 
void valid_data () final
 
bool requires_schema_upgrade () const
 
void check_schema ()
 
void create_table (const std::string &name) override
 
void drop_table (Table_Id table_id) final
 
void rename_table (Table_Id table_id, const std::string &name) final
 
void add_field (Table_Id table_id, const std::string &name, joedb::Type type) override
 
void drop_field (Table_Id table_id, Field_Id field_id) final
 
void rename_field (Table_Id table_id, Field_Id field_id, const std::string &name) final
 
void custom (const std::string &name) override
 

Protected Attributes

detail::data_of_city storage_of_city
 
detail::data_of_person storage_of_person
 
std::map< std::string, id_of_cityindex_of_city_by_name
 
std::multimap< std::tuple< std::string, std::string >, id_of_personindex_of_person_by_name
 
bool upgrading_schema = false
 
joedb::Memory_File schema_file
 
joedb::Writable_Journal schema_journal
 

Friends

class Readable
 
class id_of_city
 
class container_of_city
 
class id_of_person
 
class container_of_person
 
class range_of_person_by_name
 

Detailed Description

Definition at line 100 of file Database.h.

Constructor & Destructor Documentation

◆ Database()

tutorial::Database::Database ( )
inline

Definition at line 669 of file Database.h.

Member Function Documentation

◆ add_field()

void tutorial::Database::add_field ( Table_Id  table_id,
const std::string &  name,
joedb::Type  type 
)
inlineoverrideprotected

Definition at line 634 of file Database.h.

◆ add_index_of_city_by_name()

void tutorial::Database::add_index_of_city_by_name ( Record_Id  record_id)
inlineprotected

Definition at line 143 of file Database.h.

◆ add_index_of_person_by_name()

void tutorial::Database::add_index_of_person_by_name ( Record_Id  record_id)
inlineprotected

Definition at line 174 of file Database.h.

◆ check_schema()

void tutorial::Database::check_schema ( )
inlineprotected

Definition at line 590 of file Database.h.

◆ comment()

void tutorial::Database::comment ( const std::string &  comment)
inlineoverrideprotectedvirtual

Reimplemented from joedb::Writable.

Definition at line 577 of file Database.h.

◆ create_table()

void tutorial::Database::create_table ( const std::string &  name)
inlineoverrideprotectedvirtual

Reimplemented from joedb::Writable.

Definition at line 611 of file Database.h.

◆ custom()

void tutorial::Database::custom ( const std::string &  name)
inlineoverrideprotectedvirtual

Reimplemented from joedb::Writable.

Definition at line 662 of file Database.h.

◆ delete_from()

void tutorial::Database::delete_from ( Table_Id  table_id,
Record_Id  record_id 
)
inlinefinalprotected

Definition at line 352 of file Database.h.

◆ drop_field()

void tutorial::Database::drop_field ( Table_Id  table_id,
Field_Id  field_id 
)
inlinefinalprotected

Definition at line 645 of file Database.h.

◆ drop_table()

void tutorial::Database::drop_table ( Table_Id  table_id)
inlinefinalprotected

Definition at line 618 of file Database.h.

◆ find_city_by_name()

id_of_city tutorial::Database::find_city_by_name ( const std::string &  field_value_of_name) const
inline

Definition at line 796 of file Database.h.

◆ find_person_by_name()

range_of_person_by_name tutorial::Database::find_person_by_name ( const std::string &  field_value_of_last_name,
const std::string &  field_value_of_first_name 
) const
inline

Definition at line 953 of file Database.h.

◆ get_city_table()

container_of_city tutorial::Database::get_city_table ( ) const
inline

Definition at line 850 of file Database.h.

◆ get_first_name()

const std::string & tutorial::Database::get_first_name ( id_of_person  record) const
inline

Definition at line 749 of file Database.h.

◆ get_home()

id_of_city tutorial::Database::get_home ( id_of_person  record) const
inline

Definition at line 761 of file Database.h.

◆ get_index_of_city_by_name()

const std::map< std::string, id_of_city > & tutorial::Database::get_index_of_city_by_name ( )
inline

Definition at line 767 of file Database.h.

◆ get_index_of_person_by_name()

const std::multimap< std::tuple< std::string, std::string >, id_of_person > & tutorial::Database::get_index_of_person_by_name ( )
inline

Definition at line 772 of file Database.h.

◆ get_last_name()

const std::string & tutorial::Database::get_last_name ( id_of_person  record) const
inline

Definition at line 755 of file Database.h.

◆ get_name()

const std::string & tutorial::Database::get_name ( id_of_city  record) const
inline

Definition at line 717 of file Database.h.

◆ get_own_reference_storage()

joedb::Record_Id * tutorial::Database::get_own_reference_storage ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
size_t &  capacity 
)
inlinefinalprotected

Definition at line 556 of file Database.h.

◆ get_own_string_storage()

std::string * tutorial::Database::get_own_string_storage ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
size_t &  capacity 
)
inlinefinalprotected

Definition at line 522 of file Database.h.

◆ get_person_table()

container_of_person tutorial::Database::get_person_table ( ) const
inline

Definition at line 908 of file Database.h.

◆ get_schema_checkpoint()

int64_t tutorial::Database::get_schema_checkpoint ( ) const
inline

Definition at line 674 of file Database.h.

◆ initialize_with_readonly_journal()

void tutorial::Database::initialize_with_readonly_journal ( joedb::Readonly_Journal journal)
inline

Definition at line 679 of file Database.h.

◆ insert_into()

void tutorial::Database::insert_into ( Table_Id  table_id,
Record_Id  record_id 
)
inlinefinalprotected

Definition at line 360 of file Database.h.

◆ insert_vector()

void tutorial::Database::insert_vector ( Table_Id  table_id,
Record_Id  record_id,
size_t  size 
)
inlinefinalprotected

Definition at line 383 of file Database.h.

◆ internal_delete_city()

void tutorial::Database::internal_delete_city ( Record_Id  record_id)
inlineprotected

Definition at line 187 of file Database.h.

◆ internal_delete_person()

void tutorial::Database::internal_delete_person ( Record_Id  record_id)
inlineprotected

Definition at line 194 of file Database.h.

◆ internal_insert_city()

void tutorial::Database::internal_insert_city ( Record_Id  record_id)
inlineprotected

Definition at line 204 of file Database.h.

◆ internal_insert_person()

void tutorial::Database::internal_insert_person ( Record_Id  record_id)
inlineprotected

Definition at line 220 of file Database.h.

◆ internal_update_city__name()

void tutorial::Database::internal_update_city__name ( Record_Id  record_id,
const std::string &  field_value_of_name 
)
inlineprotected

Definition at line 237 of file Database.h.

◆ internal_update_person__first_name()

void tutorial::Database::internal_update_person__first_name ( Record_Id  record_id,
const std::string &  field_value_of_first_name 
)
inlineprotected

Definition at line 267 of file Database.h.

◆ internal_update_person__home()

void tutorial::Database::internal_update_person__home ( Record_Id  record_id,
id_of_city  field_value_of_home 
)
inlineprotected

Definition at line 327 of file Database.h.

◆ internal_update_person__last_name()

void tutorial::Database::internal_update_person__last_name ( Record_Id  record_id,
const std::string &  field_value_of_last_name 
)
inlineprotected

Definition at line 297 of file Database.h.

◆ internal_update_vector_city__name()

void tutorial::Database::internal_update_vector_city__name ( Record_Id  record_id,
size_t  size,
const std::string *  value 
)
inlineprotected

Definition at line 249 of file Database.h.

◆ internal_update_vector_person__first_name()

void tutorial::Database::internal_update_vector_person__first_name ( Record_Id  record_id,
size_t  size,
const std::string *  value 
)
inlineprotected

Definition at line 279 of file Database.h.

◆ internal_update_vector_person__home()

void tutorial::Database::internal_update_vector_person__home ( Record_Id  record_id,
size_t  size,
const id_of_city value 
)
inlineprotected

Definition at line 337 of file Database.h.

◆ internal_update_vector_person__last_name()

void tutorial::Database::internal_update_vector_person__last_name ( Record_Id  record_id,
size_t  size,
const std::string *  value 
)
inlineprotected

Definition at line 309 of file Database.h.

◆ internal_vector_insert_city()

void tutorial::Database::internal_vector_insert_city ( Record_Id  record_id,
size_t  size 
)
inlineprotected

Definition at line 210 of file Database.h.

◆ internal_vector_insert_person()

void tutorial::Database::internal_vector_insert_person ( Record_Id  record_id,
size_t  size 
)
inlineprotected

Definition at line 226 of file Database.h.

◆ is_valid() [1/2]

bool tutorial::Database::is_valid ( id_of_city  id) const
inline

Definition at line 124 of file Database.h.

◆ is_valid() [2/2]

bool tutorial::Database::is_valid ( id_of_person  id) const
inline

Definition at line 125 of file Database.h.

◆ is_valid_record_id_for_city()

bool tutorial::Database::is_valid_record_id_for_city ( Record_Id  record_id) const
inlineprotected

Definition at line 129 of file Database.h.

◆ is_valid_record_id_for_person()

bool tutorial::Database::is_valid_record_id_for_person ( Record_Id  record_id) const
inlineprotected

Definition at line 131 of file Database.h.

◆ next() [1/2]

id_of_city tutorial::Database::next ( id_of_city  id) const
inline

Definition at line 693 of file Database.h.

◆ next() [2/2]

id_of_person tutorial::Database::next ( id_of_person  id) const
inline

Definition at line 725 of file Database.h.

◆ next_city_by_name()

id_of_city tutorial::Database::next_city_by_name ( id_of_city  id)
inline

Definition at line 777 of file Database.h.

◆ null_city()

static id_of_city tutorial::Database::null_city ( )
inlinestatic

Definition at line 712 of file Database.h.

◆ null_person()

static id_of_person tutorial::Database::null_person ( )
inlinestatic

Definition at line 744 of file Database.h.

◆ previous() [1/2]

id_of_city tutorial::Database::previous ( id_of_city  id) const
inline

Definition at line 701 of file Database.h.

◆ previous() [2/2]

id_of_person tutorial::Database::previous ( id_of_person  id) const
inline

Definition at line 733 of file Database.h.

◆ previous_city_by_name()

id_of_city tutorial::Database::previous_city_by_name ( id_of_city  id)
inline

Definition at line 787 of file Database.h.

◆ remove_index_of_city_by_name()

void tutorial::Database::remove_index_of_city_by_name ( Record_Id  record_id)
inlineprotected

Definition at line 134 of file Database.h.

◆ remove_index_of_person_by_name()

void tutorial::Database::remove_index_of_person_by_name ( Record_Id  record_id)
inlineprotected

Definition at line 165 of file Database.h.

◆ rename_field()

void tutorial::Database::rename_field ( Table_Id  table_id,
Field_Id  field_id,
const std::string &  name 
)
inlinefinalprotected

Definition at line 651 of file Database.h.

◆ rename_table()

void tutorial::Database::rename_table ( Table_Id  table_id,
const std::string &  name 
)
inlinefinalprotected

Definition at line 624 of file Database.h.

◆ requires_schema_upgrade()

bool tutorial::Database::requires_schema_upgrade ( ) const
inlineprotected

Definition at line 585 of file Database.h.

◆ set_max_record_id()

void tutorial::Database::set_max_record_id ( size_t  record_id)
inline

Definition at line 119 of file Database.h.

◆ sorted_city()

template<class Comparator >
std::vector< id_of_city > tutorial::Database::sorted_city ( Comparator  comparator) const

Definition at line 856 of file Database.h.

◆ sorted_person()

template<class Comparator >
std::vector< id_of_person > tutorial::Database::sorted_person ( Comparator  comparator) const

Definition at line 914 of file Database.h.

◆ throw_exception()

template<typename E = joedb::Exception>
static void tutorial::Database::throw_exception ( const std::string &  message)
inlinestatic

Definition at line 111 of file Database.h.

◆ timestamp()

void tutorial::Database::timestamp ( int64_t  timestamp)
inlineoverrideprotectedvirtual

Reimplemented from joedb::Writable.

Definition at line 578 of file Database.h.

◆ update_reference()

void tutorial::Database::update_reference ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
joedb::Record_Id  value 
)
inlinefinalprotected

Definition at line 446 of file Database.h.

◆ update_string()

void tutorial::Database::update_string ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
const std::string &  value 
)
inlinefinalprotected

Definition at line 412 of file Database.h.

◆ update_vector_reference()

void tutorial::Database::update_vector_reference ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
size_t  size,
const joedb::Record_Id value 
)
inlinefinalprotected

Definition at line 501 of file Database.h.

◆ update_vector_string()

void tutorial::Database::update_vector_string ( Table_Id  table_id,
Record_Id  record_id,
Field_Id  field_id,
size_t  size,
const std::string *  value 
)
inlinefinalprotected

Definition at line 466 of file Database.h.

◆ valid_data()

void tutorial::Database::valid_data ( )
inlinefinalprotectedvirtual

Reimplemented from joedb::Writable.

Definition at line 579 of file Database.h.

Friends And Related Symbol Documentation

◆ container_of_city

friend class container_of_city
friend

Definition at line 104 of file Database.h.

◆ container_of_person

friend class container_of_person
friend

Definition at line 106 of file Database.h.

◆ id_of_city

friend class id_of_city
friend

Definition at line 103 of file Database.h.

◆ id_of_person

friend class id_of_person
friend

Definition at line 105 of file Database.h.

◆ range_of_person_by_name

friend class range_of_person_by_name
friend

Definition at line 107 of file Database.h.

◆ Readable

friend class Readable
friend

Definition at line 102 of file Database.h.

Member Data Documentation

◆ current_table_id

Table_Id tutorial::Database::current_table_id = Table_Id{0}

Definition at line 117 of file Database.h.

◆ index_of_city_by_name

std::map<std::string, id_of_city> tutorial::Database::index_of_city_by_name
protected

Definition at line 133 of file Database.h.

◆ index_of_person_by_name

std::multimap<std::tuple<std::string, std::string>, id_of_person> tutorial::Database::index_of_person_by_name
protected

Definition at line 164 of file Database.h.

◆ max_record_id

size_t tutorial::Database::max_record_id

Definition at line 116 of file Database.h.

◆ schema_file

joedb::Memory_File tutorial::Database::schema_file
protected

Definition at line 582 of file Database.h.

◆ schema_journal

joedb::Writable_Journal tutorial::Database::schema_journal
protected

Definition at line 583 of file Database.h.

◆ storage_of_city

detail::data_of_city tutorial::Database::storage_of_city
protected

Definition at line 128 of file Database.h.

◆ storage_of_person

detail::data_of_person tutorial::Database::storage_of_person
protected

Definition at line 130 of file Database.h.

◆ upgrading_schema

bool tutorial::Database::upgrading_schema = false
protected

Definition at line 581 of file Database.h.


The documentation for this class was generated from the following file: