ParameterSystem: remove ParamFinalizer

this adds no extra validation and complicates refactoring
This commit is contained in:
Arne Morten Kvarving 2024-09-02 15:13:46 +02:00
parent 65158cd3fb
commit cfad87b41f
2 changed files with 0 additions and 34 deletions

View File

@ -289,13 +289,6 @@ void endRegistration()
}
MetaData::registrationOpen() = false;
// loop over all parameters and retrieve their values to make sure
// that there is no syntax error
for (const auto& param : MetaData::registrationFinalizers()) {
param->retrieve();
}
MetaData::registrationFinalizers().clear();
}
void printParamUsage(std::ostream& os, const ParamInfo& paramInfo)

View File

@ -149,26 +149,6 @@ auto Get(bool errorIfNotRegistered = true);
template <class Param>
void SetDefault(decltype(Param::value) new_value);
class ParamRegFinalizerBase_
{
public:
virtual ~ParamRegFinalizerBase_()
{}
virtual void retrieve() = 0;
};
template <class Param>
class ParamRegFinalizer_ : public ParamRegFinalizerBase_
{
public:
void retrieve() override
{
// retrieve the parameter once to make sure that its value does
// not contain a syntax error.
std::ignore = Get<Param>(/*errorIfNotRegistered=*/true);
}
};
struct MetaData
{
using type = Dune::ParameterTree;
@ -182,16 +162,12 @@ struct MetaData
static const std::map<std::string, ParamInfo>& registry()
{ return storage_().registry; }
static std::list<std::unique_ptr<ParamRegFinalizerBase_>> &registrationFinalizers()
{ return storage_().finalizers; }
static bool& registrationOpen()
{ return storage_().registrationOpen; }
static void clear()
{
storage_().tree = std::make_unique<Dune::ParameterTree>();
storage_().finalizers.clear();
storage_().registrationOpen = true;
storage_().registry.clear();
}
@ -211,7 +187,6 @@ private:
std::unique_ptr<Dune::ParameterTree> tree;
std::map<std::string, ParamInfo> registry;
std::list<std::unique_ptr<ParamRegFinalizerBase_>> finalizers;
bool registrationOpen;
};
@ -458,8 +433,6 @@ void Register(const char* usageString)
using ParamType = std::conditional_t<std::is_same_v<decltype(defaultValue),
const char* const>, std::string,
std::remove_const_t<decltype(defaultValue)>>;
MetaData::registrationFinalizers().push_back(
std::make_unique<ParamRegFinalizer_<Param>>());
std::ostringstream oss;
oss << defaultValue;