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
|
/***********************************************/
/**
* @file parameterNamesWithoutDuplicates.h
*
* @brief Removes all duplicate names.
*
* @author Torsten Mayer-Guerr
* @date 2020-05-29
*/
/***********************************************/
#ifndef __GROOPS_PARAMETERNAMESWITHOUTDUPLICATES__
#define __GROOPS_PARAMETERNAMESWITHOUTDUPLICATES__
// Latex documentation
static const char *docstringParameterNamesWithoutDuplicates = R"(
\subsection{WithoutDuplicates}
Removes all duplicate names (keep first) from \configClass{parameterName}{parameterNamesType}.
)";
/***********************************************/
#include "base/import.h"
#include "config/config.h"
#include "classes/parameterNames/parameterNames.h"
/***** CLASS ***********************************/
/** @brief Removes all duplicate names.
* @ingroup parameterNamesGroup
* @see ParameterNames */
class ParameterNamesWithoutDuplicates : public ParameterNamesBase
{
public:
ParameterNamesWithoutDuplicates(Config &config)
{
try
{
ParameterNamesPtr parameterNames;
readConfig(config, "parameterName", parameterNames, Config::MUSTSET, "", "");
if(isCreateSchema(config)) return;
std::set<ParameterName> sortedNames;
for(const auto ¶meterName : parameterNames->parameterNames())
if(sortedNames.find(parameterName) == sortedNames.end())
{
sortedNames.insert(parameterName);
names.push_back(parameterName);
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
};
/***********************************************/
#endif /* __GROOPS__ */
|