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-07-12 15:23:06 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/ers.hpp>
      23              : #include <ers/IssueFactory.hpp>
      24              : #include <ers/StreamFactory.hpp>
      25              : #include <ers/AnyIssue.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       216764 : ers::IssueFactory::instance()
      34              : {
      35       216764 :     static ers::IssueFactory * instance = ers::SingletonCreator<ers::IssueFactory>::create();
      36              :     
      37       216764 :     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       216764 : ers::IssueFactory::register_issue( const std::string & name, IssueCreator creator )
      46              : {
      47       216764 :     FunctionMap::const_iterator it = m_creators.find(name); 
      48       216764 :     if ( it == m_creators.end() )
      49              :     {
      50         9494 :         m_creators[name] = creator;
      51              :     }
      52       216764 : }
      53              : 
      54              : /** Builds an issue out of the name it was registered with 
      55              :   * \param name the name used to indentify the class 
      56              :   * \return an newly allocated instance of type \c name or AnyIssue 
      57              :   * \note If the requested type cannot be resolved an instance of type AnyIssue 
      58              :   */
      59              : ers::Issue * 
      60            0 : ers::IssueFactory::create(      const std::string & name,
      61              :                                 const ers::Context & context ) const
      62              : {
      63            0 :     FunctionMap::const_iterator it = m_creators.find(name); 
      64            0 :     if ( it == m_creators.end() )
      65              :     {
      66            0 :         ERS_INTERNAL_DEBUG( 1, "Creator for the \"" << name << "\" issue is not found" );
      67            0 :         return new ers::AnyIssue( name, context );
      68              :     }
      69              :     
      70            0 :     ERS_INTERNAL_DEBUG( 2, "Creating the \"" << name << "\" issue" );
      71            0 :     return (it->second)( context ); 
      72              : }
      73              : 
      74              : 
      75              : ers::Issue *
      76            0 : ers::IssueFactory::create(      const std::string & name,
      77              :                                 const std::list<std::string> & inheritance,
      78              :                                 const ers::Context & context,
      79              :                                 Severity severity,
      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            0 :     ers::Issue * issue = create( name, context );
      87            0 :     issue->m_message = message;
      88            0 :     issue->m_severity = severity;
      89            0 :     issue->m_qualifiers = qualifiers;
      90            0 :     issue->m_values = parameters;
      91            0 :     issue->m_time = time;
      92            0 :     issue->m_cause.reset( cause );
      93              : 
      94            0 :     auto * any = dynamic_cast<ers::AnyIssue *>( issue );
      95            0 :     if ( any ) {
      96            0 :       any -> m_inheritance = inheritance;
      97              :     }
      98            0 :     return issue;
      99              : }
     100              : 
        

Generated by: LCOV version 2.0-1