LCOV - code coverage report
Current view: top level - ers/plugins - FilterStream.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 4.0 % 25 1
Test Date: 2026-07-12 15:23:06 Functions: 20.0 % 5 1

            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/streams/FilterStream.cxx to plugins/FilterStream.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              :  *  FilterStream.cxx
      14              :  *  ers
      15              :  *
      16              :  *  Created by Matthias Wiesmann on 31.03.05.
      17              :  *  Modified by Serguei Kolos on 11.08.05.
      18              :  *  Copyright 2005 CERN. All rights reserved.
      19              :  *
      20              :  */
      21              : 
      22              : #include <ers/internal/FilterStream.hpp>
      23              : #include <ers/internal/Util.hpp>
      24              : #include <ers/StreamFactory.hpp>
      25              : #include <algorithm>
      26              : 
      27           42 : ERS_REGISTER_OUTPUT_STREAM( ers::FilterStream, "filter", format )
      28              : 
      29              : namespace
      30              : {
      31              :     const char NOT = '!';
      32              :     const char * const SEPARATORS = "," ;
      33              : } // anonymous namespace 
      34              : 
      35              : /** Constructor that creates a new instance of the filter stream with the given configuration.
      36              :   * Only messages that pass the given filter will go through, the others will be filtered out.
      37              :   * \param format filter expression.
      38              :   */
      39            0 : ers::FilterStream::FilterStream( const std::string & format )
      40              : {
      41            0 :     std::vector<std::string> tokens;
      42            0 :     ers::tokenize( format, SEPARATORS, tokens );
      43            0 :     for( size_t i = 0; i < tokens.size(); i++ )
      44              :     {
      45            0 :         if ( !tokens[i].empty() && tokens[i][0] == NOT )
      46            0 :             m_exclude.push_back( tokens[i].substr( 1 ) );
      47              :         else
      48            0 :             m_include.push_back( tokens[i] );
      49              :     }
      50            0 : }
      51              : 
      52              : 
      53              : /** Filtering method 
      54              :   * This method checks if an Issue is to be accepted or not. 
      55              :   * \param issue_ptr the issue to check 
      56              :   * \return \c true if the Issue passes filtering, \c false otherwise.
      57              :   */
      58              : bool
      59            0 : ers::FilterStream::is_accepted( const ers::Issue & issue )
      60              : {
      61            0 :     const std::vector<std::string> & qualifiers = issue.qualifiers( );
      62              :                
      63            0 :     std::vector<std::string>::const_iterator it;
      64            0 :     for( it = m_exclude.begin(); it != m_exclude.end(); ++it )
      65              :     {
      66            0 :         std::vector<std::string>::const_iterator conflict = std::find( qualifiers.begin(), qualifiers.end(), *it );
      67            0 :         if ( conflict != qualifiers.end() )
      68              :         {
      69            0 :             return false;
      70              :         }
      71              :     }
      72              :     
      73            0 :     for( it = m_include.begin(); it != m_include.end(); ++it )
      74              :     {
      75            0 :         std::vector<std::string>::const_iterator match = std::find( qualifiers.begin(), qualifiers.end(), *it );
      76            0 :         if ( match != qualifiers.end() )
      77              :         {
      78            0 :             return true;
      79              :         }
      80              :     }
      81              : 
      82            0 :     return m_include.empty(); 
      83              : }
      84              : 
      85              : /** Write method 
      86              :   * basically calls \c is_accept to check if the issue is accepted. 
      87              :   * If this is the case, the \c write method on the chained stream is called with 
      88              :   * \c issue. 
      89              :   * \param issue issue to be sent.
      90              :   */
      91              : void
      92            0 : ers::FilterStream::write( const ers::Issue & issue )
      93              : {
      94            0 :     if ( is_accepted( issue ) )
      95              :     {
      96            0 :         chained().write( issue ); 
      97              :     }
      98            0 : } // send
      99              : 
        

Generated by: LCOV version 2.0-1