1 // Copyright (C) 2019 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 CONFIG_BACKEND_DHCP6_MGR_H
8 #define CONFIG_BACKEND_DHCP6_MGR_H
9 
10 #include <config_backend/base_config_backend_mgr.h>
11 #include <dhcpsrv/config_backend_pool_dhcp6.h>
12 
13 #include <boost/scoped_ptr.hpp>
14 
15 namespace isc {
16 namespace dhcp {
17 
18 /// @brief Configuration Backend Manager for DHPCv6 servers.
19 ///
20 /// Implements the "manager" class which holds information about the
21 /// supported and configured backends and provides access to those
22 /// backends. This is similar to @c HostMgr and @c LeaseMgr singletons
23 /// being used by the DHCP servers.
24 ///
25 /// It is implemented as a singleton that can be accessed from any place
26 /// within the server code. This includes server configuration, data
27 /// fetching during normal server operation and data management, including
28 /// processing of control commands implemented within hooks libraries.
29 ///
30 /// Unlike @c HostMgr, the it does not directly expose the API to fetch and
31 /// manipulate the data in the database. This is done via, the Configuration
32 /// Backend Pool, see @c ConfigBackendPoolDHCPv6 for details.
33 class ConfigBackendDHCPv6Mgr : public cb::BaseConfigBackendMgr<ConfigBackendPoolDHCPv6>,
34                                public boost::noncopyable {
35 public:
36     /// @brief Creates new instance of the @c ConfigBackendDHCPv6Mgr.
37     ///
38     /// If an instance of the @c ConfigBackendDHCPv6Mgr already exists,
39     /// it will be replaced by the new instance. Thus, all factories
40     /// will be unregistered and config databases will be dropped.
41     static void create();
42 
43     /// @brief Destroys the instance of the @c ConfigBackendDHCPv6Mgr.
44     ///
45     /// If an instance of the @c ConfigBackendDHCPv6Mgr exists,
46     /// it will be destroyed.  Thus, all factories will be unregistered
47     /// and config databases will be dropped.
48     static void destroy();
49 
50     /// @brief Returns a sole instance of the @c ConfigBackendDHCPv6Mgr.
51     ///
52     /// This method should be used to retrieve an instance of the @c ConfigBackendDHCPv6Mgr
53     /// to be used to gather/manage config backends. It returns an instance
54     /// of the @c ConfigBackendDHCPv6Mgr created by the @c create method. If
55     /// the instance doesn't exist yet, it is created using the @c create method
56     /// with the an empty set of configuration databases.
57     static ConfigBackendDHCPv6Mgr& instance();
58 
59 private:
60     /// @brief Private default constructor.
ConfigBackendDHCPv6Mgr()61     ConfigBackendDHCPv6Mgr() {}
62 
63     /// @brief Returns a pointer to the currently used instance of the
64     /// @c ConfigBackendDHCPv6Mgr.
65     static boost::scoped_ptr<ConfigBackendDHCPv6Mgr>& getConfigBackendDHCPv6MgrPtr();
66 };
67 
68 } // end of namespace isc::dhcp
69 } // end of namespace isc
70 
71 #endif // CONFIG_BACKEND_DHCP6_MGR_H
72