7#ifndef BASE_CONFIG_BACKEND_POOL_H
8#define BASE_CONFIG_BACKEND_POOL_H
43template<
typename ConfigBackendType>
69 typename std::list<ConfigBackendTypePtr>::iterator backend =
backends_.begin();
72 if ((*backend)->getType() == db_type) {
89 bool del(
const std::string& db_type,
const std::string& dbaccess,
98 typename std::list<ConfigBackendTypePtr>::iterator backend =
backends_.begin();
101 if ((*backend)->getType() != db_type || (*backend)->getParameters() != parameters) {
103 }
else if (if_unusable && (!(*backend)->isUnusable())) {
163 template<
typename PropertyType,
typename... FnPtrArgs,
typename... Args>
168 PropertyType& property,
169 Args... input)
const {
175 property = ((*backend).*MethodPointer)(server_selector, input...);
184 if (!backends.empty()) {
185 for (
auto const& backend : backends) {
186 property = ((*backend).*MethodPointer)(server_selector, input...);
194 << backend_selector.
toText());
242 template<
typename PropertyType,
typename... FnPtrArgs,
typename... Args>
244 (FnPtrArgs...)
const,
246 PropertyType& property,
247 Args... input)
const {
249 if (backends.empty()) {
251 << backend_selector.
toText());
253 }
else if (backends.size() > 1) {
255 "selector: " << backend_selector.
toText());
258 property = ((*(*(backends.begin())).*MethodPointer)(input...));
307 template<
typename PropertyCollectionType,
typename... FnPtrArgs,
typename... Args>
312 PropertyCollectionType& properties,
313 Args... input)
const {
316 properties = ((*backend).*MethodPointer)(server_selector, input...);
317 if (!properties.empty()) {
324 if (!backends.empty()) {
325 for (
auto const& backend : backends) {
326 properties = ((*backend).*MethodPointer)(server_selector, input...);
327 if (!properties.empty()) {
334 << backend_selector.
toText());
378 template<
typename PropertyCollectionType>
383 PropertyCollectionType& properties)
const {
386 properties = ((*backend).*MethodPointer)(server_selector);
387 if (!properties.empty()) {
394 if (!backends.empty()) {
395 for (
auto const& backend : backends) {
396 properties = ((*backend).*MethodPointer)(server_selector);
397 if (!properties.empty()) {
404 << backend_selector.
toText());
445 template<
typename PropertyCollectionType>
448 PropertyCollectionType& properties)
const {
450 if (backends.empty()) {
452 << backend_selector.
toText());
454 }
else if (backends.size() > 1) {
456 "selector: " << backend_selector.
toText());
459 properties = (*(*(backends.begin())).*MethodPointer)();
508 template<
typename ReturnValue,
typename... FnPtrArgs,
typename... Args>
515 if (backends.empty()) {
517 << backend_selector.
toText());
519 }
else if (backends.size() > 1) {
521 "selector: " << backend_selector.
toText());
524 return ((*(*(backends.begin())).*MethodPointer)(server_selector, input...));
570 template<
typename ReturnValue,
typename... FnPtrArgs,
typename... Args>
576 if (backends.empty()) {
578 << backend_selector.
toText());
580 }
else if (backends.size() > 1) {
582 "selector: " << backend_selector.
toText());
585 return ((*(*(backends.begin())).*MethodPointer)(input...));
594 std::list<ConfigBackendTypePtr>
597 std::list<ConfigBackendTypePtr> selected;
636 selected.push_back(backend);
Base class for configuration backend pools.
boost::shared_ptr< ConfigBackendType > ConfigBackendTypePtr
Shared pointer to the Configuration Backend used.
void getPropertyPtrConst(PropertyType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyType &property, Args... input) const
Retrieve a single configuration property from the pool.
void delAllBackends()
Deletes all backends from the pool.
void getBackendPropertyPtrConst(PropertyType(ConfigBackendType::*MethodPointer)(FnPtrArgs...) const, const db::BackendSelector &backend_selector, PropertyType &property, Args... input) const
Retrieve a single configuration property from the backend.
ReturnValue createUpdateDeleteProperty(ReturnValue(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...), const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, Args... input)
Add, update or delete property from the backend.
void delAllBackends(const std::string &db_type)
Deletes all backends of the given type from the pool.
void getMultiplePropertiesConst(PropertyCollectionType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyCollectionType &properties, Args... input) const
Retrieve multiple configuration properties from the pool.
ReturnValue createUpdateDeleteBackendProperty(ReturnValue(ConfigBackendType::*MethodPointer)(FnPtrArgs...), const db::BackendSelector &backend_selector, Args... input)
Add, update or delete property from the backend.
void addBackend(ConfigBackendTypePtr backend)
Adds a backend to the pool.
std::list< ConfigBackendTypePtr > selectBackends(const db::BackendSelector &backend_selector) const
Selects existing backends matching the selector.
void getAllPropertiesConst(PropertyCollectionType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyCollectionType &properties) const
Retrieve all configuration properties from the pool.
virtual ~BaseConfigBackendPool()
Virtual destructor.
void getAllBackendPropertiesConst(PropertyCollectionType(ConfigBackendType::*MethodPointer)() const, const db::BackendSelector &backend_selector, PropertyCollectionType &properties) const
Get all configuration properties from the backend.
std::list< ConfigBackendTypePtr > backends_
Holds configuration backends belonging to the pool.
bool del(const std::string &db_type, const std::string &dbaccess, bool if_unusable)
Deletes all backends of the given type from the pool.
Specification of the database backend to be used yields multiple results.
Type getBackendType() const
Returns backend type selected.
std::string toText() const
Returns selections as text.
static Type stringToBackendType(const std::string &type)
Converts string to backend type.
std::string getBackendHost() const
Returns host selected.
uint16_t getBackendPort() const
Returns port selected.
bool amUnspecified() const
Checks if selector is "unspecified".
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
Error when specified database could not be found in the server configuration.
Server selector for associating objects in a database with specific servers.
#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.