7#ifndef BASE_CONFIG_BACKEND_MGR_H
8#define BASE_CONFIG_BACKEND_MGR_H
14#include <boost/shared_ptr.hpp>
58template<
typename ConfigBackendPoolType>
69 typedef std::function<
typename ConfigBackendPoolType::ConfigBackendTypePtr
104 factories_.insert(std::make_pair(db_type, factory));
126 pool_->delAllBackends(db_type);
154 db::DatabaseConnection::ParameterMap::iterator it = parameters.find(
"type");
155 if (it == parameters.end()) {
160 std::string db_type = it->second;
166 db_type <<
"' is not supported");
170 auto backend = index->second(parameters);
173 " factory returned NULL");
177 pool_->addBackend(backend);
182 pool_->delAllBackends();
198 bool delBackend(
const std::string& db_type,
const std::string& dbaccess,
200 return (
pool_->del(db_type, dbaccess, if_unusable));
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
A generic exception that is thrown when an unexpected error condition occurs.
Base class for Configuration Backend Managers (CBM).
bool delBackend(const std::string &db_type, const std::string &dbaccess, bool if_unusable)
Delete a config backend manager.
bool registerBackendFactory(const std::string &db_type, const Factory &factory)
Registers new backend factory function for a given backend type.
void addBackend(const std::string &dbaccess)
Create an instance of a configuration backend.
BaseConfigBackendMgr()
Constructor.
ConfigBackendPoolPtr getPool() const
Returns underlying config backend pool.
boost::shared_ptr< ConfigBackendPoolType > ConfigBackendPoolPtr
Pointer to the configuration backend pool.
void delAllBackends()
Removes all backends from the pool.
std::map< std::string, Factory > factories_
A map holding registered backend factory functions.
std::function< typename ConfigBackendPoolType::ConfigBackendTypePtr(const db::DatabaseConnection::ParameterMap &) Factory)
Type of the backend factory function.
bool unregisterBackendFactory(const std::string &db_type)
Unregisters the backend factory function for a given backend type.
ConfigBackendPoolPtr pool_
Pointer to the configuration backends pool.
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Defines the logger used by the top-level component of kea-lfc.