DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
IssueFactory.cpp
Go to the documentation of this file.
1/*
2 * DUNE DAQ modification notice:
3 * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4 * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5 * Renamed since fork: yes (from src/IssueFactory.cxx to src/IssueFactory.cpp).
6 *
7 * Original copyright:
8 * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9 * Licensed under the Apache License, Version 2.0.
10 */
11
12/*
13 * IssueFactory.cxx
14 * ers
15 *
16 * Created by Serguei Kolos on 30.11.04.
17 * Modified by Serguei Kolos on 10.08.05.
18 * Copyright 2005 CERN. All rights reserved.
19 *
20 */
21
22#include <ers/ers.hpp>
23#include <ers/IssueFactory.hpp>
24#include <ers/StreamFactory.hpp>
25#include <ers/AnyIssue.hpp>
28
39
44void
45ers::IssueFactory::register_issue( const std::string & name, IssueCreator creator )
46{
47 FunctionMap::const_iterator it = m_creators.find(name);
48 if ( it == m_creators.end() )
49 {
50 m_creators[name] = creator;
51 }
52}
53
60ers::IssueFactory::create( const std::string & name,
61 const ers::Context & context ) const
62{
63 FunctionMap::const_iterator it = m_creators.find(name);
64 if ( it == m_creators.end() )
65 {
66 ERS_INTERNAL_DEBUG( 1, "Creator for the \"" << name << "\" issue is not found" );
67 return new ers::AnyIssue( name, context );
68 }
69
70 ERS_INTERNAL_DEBUG( 2, "Creating the \"" << name << "\" issue" );
71 return (it->second)( context );
72}
73
74
76ers::IssueFactory::create( const std::string & name,
77 const std::list<std::string> & inheritance,
78 const ers::Context & context,
80 const system_clock::time_point & time,
81 const std::string & message,
82 const std::vector<std::string> & qualifiers,
83 const ers::string_map & parameters,
84 const Issue * cause ) const
85{
86 ers::Issue * issue = create( name, context );
87 issue->m_message = message;
88 issue->m_severity = severity;
89 issue->m_qualifiers = qualifiers;
90 issue->m_values = parameters;
91 issue->m_time = time;
92 issue->m_cause.reset( cause );
93
94 auto * any = dynamic_cast<ers::AnyIssue *>( issue );
95 if ( any ) {
96 any -> m_inheritance = inheritance;
97 }
98 return issue;
99}
100
An abstract interface to access an Issue context.
Definition Context.hpp:41
Implements factory pattern for user defined Issues.
static IssueFactory & instance()
method to access singleton
Issue *(* IssueCreator)(const ers::Context &)
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:80
Severity m_severity
Issue's severity.
Definition Issue.hpp:188
system_clock::time_point m_time
Time when issue was thrown.
Definition Issue.hpp:189
std::unique_ptr< const Issue > m_cause
Issue that caused the current issue.
Definition Issue.hpp:184
string_map m_values
List of user defined attributes.
Definition Issue.hpp:190
std::string m_message
Issue's explanation text.
Definition Issue.hpp:186
std::vector< std::string > m_qualifiers
List of associated qualifiers.
Definition Issue.hpp:187
#define ERS_INTERNAL_DEBUG(level, message)
Definition macro.hpp:37
message(message)
Definition __init__.py:84
std::map< std::string, std::string > string_map
Definition Issue.hpp:53
severity
Definition Severity.hpp:37