MarlinMT  0.1.0
Application.h
Go to the documentation of this file.
1 #pragma once
2 
3 // -- marlinmt headers
4 #include <marlinmt/Exceptions.h>
5 #include <marlinmt/Logging.h>
10 #include <marlinmt/Configuration.h>
11 #include <marlinmt/CmdLineParser.h>
12 
13 namespace marlinmt {
14 
15  class IScheduler ;
16  class DataSourcePlugin ;
17  class RunHeader ;
18  class EventStore ;
19 
25  class Application {
26  public:
29  using Scheduler = std::shared_ptr<IScheduler> ;
30  using EventList = std::vector<std::shared_ptr<EventStore>> ;
31  using DataSource = std::shared_ptr<DataSourcePlugin> ;
32  using ConditionsMap = std::map<std::string, std::string> ;
33 
34  public:
35  Application() = default ;
36  ~Application() = default ;
37 
38  public:
45  static int main( int argc, char**argv ) ;
46 
53  void init( int argc, char **argv ) ;
54 
58  void run() ;
59 
63  const CmdLineParseResult &cmdLineParseResult() const ;
64 
68  const std::string &programName() const ;
69 
73  bool isInitialized() const ;
74 
78  Logger logger() const ;
79 
88  Logger createLogger( const std::string &name ) const ;
89 
93  const GeometryManager &geometryManager() const ;
94 
98  const RandomSeedManager &randomSeedManager() const ;
99 
104 
109 
114  const BookStoreManager &bookStoreManager() const ;
115 
119  const Configuration &configuration() const ;
120 
121  private:
127  void onEventRead( std::shared_ptr<EventStore> event ) ;
128 
134  void onRunHeaderRead( std::shared_ptr<RunHeader> rhdr ) ;
135 
141  void processFinishedEvents( const EventList &events ) const ;
142 
146  void dumpExampleConfig() ;
147 
148  private:
162  bool _initialized {false} ;
164  Scheduler _scheduler {nullptr} ;
169  };
170 
171 } // end namespace marlinmt
const std::string & programName() const
Get the program name.
Definition: Application.cc:171
DataSource _dataSource
The data source plugin.
Definition: Application.h:166
GeometryManager class.
Logger createLogger(const std::string &name) const
Create a new logger instance.
Definition: Application.cc:189
BookStoreManager class.
const CmdLineParseResult & cmdLineParseResult() const
Get the command line parsing result (after init)
Definition: Application.cc:165
BookStoreManager & bookStoreManager()
Get book store manager.
Definition: Application.cc:266
BookStoreManager _bookStoreManager
Managed data object shared between threads.
Definition: Application.h:160
Configuration _configuration
The main application configuration.
Definition: Application.h:152
void dumpExampleConfig()
Dump an example configuation.
Definition: Application.cc:284
void onRunHeaderRead(std::shared_ptr< RunHeader > rhdr)
Callback function to process a run header received from the data source.
Definition: Application.cc:230
std::shared_ptr< DataSourcePlugin > DataSource
Definition: Application.h:31
const RandomSeedManager & randomSeedManager() const
Get the random seed manager.
Definition: Application.cc:243
RandomSeedManager _randomSeedMgr
The random seed manager.
Definition: Application.h:156
Application class Base application interface for running a Marlin application.
Definition: Application.h:25
ConditionsMap _conditions
Initial processor runtime conditions from steering file.
Definition: Application.h:168
void processFinishedEvents(const EventList &events) const
Processed finished events from the output queue.
Definition: Application.cc:255
static int main(int argc, char **argv)
Create and run an application.
Definition: Application.cc:24
const GeometryManager & geometryManager() const
Get the geometry manager.
Definition: Application.cc:237
bool _initialized
Whether the application has been initialized.
Definition: Application.h:162
Configuration class.
GeometryManager _geometryMgr
The geometry manager.
Definition: Application.h:154
void onEventRead(std::shared_ptr< EventStore > event)
Callback function to process an event received from the data source.
Definition: Application.cc:200
Scheduler _scheduler
The event processing scheduler instance.
Definition: Application.h:164
bool isInitialized() const
Whether the application has been initialized.
Definition: Application.cc:177
std::vector< std::shared_ptr< EventStore > > EventList
Definition: Application.h:30
std::shared_ptr< streamlog::logstreamT< mutex_type > > Logger
Definition: Logging.h:73
RandomSeedManager class.
ParseResult struct. The result of the command line parsing.
Definition: CmdLineParser.h:19
std::shared_ptr< IScheduler > Scheduler
Definition: Application.h:29
LoggerManager class Responsible for configuring logger for a given application.
Definition: LoggerManager.h:21
Logging::Logger Logger
Definition: Application.h:27
void init(int argc, char **argv)
Initialize the application.
Definition: Application.cc:52
std::map< std::string, std::string > ConditionsMap
Definition: Application.h:32
void run()
Run the application.
Definition: Application.cc:138
Logger logger() const
Get the application logger instance.
Definition: Application.cc:183
CmdLineParser::ParseResult _parseResult
The command line parse result.
Definition: Application.h:150
LoggerManager _loggerMgr
The logger manager.
Definition: Application.h:158
const Configuration & configuration() const
Get the main application configuration object.
Definition: Application.cc:278