42#include <kcenon/common/patterns/result.h>
72template<
typename Derived, database_types Type>
107 return std::make_unique<Derived>();
130 return kcenon::common::error_info{
132 "Backend already initialized",
133 Derived::backend_name()
137 auto result =
static_cast<Derived*
>(
this)->do_initialize(config);
138 if (result.is_ok()) {
154 return kcenon::common::ok();
157 auto result =
static_cast<Derived*
>(
this)->do_shutdown();
CRTP template base class for database backends.
database_types type() const override
Get the database type of this backend.
kcenon::common::VoidResult shutdown() override
Shutdown the database backend gracefully.
std::atomic< bool > initialized_
Initialization state.
backend_base & operator=(const backend_base &)=delete
backend_base(backend_base &&) noexcept=delete
~backend_base() override
Virtual destructor.
bool is_initialized() const override
Check if backend is initialized and ready.
backend_base(const backend_base &)=delete
static std::unique_ptr< database_backend > create()
Factory method for backend_registry.
kcenon::common::VoidResult initialize(const connection_config &config) override
Initialize the database backend.
backend_base()=default
Default constructor.
Abstract base class for database backends.
Abstract interface for database backends.
Defines the enumeration of supported database types.
database_types
Represents various database backends or modes.
Result<T> type for database_system error handling.
Configuration for database connection.