| Kea 3.0.2-git

lease_query_impl_factory.cc
Go to the documentation of this file.
1// Copyright (C) 2020-2025 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#include <config.h>
8
9#include <exceptions/exceptions.h>
10#include <lease_query_impl_factory.h>
11
12 using namespace isc;
13 using namespace isc::asiolink;
14 using namespace isc::data;
15 using namespace isc::lease_query;
16
17 LeaseQueryImplPtr LeaseQueryImplFactory::impl_(0);
18
19 void
20 LeaseQueryImplFactory::createImpl(uint16_t family, ConstElementPtr config) {
21 if (family == AF_INET) {
22 impl_.reset(new LeaseQueryImpl4(config));
23 } else {
24 impl_.reset(new LeaseQueryImpl6(config));
25 }
26}
27
28 void
29 LeaseQueryImplFactory::destroyImpl() {
30 impl_.reset();
31}
32
33 const LeaseQueryImpl&
34 LeaseQueryImplFactory::getImpl() {
35 if (!impl_) {
36 isc_throw(Unexpected, "LeaseQueryImpl does not exist");
37 }
38
39 return (*impl_);
40}
41
42 LeaseQueryImpl&
43 LeaseQueryImplFactory::getMutableImpl() {
44 if (!impl_) {
45 isc_throw(Unexpected, "LeaseQueryImpl does not exist");
46 }
47
48 return (*impl_);
49}
isc::Unexpected
A generic exception that is thrown when an unexpected error condition occurs.
Definition exceptions/exceptions.h:153
isc::lease_query::LeaseQueryImpl4
Provides configuration and for processing DHCPv4 lease queries.
Definition lease_query_impl4.h:22
isc::lease_query::LeaseQueryImpl6
Provides configuration and control flow for processing queries.
Definition lease_query_impl6.h:33
isc::lease_query::LeaseQueryImplFactory::createImpl
static void createImpl(uint16_t family, isc::data::ConstElementPtr config)
Creates the LeaseQueryImpl singleton.
Definition lease_query_impl_factory.cc:20
isc::lease_query::LeaseQueryImplFactory::getMutableImpl
static LeaseQueryImpl & getMutableImpl()
Fetch the LeaseQueryImpl singleton.
Definition lease_query_impl_factory.cc:43
isc::lease_query::LeaseQueryImplFactory::getImpl
static const LeaseQueryImpl & getImpl()
Fetch the LeaseQueryImpl singleton.
Definition lease_query_impl_factory.cc:34
isc::lease_query::LeaseQueryImplFactory::destroyImpl
static void destroyImpl()
Destroy the LeaseQueryImpl singleton.
Definition lease_query_impl_factory.cc:29
isc::lease_query::LeaseQueryImpl
Provides configuration and control flow for processing queries.
Definition lease_query_impl.h:81
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
lease_query_impl_factory.h
isc::asiolink
Definition addr_utilities.cc:170
isc::config
Definition command_interpreter.cc:23
isc::data
Definition base_stamped_element.cc:12
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::lease_query
Definition blq_msg.h:15
isc::lease_query::LeaseQueryImplPtr
boost::shared_ptr< LeaseQueryImpl > LeaseQueryImplPtr
Defines a smart pointer to LeaseQueryImpl instance.
Definition lease_query_impl.h:154
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148