DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ers::IssueFactory Class Reference

Implements factory pattern for user defined Issues. More...

#include <IssueFactory.hpp>

Public Member Functions

Issuecreate (const std::string &name, const Context &context) const
 build an empty issue for a given name
 
Issuecreate (const std::string &name, const std::list< std::string > &inheritance, const Context &context, Severity severity, const system_clock::time_point &time, const std::string &message, const std::vector< std::string > &qualifiers, const std::map< std::string, std::string > &parameters, const Issue *cause=0) const
 build issue out of all the given parameters
 
void register_issue (const std::string &name, IssueCreator creator)
 register an issue factory
 

Static Public Member Functions

static IssueFactoryinstance ()
 method to access singleton
 

Private Types

typedef Issue *(*) IssueCreator(const ers::Context &)
 
typedef std::map< std::string, IssueCreatorFunctionMap
 

Private Member Functions

 IssueFactory ()
 

Private Attributes

FunctionMap m_creators
 

Friends

template<class >
class SingletonCreator
 

Detailed Description

Implements factory pattern for user defined Issues.

This class implements factory pattern for Issues. The main responsibility of this class is to keep track of the existing types of Issues Each user defined issue class should register one factory method for creating instances of this class. This is required for reconstructing issues produced in the context of a different process.

Author
Serguei Kolos

Definition at line 44 of file IssueFactory.hpp.

Member Typedef Documentation

◆ FunctionMap

std::map<std::string,IssueCreator> ers::IssueFactory::FunctionMap
private

Definition at line 49 of file IssueFactory.hpp.

◆ IssueCreator

Issue *(*) ers::IssueFactory::IssueCreator(const ers::Context &)
private

Definition at line 48 of file IssueFactory.hpp.

Constructor & Destructor Documentation

◆ IssueFactory()

ers::IssueFactory::IssueFactory ( )
inlineprivate

Definition at line 70 of file IssueFactory.hpp.

71 { ; }

Member Function Documentation

◆ create() [1/2]

ers::Issue * ers::IssueFactory::create ( const std::string & name,
const Context & context ) const

build an empty issue for a given name

Builds an issue out of the name it was registered with

Parameters
namethe name used to indentify the class
Returns
an newly allocated instance of type name or AnyIssue
Note
If the requested type cannot be resolved an instance of type AnyIssue

Definition at line 49 of file IssueFactory.cpp.

51{
52 FunctionMap::const_iterator it = m_creators.find(name);
53 if ( it == m_creators.end() )
54 {
55 ERS_INTERNAL_DEBUG( 1, "Creator for the \"" << name << "\" issue is not found" );
56 return new ers::AnyIssue( name, context );
57 }
58
59 ERS_INTERNAL_DEBUG( 2, "Creating the \"" << name << "\" issue" );
60 return (it->second)( context );
61}
FunctionMap m_creators
#define ERS_INTERNAL_DEBUG(level, message)
Definition macro.hpp:26

◆ create() [2/2]

Issue * ers::IssueFactory::create ( const std::string & name,
const std::list< std::string > & inheritance,
const Context & context,
Severity severity,
const system_clock::time_point & time,
const std::string & message,
const std::vector< std::string > & qualifiers,
const std::map< std::string, std::string > & parameters,
const Issue * cause = 0 ) const

build issue out of all the given parameters

◆ instance()

ers::IssueFactory & ers::IssueFactory::instance ( )
static

method to access singleton

Returns the singleton instance of the factory.

Returns
a reference to the singleton instance

Definition at line 22 of file IssueFactory.cpp.

23{
25
26 return *instance;
27} // instance
Implements factory pattern for user defined Issues.
static IssueFactory & instance()
method to access singleton

◆ register_issue()

void ers::IssueFactory::register_issue ( const std::string & name,
IssueCreator creator )

register an issue factory

Register an issue type with the factory

Parameters
namethe name that will be used to lookup new instances
creatora pointer to the function used to create new instance for that particular type of function

Definition at line 34 of file IssueFactory.cpp.

35{
36 FunctionMap::const_iterator it = m_creators.find(name);
37 if ( it == m_creators.end() )
38 {
39 m_creators[name] = creator;
40 }
41}

Friends And Related Symbol Documentation

◆ SingletonCreator

template<class >
friend class SingletonCreator
friend

Definition at line 46 of file IssueFactory.hpp.

Member Data Documentation

◆ m_creators

FunctionMap ers::IssueFactory::m_creators
private

Definition at line 73 of file IssueFactory.hpp.


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