MarlinMT  0.1.0
Processor.cc
Go to the documentation of this file.
1 
2 // -- marlinmt headers
3 #include <marlinmt/Processor.h>
4 #include <marlinmt/Application.h>
5 
6 namespace marlinmt {
7 
8  Processor::Processor( const std::string& typeName ) :
9  Component( typeName ) {
10  /* nop */
11  }
12 
13  //--------------------------------------------------------------------------
14 
16  auto &config = application().configuration() ;
17  auto &section = config.section("processors") ;
18  if( section.hasSection( name() ) ) {
19  setParameters( section.section( name() ) ) ;
20  }
21  init() ;
22  }
23 
24  //--------------------------------------------------------------------------
25 
26  std::optional<bool> Processor::runtimeOption( ERuntimeOption option ) const {
27  std::optional<bool> result {} ;
28  auto iter = _forcedRuntimeOptions.find( option ) ;
29  if( _forcedRuntimeOptions.end() != iter ) {
30  result = iter->second ;
31  }
32  return result ;
33  }
34 
35  //--------------------------------------------------------------------------
36 
38  _forcedRuntimeOptions[option] = value ;
39  }
40 
41 } // namespace marlinmt
const std::string & name() const
Get the component name.
Definition: Component.cc:23
void setRuntimeOption(ERuntimeOption option, bool value)
Force the runtime option to a given boolean value.
Definition: Processor.cc:37
void setParameters(const ConfigSection &section, bool throwIfNotFound=false)
Set the parameters from the configuration section.
Definition: Component.cc:124
constexpr unsigned long long value(const Flag_t &flag)
Definition: Flags.h:106
void initialize() override
From Component class.
Definition: Processor.cc:15
Component class.
Definition: Component.h:22
virtual void init()
Initialize the processor.
Definition: Processor.h:78
ConfigSection & section(const std::string &sn)
Get a section by name.
const Application & application() const
Get the application in which the component is registered.
Definition: Component.cc:83
ERuntimeOption
ERuntimeOption enumerator.
Definition: Processor.h:58
std::optional< bool > runtimeOption(ERuntimeOption option) const
Get the forced runtime option settings.
Definition: Processor.cc:26
const Configuration & configuration() const
Get the main application configuration object.
Definition: Application.cc:278
RuntimeOptions _forcedRuntimeOptions
The user forced runtime options for parallel processing.
Definition: Processor.h:142