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());
}
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:
/// @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
/// @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");
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);
}
-
-};
+}