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

Registry for database backend plugins. More...

#include "database_backend.h"
#include <string>
#include <memory>
#include <vector>
#include <map>
#include <functional>
#include <mutex>
Include dependency graph for backend_registry.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_registry
 Singleton registry for database backend plugins. More...
 
class  database::core::backend_registrar< BackendType >
 Helper class for automatic backend registration. More...
 

Namespaces

namespace  database
 
namespace  database::core
 

Functions

std::unique_ptr< database_backenddatabase::core::create_backend (const std::string &name)
 Convenience function for creating backends (static method style)
 
bool database::core::has_backend (const std::string &name)
 Convenience function for checking backend availability.
 
std::vector< std::string > database::core::available_backends ()
 Convenience function for getting available backends.
 

Detailed Description

Registry for database backend plugins.

Provides a centralized registry for registering and creating database backends at runtime. This eliminates the need for conditional compilation and enables dynamic backend selection.

Key Features:

  • Runtime backend registration
  • Thread-safe factory pattern
  • Automatic backend discovery via static initialization
  • Support for both built-in and external backends

Usage Pattern:

  1. Register backends (typically via static initialization):
    backend_registry::register_backend("postgresql", &postgresql_backend::create);
  2. Create backend instances:
    auto backend = backend_registry::create("postgresql");
    if (!backend) {
    // Handle error: backend not found
    }
  3. Query available backends:
    auto backends = backend_registry::available_backends();
    for (const auto& name : backends) {
    std::cout << "Available: " << name << std::endl;
    }

Definition in file backend_registry.h.