Kea 1.5.0
config_base.cc
Go to the documentation of this file.
1// Copyright (C) 2018 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
10#include <list>
11
12using namespace isc::log;
13using namespace isc::data;
14
15namespace isc {
16namespace process {
17
18void
20
21 std::list<LoggerSpecification> specs;
22 for (LoggingInfoStorage::const_iterator it = logging_info_.begin();
23 it != logging_info_.end(); ++it) {
24 specs.push_back(it->toSpec());
25 }
26 LoggerManager manager;
27 manager.process(specs.begin(), specs.end());
28}
29
30bool
31ConfigBase::equals(const ConfigBase& other) const {
32 // If number of loggers is different, then configurations aren't equal.
33 if (logging_info_.size() != other.logging_info_.size()) {
34 return (false);
35 }
36 // Pass through all loggers and try to find the match for each of them
37 // with the loggers from the other configuration. The order doesn't
38 // matter so we can't simply compare the vectors.
39 for (LoggingInfoStorage::const_iterator this_it =
40 logging_info_.begin(); this_it != logging_info_.end();
41 ++this_it) {
42 bool match = false;
43 for (LoggingInfoStorage::const_iterator other_it =
44 other.logging_info_.begin();
45 other_it != other.logging_info_.end(); ++other_it) {
46 if (this_it->equals(*other_it)) {
47 match = true;
48 break;
49 }
50 }
51 // No match found for the particular logger so return false.
52 if (!match) {
53 return (false);
54 }
55 }
56
57 // Check config control info for equality.
58 if ((config_ctl_info_ && !other.config_ctl_info_) ||
59 (!config_ctl_info_ && other.config_ctl_info_) ||
60 ((config_ctl_info_ && other.config_ctl_info_) &&
61 (!config_ctl_info_->equals(*(other.config_ctl_info_))))) {
62 return (false);
63 }
64
65 return (true);
66}
67
68void
70 // We will entirely replace loggers in the new configuration.
71 other.logging_info_.clear();
72 for (LoggingInfoStorage::const_iterator it = logging_info_.begin();
73 it != logging_info_.end(); ++it) {
74 other.addLoggingInfo(*it);
75 }
76
77 // Clone the config control info
78 if (config_ctl_info_) {
79 other.config_ctl_info_.reset(new ConfigControlInfo(*config_ctl_info_));
80 } else {
81 other.config_ctl_info_.reset();
82 }
83}
84
88
89 // Logging global map (skip if empty)
90 if (!logging_info_.empty()) {
92 // Set loggers list
94 for (LoggingInfoStorage::const_iterator logger =
95 logging_info_.cbegin();
96 logger != logging_info_.cend(); ++logger) {
97 loggers->add(logger->toElement());
98 }
99 logging->set("loggers", loggers);
100 result->set("Logging", logging);
101 }
102
103 // We do NOT output ConfigControlInfo here, as it is not a
104 // top level element, but rather belongs within the process
105 // element.
106
107 return (result);
108}
109
110};
111};
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition: data.cc:268
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:263
void process(T start, T finish)
Process Specifications.
Base class for all configurations.
Definition: config_base.h:31
void addLoggingInfo(const process::LoggingInfo &logging_info)
Sets logging specific configuration.
Definition: config_base.h:48
void applyLoggingCfg() const
Apply logging configuration to log4cplus.
Definition: config_base.cc:19
virtual isc::data::ElementPtr toElement() const
Converts to Element representation.
Definition: config_base.cc:86
void copy(ConfigBase &new_config) const
Copies the current configuration to a new configuration.
Definition: config_base.cc:69
bool equals(const ConfigBase &other) const
Compares two configuration.
Definition: config_base.cc:31
Embodies configuration information used during a server's configuration process.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
Defines the logger used by the top-level component of kea-dhcp-ddns.