Mēnsūra
Public Member Functions | List of all members
Service Class Referenceabstract

Abstract base class for services. More...

#include <Service.hpp>

Inheritance diagram for Service:
BTagEffService BTagSFService BTagWPService JetCorrectorService SystService TFileService

Public Member Functions

 Service (std::string const &name)
 Constructor. More...
 
 Service (Service const &)=default
 Default copy constructor.
 
 Service (Service &&)=default
 Default move constructor.
 
Serviceoperator= (Service const &)=default
 Default assignment operator.
 
virtual ~Service ()=default
 Default destructor.
 
virtual void BeginRun (Dataset const &dataset)
 Performs initialization needed when processing of a new dataset starts. More...
 
virtual ServiceClone () const =0
 Clones the object. More...
 
virtual void EndRun ()
 Performs necessary actions needed after processing of a dataset is finished. More...
 
Processor const & GetMaster () const
 Returns a reference to the master. More...
 
std::string const & GetName () const
 Returns name of the plugin.
 
void SetMaster (Processor const *processor)
 Provides a pointer to an instance of Processor class that owns the service. More...
 

Detailed Description

Abstract base class for services.

This class provides an interface to access information that is only updated once per dataset or not updated at all (as opposed to plugins that are designed to operate on the per-event basis). It keeps the pointer to the Processor class that owns services, which allows to access other services if needed.

A service is notified when processing of a dataset starts or finishes with the help of the dedicated hooks. Depending on the logic, it might or might not take action in response to these events.

A service must implement method Clone that creates a newly initialized copy of it. The clonning is performed by the framework before the start of processing of the first dataset, and thus it must not address any internal state specific to a dataset. Often it might be advantageous to share resources between all clones of a service.

A service must be capable of working in a multi-thread environment. In particular, a special attention should be given to ROOT objects as ROOT is not thread-safe. Critical blocks must be guarded with the help of class ROOTLock.

A service must define a valid move constructor.

Constructor & Destructor Documentation

Service::Service ( std::string const &  name)

Constructor.

The argument is the unique name of the service.

Member Function Documentation

void Service::BeginRun ( Dataset const &  dataset)
virtual

Performs initialization needed when processing of a new dataset starts.

The method is trivial in the default implementation.

Reimplemented in BTagEffService, and TFileService.

virtual Service* Service::Clone ( ) const
pure virtual

Clones the object.

The method must create a new instance of the (derived) class with the same constructor parameters. The method must not address any parameters specific to a dataset. Technically it means the method must create a new instance of the class exactly in the same way this has been created and initialized.

In some cases, it might be advantageous to share resources between all clones, provided that precautions against race conditions are taken.

The method is used when unique copies of services are created for each instance of class Processor. Clonning is performed before call to SetMaster and before the first call to BeginRun.

Implemented in BTagSFService, BTagEffService, TFileService, JetCorrectorService, BTagWPService, and SystService.

void Service::EndRun ( )
virtual

Performs necessary actions needed after processing of a dataset is finished.

The method is trivial in the default implementation.

Reimplemented in TFileService.

Processor const & Service::GetMaster ( ) const

Returns a reference to the master.

Will throw an exception if the pointer to master is null.

void Service::SetMaster ( Processor const *  processor)

Provides a pointer to an instance of Processor class that owns the service.

The pointer is guaranteed to be initialized before the first call to BeginRun. It stays valid for the lifetime of the object.


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