|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
CRTP template base class for database backends. More...
#include <backend_base.h>


Public Member Functions | |
| backend_base ()=default | |
| Default constructor. | |
| ~backend_base () override | |
| Virtual destructor. | |
| backend_base (const backend_base &)=delete | |
| backend_base & | operator= (const backend_base &)=delete |
| backend_base (backend_base &&) noexcept=delete | |
| backend_base & | operator= (backend_base &&) noexcept=delete |
| database_types | type () const override |
| Get the database type of this backend. | |
| kcenon::common::VoidResult | initialize (const connection_config &config) override |
| Initialize the database backend. | |
| kcenon::common::VoidResult | shutdown () override |
| Shutdown the database backend gracefully. | |
| bool | is_initialized () const override |
| Check if backend is initialized and ready. | |
Public Member Functions inherited from database::core::database_backend | |
| virtual | ~database_backend ()=default |
| virtual kcenon::common::Result< database_result > | select_query (const std::string &query_string)=0 |
| Execute a SELECT query. | |
| virtual kcenon::common::VoidResult | execute_query (const std::string &query_string)=0 |
| Execute a general SQL query (DDL, DML) | |
| virtual kcenon::common::Result< database_result > | select_prepared (const std::string &query, const std::vector< database_value > ¶ms) |
| Execute a parameterized SELECT query (prepared statement) | |
| virtual kcenon::common::VoidResult | execute_prepared (const std::string &query, const std::vector< database_value > ¶ms) |
| Execute a parameterized DML/DDL query (prepared statement) | |
| virtual kcenon::common::VoidResult | begin_transaction ()=0 |
| Begin a transaction. | |
| virtual kcenon::common::VoidResult | commit_transaction ()=0 |
| Commit the current transaction. | |
| virtual kcenon::common::VoidResult | rollback_transaction ()=0 |
| Rollback the current transaction. | |
| virtual bool | in_transaction () const =0 |
| Check if backend is currently in a transaction. | |
| virtual std::string | last_error () const =0 |
| Get last error message from backend. | |
| virtual std::map< std::string, std::string > | connection_info () const =0 |
| Get backend-specific connection information. | |
Static Public Member Functions | |
| static std::unique_ptr< database_backend > | create () |
| Factory method for backend_registry. | |
Protected Attributes | |
| std::atomic< bool > | initialized_ {false} |
| Initialization state. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from database::core::database_backend | |
| static std::string | expand_params (const std::string &query, const std::vector< database_value > ¶ms) |
| Expand positional parameters into a SQL string (fallback) | |
CRTP template base class for database backends.
This template class implements the common lifecycle pattern shared by all database backends, reducing code duplication and ensuring consistent behavior.
| Derived | The derived backend class (CRTP pattern) |
| Type | The database_types enum value for this backend |
Template Parameters:
Thread Safety:
Definition at line 73 of file backend_base.h.
|
default |
Default constructor.
Initializes the backend in an uninitialized state.
|
inlineoverride |
Virtual destructor.
Calls shutdown() to ensure proper cleanup of derived class resources.
Definition at line 88 of file backend_base.h.
References database::core::backend_base< Derived, Type >::shutdown().

|
delete |
|
deletenoexcept |
|
inlinestatic |
Factory method for backend_registry.
Definition at line 105 of file backend_base.h.
|
inlineoverridevirtual |
Initialize the database backend.
| config | Connection configuration |
Performs initialization guard check, then delegates to derived class. Derived class must implement do_initialize() for database-specific logic.
Implements database::core::database_backend.
Definition at line 127 of file backend_base.h.
References database::core::backend_base< Derived, Type >::initialized_, and database::invalid_state.
|
inlineoverridevirtual |
Check if backend is initialized and ready.
Implements database::core::database_backend.
Definition at line 166 of file backend_base.h.
References database::core::backend_base< Derived, Type >::initialized_.
|
deletenoexcept |
|
delete |
|
inlineoverridevirtual |
Shutdown the database backend gracefully.
Performs shutdown guard check, then delegates to derived class. Derived class must implement do_shutdown() for database-specific cleanup.
Implements database::core::database_backend.
Definition at line 151 of file backend_base.h.
References database::core::backend_base< Derived, Type >::initialized_.
Referenced by database::core::backend_base< Derived, Type >::~backend_base().

|
inlineoverridevirtual |
Get the database type of this backend.
Implements database::core::database_backend.
Definition at line 114 of file backend_base.h.
|
protected |
Initialization state.
Definition at line 172 of file backend_base.h.
Referenced by database::core::backend_base< Derived, Type >::initialize(), database::core::backend_base< Derived, Type >::is_initialized(), and database::core::backend_base< Derived, Type >::shutdown().