Skip to content

Commit

Permalink
Processor: check also for registerOptionalProcessor
Browse files Browse the repository at this point in the history
move logic for check to separate function
  • Loading branch information
andresailer authored and gaede committed Jun 23, 2017
1 parent 7f881f9 commit 56977b8
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions source/include/marlin/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,7 @@ namespace marlin{
T& parameter,
const T& defaultVal,
int setSize=0 ) {

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() );
}

checkForExistingParameter( name );
_map[ name ] = new ProcessorParameter_t<T>( name , description,
parameter, defaultVal,
false , setSize) ;
Expand Down Expand Up @@ -320,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 @@ -330,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

0 comments on commit 56977b8

Please sign in to comment.