Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
backend_base.h File Reference

CRTP template base class for database backends. More...

#include "database_backend.h"
#include "result.h"
#include "../database_types.h"
#include <kcenon/common/patterns/result.h>
#include <memory>
#include <atomic>
Include dependency graph for backend_base.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  database::core::backend_base< Derived, Type >
 CRTP template base class for database backends. More...
 

Namespaces

namespace  database
 
namespace  database::core
 

Detailed Description

CRTP template base class for database backends.

Provides a template base class that eliminates duplicated lifecycle patterns across all database backend implementations. Uses CRTP (Curiously Recurring Template Pattern) for static polymorphism.

Issue #328: Create template base class for backend lifecycle

Design Goals:

  • Eliminate ~150 lines of boilerplate per backend
  • Centralize common lifecycle logic (constructor, destructor, create, type)
  • Standardize initialization guard checks
  • Allow backends to focus on database-specific implementation

Usage Pattern:

class postgresql_backend
: public backend_base<postgresql_backend, database_types::postgres> {
public:
static constexpr const char* backend_name() { return "postgresql_backend"; }
protected:
friend class backend_base<postgresql_backend, database_types::postgres>;
VoidResult do_initialize(const connection_config& config);
VoidResult do_shutdown();
};

Definition in file backend_base.h.