Kea: master_loader_callbacks.h Source File

| Kea 2.2.0

master_loader_callbacks.h
Go to the documentation of this file.
1// Copyright (C) 2012-2020 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 MASTER_LOADER_CALLBACKS_H
8#define MASTER_LOADER_CALLBACKS_H
9
10#include <exceptions/exceptions.h>
11
12#include <boost/shared_ptr.hpp>
13#include <functional>
14#include <string>
15
16namespace isc {
17namespace dns {
18class Name;
19class RRClass;
20class RRType;
21class RRTTL;
22namespace rdata {
23class Rdata;
24 typedef boost::shared_ptr<Rdata> RdataPtr;
25}
26
38typedef std::function<void(const Name& name, const RRClass& rrclass,
39 const RRType& rrtype, const RRTTL& rrttl,
40 const rdata::RdataPtr& rdata)>
41 AddRRCallback;
42
49 class MasterLoaderCallbacks {
50public:
61 typedef std::function<void(const std::string& source_name,
62 size_t source_line,
63 const std::string& reason)> IssueCallback;
64
72 MasterLoaderCallbacks(const IssueCallback& error,
73 const IssueCallback& warning) :
74 error_(error),
75 warning_(warning)
76 {
77 if (!error_ || !warning_) {
78 isc_throw(isc::InvalidParameter,
79 "Empty function passed as callback");
80 }
81 }
82
94 void error(const std::string& source_name, size_t source_line,
95 const std::string& reason) const
96 {
97 error_(source_name, source_line, reason);
98 }
99
111 void warning(const std::string& source_name, size_t source_line,
112 const std::string& reason) const
113 {
114 warning_(source_name, source_line, reason);
115 }
116
125 static MasterLoaderCallbacks getNullCallbacks();
126
127private:
128 const IssueCallback error_, warning_;
129};
130
131}
132}
133
134#endif // MASTER_LOADER_CALLBACKS_H
isc::InvalidParameter
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
Definition: exceptions/exceptions.h:124
isc::dns::MasterLoaderCallbacks
Set of issue callbacks for a loader.
Definition: master_loader_callbacks.h:49
isc::dns::MasterLoaderCallbacks::getNullCallbacks
static MasterLoaderCallbacks getNullCallbacks()
Return a callbacks instance with null callbacks.
Definition: master_loader_callbacks.cc:23
isc::dns::MasterLoaderCallbacks::MasterLoaderCallbacks
MasterLoaderCallbacks(const IssueCallback &error, const IssueCallback &warning)
Constructor.
Definition: master_loader_callbacks.h:72
isc::dns::MasterLoaderCallbacks::error
void error(const std::string &source_name, size_t source_line, const std::string &reason) const
Call callback for serious errors.
Definition: master_loader_callbacks.h:94
isc::dns::MasterLoaderCallbacks::IssueCallback
std::function< void(const std::string &source_name, size_t source_line, const std::string &reason)> IssueCallback
Type of one callback to report problems.
Definition: master_loader_callbacks.h:63
isc::dns::MasterLoaderCallbacks::warning
void warning(const std::string &source_name, size_t source_line, const std::string &reason) const
Call callback for potential problems.
Definition: master_loader_callbacks.h:111
isc::dns::Name
The Name class encapsulates DNS names.
Definition: name.h:223
isc::dns::RRClass
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
isc::dns::RRTTL
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
isc::dns::RRType
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition: exceptions/exceptions.h:210
isc::dns::rdata::RdataPtr
boost::shared_ptr< Rdata > RdataPtr
The RdataPtr type is a pointer-like type, pointing to an object of some concrete derived class of Rda...
Definition: master_loader_callbacks.h:23
isc::dns::AddRRCallback
std::function< void(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &rrttl, const rdata::RdataPtr &rdata)> AddRRCallback
Type of callback to add a RR.
Definition: master_loader_callbacks.h:41
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143