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/AnyIssue.hpp>
23#include <ers/IssueFactory.hpp>
24#include <ers/StreamFactory.hpp>
25#include <ers/ers.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 m_creators[name] = creator;
50 }
51}
52
59ers::IssueFactory::create(const std::string& name, const ers::Context& context) const
60{
61 FunctionMap::const_iterator it = m_creators.find(name);
62 if (it == m_creators.end()) {
63 ERS_INTERNAL_DEBUG(1, "Creator for the \"" << name << "\" issue is not found");
64 return new ers::AnyIssue(name, context);
65 }
66
67 ERS_INTERNAL_DEBUG(2, "Creating the \"" << name << "\" issue");
68 return (it->second)(context);
69}
70
72ers::IssueFactory::create(const std::string& name,
73 const std::list<std::string>& inheritance,
74 const ers::Context& context,
76 const system_clock::time_point& time,
77 const std::string& message,
78 const std::vector<std::string>& qualifiers,
79 const ers::string_map& parameters,
80 const Issue* cause) const
81{
82 ers::Issue* issue = create(name, context);
83 issue->m_message = message;
84 issue->m_severity = severity;
85 issue->m_qualifiers = qualifiers;
86 issue->m_values = parameters;
87 issue->m_time = time;
88 issue->m_cause.reset(cause);
89
90 auto* any = dynamic_cast<ers::AnyIssue*>(issue);
91 if (any) {
92 any->m_inheritance = inheritance;
93 }
94 return issue;
95}
An abstract interface to access an Issue context.
Definition Context.hpp:40
Implements factory pattern for user defined Issues.
Issue *(*) IssueCreator(const ers::Context &)
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:76
Severity m_severity
Issue's severity.
Definition Issue.hpp:176
system_clock::time_point m_time
Time when issue was thrown.
Definition Issue.hpp:177
std::unique_ptr< const Issue > m_cause
Issue that caused the current issue.
Definition Issue.hpp:172
string_map m_values
List of user defined attributes.
Definition Issue.hpp:178
std::string m_message
Issue's explanation text.
Definition Issue.hpp:174
std::vector< std::string > m_qualifiers
List of associated qualifiers.
Definition Issue.hpp:175
#define ERS_INTERNAL_DEBUG(level, message)
Definition macro.hpp:42
message(message)
Definition __init__.py:84
std::map< std::string, std::string > string_map
Definition Issue.hpp:52
severity
Definition Severity.hpp:37