blob: b98d1980e532a247b1a7f379fea8d86151c5c0ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef HA_CONFIG_PARSER_H
#define HA_CONFIG_PARSER_H
#include <ha_config.h>
#include <cc/data.h>
#include <cc/simple_parser.h>
#include <string>
namespace isc {
namespace ha {
/// @brief Configuration parser for High Availability.
class HAConfigParser : public data::SimpleParser {
public:
/// @brief Parses HA configuration.
///
/// @param [out] config_storage Pointer to the object where parsed configuration
/// is going to be stored.
///
/// @param config Specified configuration.
/// @throw ConfigError when parsing fails or configuration is invalid.
void parse(const HAConfigPtr& config_storage,
const data::ConstElementPtr& config);
private:
/// @brief Parses HA configuration and can throw various exceptions..
///
/// @param [out] config_storage Pointer to the object where parsed configuration
/// is going to be stored.
///
/// @param config Specified configuration.
void parseInternal(const HAConfigPtr& config_storage,
const data::ConstElementPtr& config);
/// @brief Validates and returns a value of the parameter.
///
/// @param config configuration map from which the parameter should be
/// retrieved.
/// @param parameter_name parameter name to be fetched from the configuration.
/// @tparam T parameter type, e.g. @c uint16_t, @c uint32_t etc.
template<typename T>
T getAndValidateInteger(const data::ConstElementPtr& config,
const std::string& parameter_name) const;
/// @brief Logs various information related to the successfully parsed
/// configuration.
///
/// @param config_storage Pointer to the object where parsed configuration
/// is stored.
///
/// One example of such information is a warning message indicating that
/// sending lease updates is disabled.
void logConfigStatus(const HAConfigPtr& config_storage) const;
};
} // end of namespace isc::ha
} // end of namespace isc
#endif
|