Improve parameter validation
The "parameter validation protocol" is based on parameters providing a [[nodiscard]] bool validate() const
function, where all the parameters of the tree are visited in turn.
Unfortunately, for a deep parameter tree (vs flat parameter structure), it's not possible to report which parameter is actually incorrect. The current workaround is to throw from the validate()
function. With this workaround, we are reporting an invalid parameter one at a time while we could report all the parameters that are invalids in one pass.
I suggest to switch to something like:
struct invalid_param {
std::string name; //<! Name of the parameters including the tree (aka "processing.saving.base_path")
std::string message; //<! Explain what is wrong with the parameter
std::string suggested_value; //<! Eventually a suggested value that is in the validity range?
};
// Validate function (annoted to the data member)
template <typename T, typename OutputIterator>
void validate(T const& val, OutputIterator invalid) const
{
if (val < 0)
*invalid++ = invalid_param {"negative value not supported", "1"};
}