DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
IssueFactory.cpp
Go to the documentation of this file.
1/*
2 * IssueFactory.cxx
3 * ers
4 *
5 * Created by Serguei Kolos on 30.11.04.
6 * Modified by Serguei Kolos on 10.08.05.
7 * Copyright 2005 CERN. All rights reserved.
8 *
9 */
10
11#include <ers/ers.hpp>
12#include <ers/IssueFactory.hpp>
13#include <ers/StreamFactory.hpp>
14#include <ers/AnyIssue.hpp>
17
28
33void
34ers::IssueFactory::register_issue( const std::string & name, IssueCreator creator )
35{
36 FunctionMap::const_iterator it = m_creators.find(name);
37 if ( it == m_creators.end() )
38 {
39 m_creators[name] = creator;
40 }
41}
42
49ers::IssueFactory::create( const std::string & name,
50 const ers::Context & context ) const
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}
62
63
65ers::IssueFactory::create( const std::string & name,
66 const std::list<std::string> & inheritance,
67 const ers::Context & context,
69 const system_clock::time_point & time,
70 const std::string & message,
71 const std::vector<std::string> & qualifiers,
72 const ers::string_map & parameters,
73 const Issue * cause ) const
74{
75 ers::Issue * issue = create( name, context );
76 issue->m_message = message;
77 issue->m_severity = severity;
78 issue->m_qualifiers = qualifiers;
79 issue->m_values = parameters;
80 issue->m_time = time;
81 issue->m_cause.reset( cause );
82
83 auto * any = dynamic_cast<ers::AnyIssue *>( issue );
84 if ( any ) {
85 any -> m_inheritance = inheritance;
86 }
87 return issue;
88}
89
An abstract interface to access an Issue context.
Definition Context.hpp:30
Implements factory pattern for user defined Issues.
static IssueFactory & instance()
method to access singleton
void register_issue(const std::string &name, IssueCreator creator)
register an issue factory
FunctionMap m_creators
Issue * create(const std::string &name, const Context &context) const
build an empty issue for a given name
Base class for any user define issue.
Definition Issue.hpp:69
Severity m_severity
Issue's severity.
Definition Issue.hpp:177
system_clock::time_point m_time
Time when issue was thrown.
Definition Issue.hpp:178
std::unique_ptr< const Issue > m_cause
Issue that caused the current issue.
Definition Issue.hpp:173
string_map m_values
List of user defined attributes.
Definition Issue.hpp:179
std::string m_message
Issue's explanation text.
Definition Issue.hpp:175
std::vector< std::string > m_qualifiers
List of associated qualifiers.
Definition Issue.hpp:176
#define ERS_INTERNAL_DEBUG(level, message)
Definition macro.hpp:26
std::map< std::string, std::string > string_map
Definition Issue.hpp:42
message(message)
Definition __init__.py:84
severity
Definition Severity.hpp:26