LCOV - code coverage report
Current view: top level - ers/src - IssueFactory.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 29.6 % 27 8
Test Date: 2026-10-11 15:05:20 Functions: 50.0 % 4 2

            Line data    Source code
       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>
      26              : #include <ers/internal/SingletonCreator.hpp>
      27              : #include <ers/internal/macro.hpp>
      28              : 
      29              : /** Returns the singleton instance of the factory.
      30              :  * \return a reference to the singleton instance
      31              :  */
      32              : ers::IssueFactory&
      33       232408 : ers::IssueFactory::instance()
      34              : {
      35       232408 :   static ers::IssueFactory* instance = ers::SingletonCreator<ers::IssueFactory>::create();
      36              : 
      37       232408 :   return *instance;
      38              : } // instance
      39              : 
      40              : /** Register an issue type with the factory
      41              :  * \param name the name that will be used to lookup new instances
      42              :  * \param creator a pointer to the function used to create new instance for that particular type of function
      43              :  */
      44              : void
      45       232408 : ers::IssueFactory::register_issue(const std::string& name, IssueCreator creator)
      46              : {
      47       232408 :   FunctionMap::const_iterator it = m_creators.find(name);
      48       232408 :   if (it == m_creators.end()) {
      49        10101 :     m_creators[name] = creator;
      50              :   }
      51       232408 : }
      52              : 
      53              : /** Builds an issue out of the name it was registered with
      54              :  * \param name the name used to indentify the class
      55              :  * \return an newly allocated instance of type \c name or AnyIssue
      56              :  * \note If the requested type cannot be resolved an instance of type AnyIssue
      57              :  */
      58              : ers::Issue*
      59            0 : ers::IssueFactory::create(const std::string& name, const ers::Context& context) const
      60              : {
      61            0 :   FunctionMap::const_iterator it = m_creators.find(name);
      62            0 :   if (it == m_creators.end()) {
      63            0 :     ERS_INTERNAL_DEBUG(1, "Creator for the \"" << name << "\" issue is not found");
      64            0 :     return new ers::AnyIssue(name, context);
      65              :   }
      66              : 
      67            0 :   ERS_INTERNAL_DEBUG(2, "Creating the \"" << name << "\" issue");
      68            0 :   return (it->second)(context);
      69              : }
      70              : 
      71              : ers::Issue*
      72            0 : ers::IssueFactory::create(const std::string& name,
      73              :                           const std::list<std::string>& inheritance,
      74              :                           const ers::Context& context,
      75              :                           Severity severity,
      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            0 :   ers::Issue* issue = create(name, context);
      83            0 :   issue->m_message = message;
      84            0 :   issue->m_severity = severity;
      85            0 :   issue->m_qualifiers = qualifiers;
      86            0 :   issue->m_values = parameters;
      87            0 :   issue->m_time = time;
      88            0 :   issue->m_cause.reset(cause);
      89              : 
      90            0 :   auto* any = dynamic_cast<ers::AnyIssue*>(issue);
      91            0 :   if (any) {
      92            0 :     any->m_inheritance = inheritance;
      93              :   }
      94            0 :   return issue;
      95              : }
        

Generated by: LCOV version 2.0-1