1#ifndef FIRE_PROCESSOR_H
2#define FIRE_PROCESSOR_H
4#include "fire/Conditions.h"
6#include "fire/RunHeader.h"
7#include "fire/StorageControl.h"
8#include "fire/config/Parameters.h"
9#include "fire/exception/Exception.h"
10#include "fire/factory/Factory.h"
267 template<
typename DerivedType>
269 std::string full_name{boost::core::demangle(
typeid(DerivedType).name())};
270 library_[full_name] = &maker<DerivedType>;
295 auto lib_it{
library_.find(full_name)};
297 throw Exception(
"Factory",
"A processor of class " + full_name +
298 " has not been declared.",
false);
300 return lib_it->second(ps,p);
321 template <
typename DerivedType>
326 ptr = std::make_unique<DerivedType>(parameters);
413#define DECLARE_PROCESSOR(CLASS) \
415 auto v = fire::Processor::Factory::get().declare<CLASS>(); \
Container and cache for conditions and conditions providers.
Definition: Conditions.h:66
const ConditionType & get(const std::string &condition_name)
Primary request action for a conditions object.
Definition: Conditions.h:114
Event class for interfacing with processors.
Definition: Event.h:28
Standard base exception class with some useful output information.
Definition: Exception.h:18
The central object managing the data processing.
Definition: Process.h:16
Specific exception used to abort an event.
Definition: Processor.h:65
The special factory used to create processors.
Definition: Processor.h:219
PrototypePtr make(const std::string &full_name, const config::Parameters &ps, Process &p)
make a new object by name
Definition: Processor.h:292
std::unique_ptr< Processor > PrototypePtr
The base pointer for processors.
Definition: Processor.h:224
Factory()=default
private constructor to prevent creation
Factory(Factory const &)=delete
delete the copy constructor
uint64_t declare()
register a new object to be constructible
Definition: Processor.h:268
static PrototypePtr maker(const config::Parameters ¶meters, Process &process)
make a DerivedType returning a PrototypePtr
Definition: Processor.h:322
static Factory & get()
get the factory instance
Definition: Processor.h:244
void operator=(Factory const &)=delete
delete the assignment operator
std::unordered_map< std::string, PrototypeMaker > library_
library of possible objects to create
Definition: Processor.h:340
Base class for all event processing components.
Definition: Processor.h:57
virtual void attach(Process *p) final
Attach the current process to this processor.
Definition: Processor.h:172
virtual void onFileOpen(const std::string &file_name)
Callback for the Processor to take any necessary action when a new input event file is opened.
Definition: Processor.h:123
Conditions & getConditions() const
Internal getter for conditions without exposing all of Process.
Definition: Processor.cxx:17
virtual void onProcessStart()
Callback for the Processor to take any necessary action when the processing of events starts.
Definition: Processor.h:139
virtual void onFileClose(const std::string &file_name)
Callback for the Processor to take any necessary action when a event input file is closed.
Definition: Processor.h:133
void setStorageHint(StorageControl::Hint hint, const std::string &purpose="") const
Mark the current event as having the given storage control hint from this processor and the given pur...
Definition: Processor.cxx:11
void abortEvent()
Abort the event immediately.
Definition: Processor.h:361
logging::logger theLog_
The logger for this Processor.
Definition: Processor.h:376
void fatalError(const std::string &msg)
End processing due to a fatal runtime error.
Definition: Processor.h:368
virtual void process(Event &event)=0
have the derived processors do what they need to do
Process * process_
Handle to current process.
Definition: Processor.h:388
virtual void onProcessEnd()
Callback for the Processor to take any necessary action when the processing of events finishes,...
Definition: Processor.h:146
Processor(const config::Parameters &ps)
Configure the processor upon construction.
Definition: Processor.cxx:7
const std::string & getName() const
Get the processor name.
Definition: Processor.h:151
virtual ~Processor()=default
virtual default destructor so derived classes can be destructed
virtual void onNewRun(const RunHeader &runHeader)
Callback for the Processor to take any necessary action when the run being processed changes.
Definition: Processor.h:113
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
Definition: Processor.h:196
std::string name_
The name of the Processor.
Definition: Processor.h:385
virtual void beforeNewRun(RunHeader &header)
Handle allowing processors to modify run headers before the run begins.
Definition: Processor.h:100
Hint
Hints that can be provided by processors to the storage controller.
Definition: StorageControl.h:30
Class encapsulating parameters for configuring a processor.
Definition: Parameters.h:28
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition: Parameters.h:76
Interface to Boost.Logging.
log::sources::severity_channel_logger_mt< level, std::string > logger
Short names for boost::log.
Definition: Logger.h:84
fire::Process Process
alias Process into this namespace
Definition: EventProcessor.h:105