MarlinMT  0.1.0
marlinmt::DataSourcePlugin Class Referenceabstract

DataSourcePlugin class Responsible for reading/getting LCEvent and LCRunHeader in the framework for further processing. More...

#include <DataSourcePlugin.h>

Inherits marlinmt::Component.

Inherited by marlinmt::LCIOFileSource, and marlinmt::StdHepFileSource.

Public Types

using EventFunction = std::function< void(std::shared_ptr< EventStore >)>
 
using RunHeaderFunction = std::function< void(std::shared_ptr< RunHeader >)>
 
- Public Types inherited from marlinmt::Component
using LoggerPtr = Logging::Logger
 
- Public Types inherited from marlinmt::Configurable
using ParameterMap = std::map< std::string, std::shared_ptr< ParameterImpl > >
 
using iterator = ParameterMap::iterator
 
using const_iterator = ParameterMap::const_iterator
 

Public Member Functions

virtual ~DataSourcePlugin ()=default
 
 DataSourcePlugin (const std::string &dstype)
 Constructor. More...
 
const std::string & type () const
 Get the data source type. More...
 
const std::string & description () const
 Get the data source description. More...
 
virtual bool readOne ()=0
 Read one record from the input stream. More...
 
virtual void readAll ()
 Read the full stream until the end See readOne() for details. More...
 
void onEventRead (EventFunction func)
 Set the callback function to process on event read. More...
 
void onRunHeaderRead (RunHeaderFunction func)
 Set the callback function to process on run header read. More...
 
- Public Member Functions inherited from marlinmt::Component
 Component ()=delete
 No default constructor. More...
 
 Component (const Component &)=delete
 No copy or assignement. More...
 
Componentoperator= (const Component &)=delete
 
virtual ~Component ()=default
 Default destructor. More...
 
 Component (const std::string &type)
 Constructor with component type. More...
 
const std::string & type () const
 Get the component name. More...
 
const std::string & name () const
 Get the component name. More...
 
void setName (const std::string &n)
 Set the component name. More...
 
const std::string & description () const
 Get the component description. More...
 
void setDescription (const std::string &desc)
 Set the component description. More...
 
const Applicationapplication () const
 Get the application in which the component is registered. More...
 
Applicationapplication ()
 Get the application in which the component is registered. More...
 
template<class T >
Logging::StreamType log () const
 Log a message with specific log level. More...
 
Logging::StreamType debug () const
 Shortcut for log<DEBUG>() More...
 
Logging::StreamType message () const
 Shortcut for log<MESSAGE>() More...
 
Logging::StreamType warning () const
 Shortcut for log<WARNING>() More...
 
Logging::StreamType error () const
 Shortcut for log<ERROR>() More...
 
void setVerbosity (const std::string &level)
 Set the verbosity level. More...
 
const std::string & verbosity () const
 Get the verbosity level. More...
 
bool isInitialized () const
 Whether the component has been initialized. More...
 
void setup (Application *app)
 Setup the component. More...
 
void printParameters () const
 Print the component parameters. More...
 
template<class T >
void printParameters () const
 Print the component parameters at specific verbosity. More...
 
void setParameters (const ConfigSection &section, bool throwIfNotFound=false)
 Set the parameters from the configuration section. More...
 
void getParameters (ConfigSection &section, const std::set< std::string > &exclude={}) const
 Get the parameters from configurable object and populate the config section with. More...
 
- Public Member Functions inherited from marlinmt::Configurable
 Configurable ()=default
 
virtual ~Configurable ()=default
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value)
 Add a parameter. More...
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value, T defVal)
 Add a parameter. More...
 
template<typename T >
parameter (const std::string &name) const
 Get a parameter value. More...
 
template<typename T >
parameter (const std::string &name, const T &fallback) const
 Get a parameter value. More...
 
void checkParameter (const std::string &name) const
 Check if the parameter has been registered. More...
 
bool exists (const std::string &name) const
 Return true if the parameter has been registered. More...
 
bool isSet (const std::string &name) const
 Returns true if the parameter exists and is set, false otherwise. More...
 
void clear ()
 Remove all parameters. More...
 
void unset ()
 Unset all registered parameters. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Protected Member Functions

void processRunHeader (std::shared_ptr< RunHeader > rhdr)
 Must be called by daughter classes in readStream() to process an event in the framework. More...
 
void processEvent (std::shared_ptr< EventStore > event)
 Must be called by daughter classes in readStream() to process an event in the framework. More...
 
virtual void initialize () override
 Init data source. More...
 

Protected Attributes

std::string _description {"No description"}
 < The data source description More...
 
- Protected Attributes inherited from marlinmt::Component
std::string _type {}
 The component type. More...
 
std::string _name {}
 The component name. More...
 
std::string _description {"No description"}
 The component description. More...
 
Application_application {nullptr}
 The application in which the component has been registered. More...
 
LoggerPtr _logger {nullptr}
 The logger instance. More...
 
StringParameter _verbosity { *this, "Verbosity", "The component verbosity level", "MESSAGE" }
 The verbosity level of the logger (parameter) More...
 
- Protected Attributes inherited from marlinmt::Configurable
ParameterMap _parameters {}
 The parameter map. More...
 

Private Attributes

EventFunction _onEventRead {nullptr}
 < The callback function on event read More...
 
RunHeaderFunction _onRunHeaderRead {nullptr}
 

Detailed Description

DataSourcePlugin class Responsible for reading/getting LCEvent and LCRunHeader in the framework for further processing.

Definition at line 24 of file DataSourcePlugin.h.

Member Typedef Documentation

◆ EventFunction

using marlinmt::DataSourcePlugin::EventFunction = std::function<void(std::shared_ptr<EventStore>)>

Definition at line 26 of file DataSourcePlugin.h.

◆ RunHeaderFunction

using marlinmt::DataSourcePlugin::RunHeaderFunction = std::function<void(std::shared_ptr<RunHeader>)>

Definition at line 27 of file DataSourcePlugin.h.

Constructor & Destructor Documentation

◆ ~DataSourcePlugin()

virtual marlinmt::DataSourcePlugin::~DataSourcePlugin ( )
virtualdefault

◆ DataSourcePlugin()

marlinmt::DataSourcePlugin::DataSourcePlugin ( const std::string &  dstype)

Constructor.

Parameters
dstypethe data source plugin type

Definition at line 10 of file DataSourcePlugin.cc.

Member Function Documentation

◆ description()

const std::string& marlinmt::DataSourcePlugin::description ( ) const

Get the data source description.

◆ initialize()

void marlinmt::DataSourcePlugin::initialize ( )
overrideprotectedvirtual

◆ onEventRead()

void marlinmt::DataSourcePlugin::onEventRead ( EventFunction  func)

Set the callback function to process on event read.

Parameters
functhe callback function

Definition at line 23 of file DataSourcePlugin.cc.

References _onEventRead.

◆ onRunHeaderRead()

void marlinmt::DataSourcePlugin::onRunHeaderRead ( RunHeaderFunction  func)

Set the callback function to process on run header read.

Parameters
functhe callback function

Definition at line 29 of file DataSourcePlugin.cc.

References _onRunHeaderRead.

◆ processEvent()

void marlinmt::DataSourcePlugin::processEvent ( std::shared_ptr< EventStore event)
protected

Must be called by daughter classes in readStream() to process an event in the framework.

Parameters
eventthe event to process

Definition at line 44 of file DataSourcePlugin.cc.

References _onEventRead.

Referenced by marlinmt::LCIOFileSource::initialize(), and marlinmt::StdHepFileSource::readOne().

◆ processRunHeader()

void marlinmt::DataSourcePlugin::processRunHeader ( std::shared_ptr< RunHeader rhdr)
protected

Must be called by daughter classes in readStream() to process an event in the framework.

Parameters
eventthe event to process

Definition at line 35 of file DataSourcePlugin.cc.

References _onRunHeaderRead.

Referenced by marlinmt::LCIOFileSource::initialize(), and marlinmt::StdHepFileSource::readOne().

◆ readAll()

void marlinmt::DataSourcePlugin::readAll ( )
virtual

Read the full stream until the end See readOne() for details.

Definition at line 17 of file DataSourcePlugin.cc.

References readOne().

◆ readOne()

virtual bool marlinmt::DataSourcePlugin::readOne ( )
pure virtual

Read one record from the input stream.

Users must call processRunHeader() or processEvent() to forward it to the framework. Returns true on success. If the end of the stream is reached, return false.

Implemented in marlinmt::LCIOFileSource, and marlinmt::StdHepFileSource.

Referenced by readAll().

◆ type()

const std::string& marlinmt::DataSourcePlugin::type ( ) const

Get the data source type.

Member Data Documentation

◆ _description

std::string marlinmt::DataSourcePlugin::_description {"No description"}
protected

< The data source description

Definition at line 100 of file DataSourcePlugin.h.

◆ _onEventRead

EventFunction marlinmt::DataSourcePlugin::_onEventRead {nullptr}
private

< The callback function on event read

The callback function on run header read

Definition at line 104 of file DataSourcePlugin.h.

Referenced by onEventRead(), and processEvent().

◆ _onRunHeaderRead

RunHeaderFunction marlinmt::DataSourcePlugin::_onRunHeaderRead {nullptr}
private

Definition at line 106 of file DataSourcePlugin.h.

Referenced by onRunHeaderRead(), and processRunHeader().


The documentation for this class was generated from the following files: