![]() |
MDBX Containers
|
Base class providing common functionality for MDBX database access. More...
#include <BaseTable.hpp>
Public Member Functions | |
BaseTable (std::shared_ptr< Connection > connection, std::string name, MDBX_db_flags_t flags) | |
Construct the database table accessor. | |
virtual | ~BaseTable ()=default |
bool | is_connected () const |
Checks if the connection is currently active. | |
void | connect () |
Connects to the MDBX environment if not already connected. | |
void | disconnect () |
Disconnects the MDBX environment. | |
void | begin (TransactionMode mode=TransactionMode::WRITABLE) |
Begins a manual transaction (must be committed or rolled back later). | |
void | commit () |
Commits the current manual transaction. | |
void | rollback () |
Rolls back the current manual transaction. | |
template<typename Func> | |
void | execute_in_transaction (Func operation, TransactionMode mode=TransactionMode::WRITABLE) |
Executes an operation inside an automatic transaction. | |
Protected Member Functions | |
MDBX_txn * | thread_txn () const |
Returns the transaction bound to the current thread, if any. | |
MDBX_dbi | handle () const |
Gets the raw DBI handle. | |
Protected Attributes | |
std::shared_ptr< Connection > | m_connection |
Shared connection to MDBX environment. | |
MDBX_dbi | m_dbi {} |
DBI handle for the opened table. | |
Base class providing common functionality for MDBX database access.
Opens or creates a table (DBI handle) and offers basic transaction management. Not thread-safe for simultaneous operations on the same instance.
Definition at line 16 of file BaseTable.hpp.
|
inlineexplicit |
Construct the database table accessor.
connection | Shared MDBX connection. |
name | Name of the table (used as DBI name). |
flags | DBI flags (e.g., MDBX_CREATE). |
Definition at line 22 of file BaseTable.hpp.
|
virtualdefault |
|
inline |
Begins a manual transaction (must be committed or rolled back later).
mode | The transaction mode (default: WRITABLE). |
MdbxException | if the transaction is already started or if beginning fails. |
Definition at line 54 of file BaseTable.hpp.
|
inline |
Commits the current manual transaction.
MdbxException | if no transaction is active or commit/reset fails. |
Definition at line 60 of file BaseTable.hpp.
|
inline |
Connects to the MDBX environment if not already connected.
Definition at line 42 of file BaseTable.hpp.
|
inline |
Disconnects the MDBX environment.
Definition at line 47 of file BaseTable.hpp.
|
inline |
Executes an operation inside an automatic transaction.
operation | The function to execute. |
mode | The transaction mode (default: WRITABLE). |
MdbxException | if an error occurs during execution. |
Definition at line 75 of file BaseTable.hpp.
|
inlineprotected |
Gets the raw DBI handle.
Definition at line 99 of file BaseTable.hpp.
|
inline |
Checks if the connection is currently active.
Definition at line 37 of file BaseTable.hpp.
|
inline |
Rolls back the current manual transaction.
MdbxException | if no transaction is active or rollback/reset fails. |
Definition at line 66 of file BaseTable.hpp.
|
inlineprotected |
Returns the transaction bound to the current thread, if any.
Definition at line 94 of file BaseTable.hpp.
|
protected |
Shared connection to MDBX environment.
Definition at line 89 of file BaseTable.hpp.
|
protected |
DBI handle for the opened table.
Definition at line 90 of file BaseTable.hpp.