![]() |
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 57 of file BaseTable.hpp.
|
inline |
Commits the current manual transaction.
| MdbxException | if no transaction is active or commit/reset fails. |
Definition at line 63 of file BaseTable.hpp.
|
inline |
Connects to the MDBX environment if not already connected.
| MdbxException | if connection fails. |
Definition at line 44 of file BaseTable.hpp.
|
inline |
Disconnects the MDBX environment.
| MdbxException | if closing the environment fails. |
Definition at line 50 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 78 of file BaseTable.hpp.
|
inlineprotected |
Gets the raw DBI handle.
Definition at line 103 of file BaseTable.hpp.
|
inline |
Checks if the connection is currently active.
Definition at line 38 of file BaseTable.hpp.
|
inline |
Rolls back the current manual transaction.
| MdbxException | if no transaction is active or rollback/reset fails. |
Definition at line 69 of file BaseTable.hpp.
|
inlineprotected |
Returns the transaction bound to the current thread, if any.
Definition at line 97 of file BaseTable.hpp.
|
protected |
Shared connection to MDBX environment.
Definition at line 92 of file BaseTable.hpp.
|
protected |
DBI handle for the opened table.
Definition at line 93 of file BaseTable.hpp.