Abstract backend.
More...
#include <StormByte/database/database.hxx>
Abstract backend.
- Note
- Operations on one connection are serialized. A Transaction reserves its connection and must remain on its creating thread.
-
Custom backends must lock
m_operation_mutex in public operations that access backend state.
-
Inheritance-oriented. Concrete backends expose protected constructors. Derive, call the backend constructor, override hooks if needed.
◆ Database() [1/3]
Construct with an optional logger.
- Parameters
-
| logger | Logger instance (may be null). |
◆ Database() [2/3]
| StormByte::Database::Database::Database |
( |
const Database & |
| ) |
|
|
delete |
Copy constructor (deleted).
◆ Database() [3/3]
| StormByte::Database::Database::Database |
( |
Database && |
other | ) |
|
|
noexcept |
◆ ~Database()
| virtual StormByte::Database::Database::~Database |
( |
| ) |
|
|
virtualnoexcept |
◆ BeginTransaction()
Begin a transaction.
- Parameters
-
| level | Isolation (backend-specific mapping). |
- Returns
- RAII Transaction (rollback on destruction if not committed).
◆ ClearPreparedSTMTs()
| void StormByte::Database::Database::ClearPreparedSTMTs |
( |
| ) |
|
|
protectednoexcept |
Destroy all registered statements inside the Database module.
◆ CommitTransaction()
| void StormByte::Database::Database::CommitTransaction |
( |
| ) |
|
Commit the current transaction.
◆ Connect()
| bool StormByte::Database::Database::Connect |
( |
| ) |
|
|
noexcept |
Connect.
- Returns
- true on success.
◆ CreatePreparedSTMT()
|
|
protectedpure virtualnoexcept |
Create a backend prepared statement.
- Parameters
-
| name | Statement name. |
| query | SQL text. |
- Returns
- Statement or nullptr on failure.
◆ Disconnect()
| void StormByte::Database::Database::Disconnect |
( |
| ) |
|
|
noexcept |
Disconnect.
- Note
- Has no effect when the database is already disconnected.
◆ DoBeginTransaction()
| virtual void StormByte::Database::Database::DoBeginTransaction |
( |
IsolationLevel |
level | ) |
|
|
protectedpure virtual |
Backend BEGIN with isolation.
- Parameters
-
◆ DoConnect()
| virtual bool StormByte::Database::Database::DoConnect |
( |
| ) |
|
|
protectedpure virtualnoexcept |
Backend connect.
- Returns
- true on success.
◆ DoDisconnect()
| virtual void StormByte::Database::Database::DoDisconnect |
( |
| ) |
|
|
protectedpure virtualnoexcept |
◆ DoPostConnect()
| virtual void StormByte::Database::Database::DoPostConnect |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
Post-connect hook.
Default no-op.
◆ DoPostDisconnect()
| virtual void StormByte::Database::Database::DoPostDisconnect |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
Post-disconnect hook.
Default no-op.
◆ DoPreConnect()
| virtual void StormByte::Database::Database::DoPreConnect |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
Pre-connect hook.
Default no-op.
◆ DoPreDisconnect()
| virtual void StormByte::Database::Database::DoPreDisconnect |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
Pre-disconnect hook.
Default no-op.
◆ DoPrepareSTMT()
| void StormByte::Database::Database::DoPrepareSTMT |
( |
std::string_view |
name, |
|
|
std::string_view |
query |
|
) |
| |
|
protectednoexcept |
Same as PrepareSTMT; kept for hook symmetry.
- Parameters
-
| name | Statement name. |
| query | SQL text. |
◆ DoSilentQuery()
| virtual bool StormByte::Database::Database::DoSilentQuery |
( |
std::string_view |
query | ) |
|
|
protectedpure virtualnoexcept |
◆ ExecuteSTMT()
template<typename... Args>
| ExpectedRows StormByte::Database::Database::ExecuteSTMT |
( |
std::string_view |
name, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Execute a prepared statement by name.
- Template Parameters
-
- Parameters
-
| name | Prepared statement name. |
| args | Positional values (0-based). |
- Returns
- Result rows or an error.
◆ GetSslMode()
| SslMode StormByte::Database::Database::GetSslMode |
( |
| ) |
const |
|
inlinenoexcept |
Current TLS policy.
- Returns
- Mode.
◆ GetTelemetry()
Obtain the cumulative connection telemetry handle.
- Returns
- Shared counters that remain valid after close or Database destruction.
◆ IsConnected()
| bool StormByte::Database::Database::IsConnected |
( |
| ) |
const |
|
inlinenoexcept |
Whether the connection is open.
- Returns
- true if connected.
◆ operator=() [1/2]
Copy assignment (deleted).
◆ operator=() [2/2]
◆ PrepareSTMT()
| void StormByte::Database::Database::PrepareSTMT |
( |
std::string_view |
name, |
|
|
std::string_view |
query |
|
) |
| |
|
protectednoexcept |
Register a prepared statement under name.
- Parameters
-
| name | Statement name. |
| query | SQL text. |
◆ Query()
| virtual ExpectedRows StormByte::Database::Database::Query |
( |
std::string_view |
query | ) |
|
|
pure virtual |
◆ RecordBackendEvent()
| void StormByte::Database::Database::RecordBackendEvent |
( |
BackendEvent |
event | ) |
|
|
inlineprotectednoexcept |
Record a categorized event reported by the active backend.
- Parameters
-
| event | Backend event category. |
◆ RollbackTransaction()
| void StormByte::Database::Database::RollbackTransaction |
( |
| ) |
|
Roll back the current transaction.
◆ SetSslMode()
| void StormByte::Database::Database::SetSslMode |
( |
SslMode |
mode | ) |
|
|
inlinenoexcept |
◆ SetTelemetry()
Replace the telemetry implementation, normally in a concrete backend constructor.
- Parameters
-
| telemetry | Backend-specific telemetry allocated on Base's heap. |
◆ SilentQuery()
| virtual bool StormByte::Database::Database::SilentQuery |
( |
std::string_view |
query | ) |
|
|
pure virtualnoexcept |
◆ TrackOperation()
Start timing a Database operation without invoking user callbacks.
- Parameters
-
| operation | Operation category. |
- Returns
- Scope that records failure unless Complete() reports otherwise.
◆ Transaction
◆ m_connected
| bool StormByte::Database::Database::m_connected |
|
protected |
◆ m_logger
Shared logger, safe across the DLL boundary.
◆ m_operation_mutex
| StormByte::Shared<std::recursive_mutex> StormByte::Database::Database::m_operation_mutex |
|
protected |
DLL-safe owner of the connection mutex.
◆ m_ssl_mode
| SslMode StormByte::Database::Database::m_ssl_mode |
|
protected |
TLS policy for network backends.
◆ m_telemetry
Shared cumulative counters for this connection.
The documentation for this class was generated from the following file: