MarlinMT  0.1.0
Processor.h
Go to the documentation of this file.
1 #ifndef MARLINMT_PROCESSOR_h
2 #define MARLINMT_PROCESSOR_h 1
3 
4 // -- marlinmt headers
5 #include <marlinmt/Component.h>
6 #include <marlinmt/EventStore.h>
7 #include <marlinmt/RunHeader.h>
8 #include <marlinmt/MarlinMTConfig.h> // for Marlin version macros
9 
10 // -- std headers
11 #include <map>
12 #include <string>
13 #include <memory>
14 #include <iostream>
15 #include <sstream>
16 
17 namespace marlinmt {
18 
19  class Application ;
20  class ProcessorApi ;
21 
43  class Processor : public Component {
44  friend class ProcessorApi ;
45 
46  private:
47  // prevent users from making (default) copies of processors
48  Processor() = delete ;
49  Processor(const Processor&) = delete ;
50  Processor& operator=(const Processor&) = delete ;
51 
52  public:
53  virtual ~Processor() = default ;
54 
58  enum class ERuntimeOption {
59  eCritical,
60  eClone
61  };
62 
63  using RuntimeOptions = std::map<ERuntimeOption, bool> ;
64 
65  public:
71  Processor( const std::string& t ) ;
72 
78  virtual void init() { /* nop */ }
79 
83  virtual void processRunHeader( RunHeader * ) { /* nop */ }
84 
89  virtual void processEvent( EventStore * ) { /* nop */ }
90 
97  virtual void end() { /* nop */ }
98 
105  std::optional<bool> runtimeOption( ERuntimeOption option ) const ;
106 
107  protected:
134  void setRuntimeOption( ERuntimeOption option, bool value ) ;
135 
136  private:
138  void initialize() override ;
139 
140  private:
143  };
144 
145 } // end namespace marlinmt
146 
147 #endif
virtual ~Processor()=default
void setRuntimeOption(ERuntimeOption option, bool value)
Force the runtime option to a given boolean value.
Definition: Processor.cc:37
std::map< ERuntimeOption, bool > RuntimeOptions
Definition: Processor.h:63
constexpr unsigned long long value(const Flag_t &flag)
Definition: Flags.h:106
Processor & operator=(const Processor &)=delete
void initialize() override
From Component class.
Definition: Processor.cc:15
virtual void processRunHeader(RunHeader *)
Call at start of run.
Definition: Processor.h:83
virtual void processEvent(EventStore *)
Process an input event.
Definition: Processor.h:89
Component class.
Definition: Component.h:22
virtual void init()
Initialize the processor.
Definition: Processor.h:78
Whether the processor has to be executed in a critical section.
ERuntimeOption
ERuntimeOption enumerator.
Definition: Processor.h:58
std::optional< bool > runtimeOption(ERuntimeOption option) const
Get the forced runtime option settings.
Definition: Processor.cc:26
RunHeader class.
Definition: RunHeader.h:22
Processor class.
Definition: Processor.h:43
virtual void end()
Terminate the processor.
Definition: Processor.h:97
EventStore class.
Definition: EventStore.h:17
RuntimeOptions _forcedRuntimeOptions
The user forced runtime options for parallel processing.
Definition: Processor.h:142