Kea  2.3.5-git
host_data_source_factory.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef HOST_DATA_SOURCE_FACTORY_H
8 #define HOST_DATA_SOURCE_FACTORY_H
9 
12 #include <exceptions/exceptions.h>
13 #include <boost/scoped_ptr.hpp>
14 
15 #include <functional>
16 #include <string>
17 #include <vector>
18 #include <map>
19 
20 namespace isc {
21 namespace dhcp {
22 
28 public:
29  NoHostDataSourceManager(const char* file, size_t line, const char* what) :
30  isc::Exception(file, line, what) {}
31 };
32 
42 
44 public:
66  static void add(HostDataSourceList& sources, const std::string& dbaccess);
67 
76  static bool del(HostDataSourceList& sources, const std::string& db_type);
77 
94  static bool del(HostDataSourceList& sources, const std::string& db_type,
95  const std::string& dbaccess, bool if_unusable = true);
96 
101  typedef std::function<HostDataSourcePtr (const db::DatabaseConnection::ParameterMap&)> Factory;
102 
114  static bool registerFactory(const std::string& db_type,
115  const Factory& factory, bool no_log = false);
116 
126  static bool deregisterFactory(const std::string& db_type,
127  bool no_log = false);
128 
133  static bool registeredFactory(const std::string& db_type);
134 
140  static void printRegistered();
141 
142 private:
144  static std::map<std::string, Factory> map_;
145 };
146 
147 } // end of isc::dhcp namespace
148 } // end of isc namespace
149 
150 #endif
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::function< HostDataSourcePtr(const db::DatabaseConnection::ParameterMap &)> Factory
Type of host data source factory.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
std::vector< HostDataSourcePtr > HostDataSourceList
HostDataSource list.
No host data source instance exception.
NoHostDataSourceManager(const char *file, size_t line, const char *what)