Commit e79e9ce1 authored by Francis Dupont's avatar Francis Dupont

[#1182] Made getParameters public

parent 00e4a569
......@@ -101,7 +101,7 @@ isc::data::ConstElementPtr
LibraryHandle::getParameter(const std::string& name) {
// Try to find appropriate parameter. May return null pointer
isc::data::ConstElementPtr params = getParameters();
if (!params) {
if (!params || (params->getType() != isc::data::Element::map)) {
return (isc::data::ConstElementPtr());
}
......
......@@ -194,11 +194,18 @@ public:
isc::data::ConstElementPtr
getParameter(const std::string& name);
/// @brief Get configuration parameter common code.
///
/// @return configuration parameters.
isc::data::ConstElementPtr getParameters();
/// @brief Returns names of configuration parameters for the library.
///
/// This method returns a vector of strings reflecting names of
/// configuration parameters specified in the configuration file.
///
/// @note: kept for backward compatibility.
/// @return a vector with parameter entry names.
std::vector<std::string> getParameterNames();
private:
......@@ -221,11 +228,6 @@ private:
/// @param Unused - should be the object to copy.
LibraryHandle& operator=(const LibraryHandle&);
/// @brief Get configuration parameter common code.
///
/// @return configuration parameters.
isc::data::ConstElementPtr getParameters();
/// Back pointer to the collection object for the library
CalloutManager& callout_manager_;
......
// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2016-2020 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
......@@ -36,6 +36,7 @@ version() {
/// @param handle passed by the hooks framework
/// @return 0 if load was successful, non-zero for errors
int load(LibraryHandle& handle) {
ConstElementPtr elems = handle.getParameters();
ConstElementPtr string_elem = handle.getParameter("svalue");
ConstElementPtr int_elem = handle.getParameter("ivalue");
ConstElementPtr bool_elem = handle.getParameter("bvalue");
......@@ -107,10 +108,22 @@ int load(LibraryHandle& handle) {
return (10);
}
// Check elems map.
if (!elems) {
return (11);
}
string expected_str = "{ "
"\"bvalue\": true, "
"\"ivalue\": 42, "
"\"svalue\": \"string value\""
" }";
if (expected_str != elems->str()) {
return (12);
}
// All validation steps were successful. The library has all the parameters
// it needs, so we should report a success.
return (0);
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment