Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processor: throw exception if parameter is already defined for given … #15

Merged
merged 2 commits into from
Jun 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions source/include/marlin/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace marlin{
T& parameter,
const T& defaultVal,
int setSize=0 ) {

checkForExistingParameter( name );
_map[ name ] = new ProcessorParameter_t<T>( name , description,
parameter, defaultVal,
false , setSize) ;
Expand Down Expand Up @@ -309,7 +309,8 @@ namespace marlin{
T& parameter,
const T& defaultVal,
int setSize=0 ) {


checkForExistingParameter( name );
_map[ name ] = new ProcessorParameter_t<T>( name , description,
parameter, defaultVal,
true , setSize) ;
Expand All @@ -319,7 +320,22 @@ namespace marlin{
*/
bool parameterSet( const std::string& name ) ;


/** Tests whether the parameter has been registered before
*
* @param name name of the parameter to check
* @throw logic_error if parameter has been registered before
*/
void checkForExistingParameter( const std::string& name ) {
auto paraIt = _map.find( name );
if (paraIt != _map.end() ) {
std::stringstream errorMessage;
errorMessage << "Parameter " << name
<< " already defined for processor "
<< this->type()
<< std::endl;
throw std::logic_error( errorMessage.str() );
}
}

/** Print message according to verbosity level of the templated parameter (one of
* DEBUG, MESSAGE, WARNING, ERROR ) and the global parameter "Verbosity".
Expand Down