LCOV - code coverage report
Current view: top level - dbe/src/internal - config_api_get.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 148 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 55 0

            Line data    Source code
       1              : // DUNE DAQ modification notice:
       2              : // This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
       3              : // Fork baseline commit: dbe-02-12-17 (2022-05-12).
       4              : // Renamed since fork: no.
       5              : 
       6              : /*
       7              :  * config_api_get.cpp
       8              :  *
       9              :  *  Created on: Apr 19, 2016
      10              :  *      Author: Leonidas Georgopoulos
      11              :  */
      12              : 
      13              : #include "dbe/config_api_get.hpp"
      14              : #include "dbe/Conversion.hpp"
      15              : #include "dbe/dbaccessor.hpp"
      16              : #include "dbe/messenger.hpp"
      17              : #include "dbe/config_api.hpp"
      18              : 
      19              : using namespace dunedaq::conffwk;
      20              : 
      21              : 
      22              : //------------------------------------------------------------------------------------------
      23              : // NAMESPACE DBE::CONFIG::API::GET
      24              : //------------------------------------------------------------------------------------------
      25              : 
      26              : namespace dbe
      27              : {
      28              : 
      29              : namespace config
      30              : {
      31              : 
      32              : namespace api
      33              : {
      34              : 
      35              : namespace get
      36              : {
      37              : //------------------------------------------------------------------------------------------
      38              : 
      39              : template<typename T>
      40            0 : inline std::vector<std::string> attribute::read (
      41              :   ConfigObject & input, dunedaq::conffwk::attribute_t const & attr )
      42              : {
      43            0 :   std::vector<T> attrvalues;
      44              : 
      45            0 :   if ( attr.p_is_multi_value )
      46              :   {
      47            0 :     attrvalues = direct::attribute<std::vector<T>> ( input, attr );
      48              :   }
      49              :   else
      50              :   {
      51            0 :     attrvalues =
      52            0 :     { direct::attribute<T> ( input, attr ) };
      53              :   }
      54              : 
      55            0 :   std::vector<std::string> strings ( attrvalues.size() );
      56            0 :   std::transform ( attrvalues.begin(), attrvalues.end(),
      57            0 :                    strings.begin(), [&attr] ( T const & x )
      58              :   {
      59            0 :     return convert::valtostr ( x, attr.p_int_format );
      60              :   }
      61              : 
      62              :                  );
      63              : 
      64            0 :   return strings;
      65            0 : }
      66              : 
      67              : //------------------------------------------------------------------------------------------
      68              : 
      69              : //------------------------------------------------------------------------------------------
      70              : template<typename T>
      71            0 : inline T direct::attribute ( ConfigObject & input,
      72              :                              dunedaq::conffwk::attribute_t const & attr )
      73              : {
      74            0 :   T value;
      75            0 :   input.get ( attr.p_name, value );
      76            0 :   return value;
      77            0 : }
      78              : 
      79              : //------------------------------------------------------------------------------------------
      80              : 
      81              : //------------------------------------------------------------------------------------------
      82              : template<>
      83            0 : QStringList direct::attribute<QStringList> ( ConfigObject & input,
      84              :                                              dunedaq::conffwk::attribute_t const & attr )
      85              : {
      86            0 :   std::vector<std::string> data;
      87              : 
      88            0 :   switch ( attr.p_type )
      89              :   {
      90              : 
      91            0 :   case dunedaq::conffwk::bool_type:
      92            0 :     data = get::attribute::read<bool> ( input, attr );
      93            0 :     break;
      94              : 
      95            0 :   case dunedaq::conffwk::enum_type:
      96              : 
      97            0 :   case dunedaq::conffwk::date_type:
      98              : 
      99            0 :   case dunedaq::conffwk::time_type:
     100              : 
     101            0 :   case dunedaq::conffwk::string_type:
     102              : 
     103            0 :   case dunedaq::conffwk::class_type:
     104            0 :     data = get::attribute::read<std::string> ( input, attr );
     105            0 :     break;
     106              : 
     107            0 :   case dunedaq::conffwk::float_type:
     108            0 :     data = get::attribute::read<float> ( input, attr );
     109            0 :     break;
     110              : 
     111            0 :   case dunedaq::conffwk::double_type:
     112            0 :     data = get::attribute::read<double> ( input, attr );
     113            0 :     break;
     114              : 
     115            0 :   case dunedaq::conffwk::s8_type:
     116            0 :     data = get::attribute::read<int8_t> ( input, attr );
     117            0 :     break;
     118              : 
     119            0 :   case dunedaq::conffwk::u8_type:
     120            0 :     data = get::attribute::read<u_int8_t> ( input, attr );
     121            0 :     break;
     122              : 
     123            0 :   case dunedaq::conffwk::s16_type:
     124            0 :     data = get::attribute::read<int16_t> ( input, attr );
     125            0 :     break;
     126              : 
     127            0 :   case dunedaq::conffwk::u16_type:
     128            0 :     data = get::attribute::read<u_int16_t> ( input, attr );
     129            0 :     break;
     130              : 
     131            0 :   case dunedaq::conffwk::s32_type:
     132            0 :     data = get::attribute::read<int32_t> ( input, attr );
     133            0 :     break;
     134              : 
     135            0 :   case dunedaq::conffwk::u32_type:
     136            0 :     data = get::attribute::read<u_int32_t> ( input, attr );
     137            0 :     break;
     138              : 
     139            0 :   case dunedaq::conffwk::s64_type:
     140            0 :     data = get::attribute::read<int64_t> ( input, attr );
     141            0 :     break;
     142              : 
     143            0 :   case dunedaq::conffwk::u64_type:
     144            0 :     data = get::attribute::read<u_int64_t> ( input, attr );
     145            0 :     break;
     146              :   }
     147              : 
     148            0 :   QStringList result;
     149              : 
     150            0 :   for ( auto const & x : data )
     151              :   {
     152            0 :     result.push_back ( x.c_str() );
     153              :   }
     154              : 
     155            0 :   return result;
     156              : 
     157            0 : }
     158              : 
     159              : template
     160              : QStringList direct::attribute<QStringList>
     161              : ( ConfigObject &,
     162              :   dunedaq::conffwk::attribute_t const & );
     163              : 
     164              : template
     165              : ConfigObject direct::attribute<ConfigObject>
     166              : ( ConfigObject &,
     167              :   dunedaq::conffwk::attribute_t const & );
     168              : 
     169              : template
     170              : std::vector<ConfigObject>
     171              : direct::attribute<std::vector<ConfigObject>> (
     172              :                                             ConfigObject &, dunedaq::conffwk::attribute_t const & );
     173              : 
     174              : //------------------------------------------------------------------------------------------
     175              : 
     176              : //------------------------------------------------------------------------------------------
     177              : template<typename T>
     178            0 : inline T attribute::list ( dbe::inner::configobject::tref obj,
     179              :                            dunedaq::conffwk::attribute_t const & Attribute )
     180              : {
     181            0 :   std::vector<std::string> attrvalues;
     182              : 
     183            0 :   switch ( Attribute.p_type )
     184              :   {
     185              : 
     186            0 :   case dunedaq::conffwk::bool_type:
     187            0 :     attrvalues = get::attribute::read<bool> ( obj, Attribute );
     188            0 :     break;
     189              : 
     190            0 :   case dunedaq::conffwk::enum_type:
     191              : 
     192              :   case dunedaq::conffwk::date_type:
     193              : 
     194              :   case dunedaq::conffwk::time_type:
     195              : 
     196              :   case dunedaq::conffwk::string_type:
     197              : 
     198              :   case dunedaq::conffwk::class_type:
     199            0 :     attrvalues = get::attribute::read<std::string> ( obj, Attribute );
     200            0 :     break;
     201              : 
     202            0 :   case dunedaq::conffwk::float_type:
     203            0 :     attrvalues = get::attribute::read<float> ( obj, Attribute );
     204            0 :     break;
     205              : 
     206            0 :   case dunedaq::conffwk::double_type:
     207            0 :     attrvalues = get::attribute::read<double> ( obj, Attribute );
     208            0 :     break;
     209              : 
     210            0 :   case dunedaq::conffwk::s8_type:
     211            0 :     attrvalues = get::attribute::read<int8_t> ( obj, Attribute );
     212            0 :     break;
     213              : 
     214            0 :   case dunedaq::conffwk::u8_type:
     215            0 :     attrvalues = get::attribute::read<u_int8_t> ( obj, Attribute );
     216            0 :     break;
     217              : 
     218            0 :   case dunedaq::conffwk::s16_type:
     219            0 :     attrvalues = get::attribute::read<int16_t> ( obj, Attribute );
     220            0 :     break;
     221              : 
     222            0 :   case dunedaq::conffwk::u16_type:
     223            0 :     attrvalues = get::attribute::read<u_int16_t> ( obj, Attribute );
     224            0 :     break;
     225              : 
     226            0 :   case dunedaq::conffwk::s32_type:
     227            0 :     attrvalues = get::attribute::read<int32_t> ( obj, Attribute );
     228            0 :     break;
     229              : 
     230            0 :   case dunedaq::conffwk::u32_type:
     231            0 :     attrvalues = get::attribute::read<u_int32_t> ( obj, Attribute );
     232            0 :     break;
     233              : 
     234            0 :   case dunedaq::conffwk::s64_type:
     235            0 :     attrvalues = get::attribute::read<int64_t> ( obj, Attribute );
     236            0 :     break;
     237              : 
     238            0 :   case dunedaq::conffwk::u64_type:
     239            0 :     attrvalues = get::attribute::read<u_int64_t> ( obj, Attribute );
     240            0 :     break;
     241              :   }
     242              : 
     243            0 :   return dbe::convert::to<T> ( attrvalues );
     244            0 : }
     245              : 
     246              : // Template method declaration of attribute::list for type QStringList
     247              : template
     248              : QStringList attribute::list<QStringList> ( dbe::inner::configobject::tref obj,
     249              :                               dunedaq::conffwk::attribute_t const & );
     250              : //------------------------------------------------------------------------------------------
     251              : 
     252              : //------------------------------------------------------------------------------------------
     253            0 : QStringList file::inclusions ( QStringList const & candidates, QStringList files )
     254              : {
     255            0 :   if ( candidates.isEmpty() )
     256              :   {
     257            0 :     return files;
     258              :   }
     259              :   else
     260              :   {
     261            0 :     QStringList newcandidates =
     262            0 :     { };
     263              : 
     264            0 :     for ( QString const & fname : candidates )
     265              :     {
     266            0 :       if ( not ( fname.endsWith ( "schema.xml" ) or files.contains ( fname ) ) )
     267              :       {
     268            0 :         files.push_back ( fname );
     269              :         // Query the current file for other inclusions
     270            0 :         std::list<std::string> configfiles;
     271              : 
     272            0 :         try
     273              :         {
     274            0 :           if ( not ( fname.contains ( "rdbconfig:" ) or fname.contains ( "roksconflibs:" ) ) )
     275              :           {
     276              :             // Process file based sources
     277            0 :             dbaccessor::dbptr()->get_includes ( fname.toStdString(), configfiles );
     278              :           }
     279              :           else
     280              :           {
     281              :             // Process other sources (e.g. Oracle and RDB )
     282            0 :             dbaccessor::dbptr()->get_includes ( "", configfiles );
     283            0 :             files.removeAll ( fname ); // Once used RDB / Oracle sources must be removed
     284              :           }
     285              :         }
     286            0 :         catch ( dunedaq::conffwk::Exception const & ex )
     287              :         {
     288            0 :           ERROR ( "Include did not succeed for ", dbe::config::errors::parse ( ex ).c_str(),
     289            0 :                   "filename:", fname.toStdString().c_str() );
     290            0 :         }
     291              : 
     292              :         // Keep only files that have not already been processed
     293              :         // i.e. they are not in the list of given files.
     294            0 :         for ( std::string const & configfile : configfiles )
     295              :         {
     296            0 :           QString const & qconfigfile = QString::fromStdString ( configfile );
     297              : 
     298            0 :           if ( not files.contains ( qconfigfile ) )
     299              :           {
     300            0 :             newcandidates.push_back ( qconfigfile );
     301              :           }
     302            0 :         }
     303              : 
     304            0 :       }
     305              : 
     306              :     }
     307              : 
     308            0 :     return get::file::inclusions ( newcandidates, files );
     309            0 :   }
     310              : }
     311              : 
     312              : //------------------------------------------------------------------------------------------
     313              : 
     314              : //------------------------------------------------------------------------------------------
     315            0 : QStringList file::inclusions_singlefile ( QString const & FileName )
     316              : {
     317            0 :   std::string dbname = FileName.toStdString();
     318            0 :   std::list<std::string> incList;
     319              : 
     320            0 :   QStringList dbfiles;
     321              : 
     322            0 :   try
     323              :   {
     324            0 :     dbaccessor::dbptr()->get_includes ( dbname, incList );
     325              : 
     326            0 :     for ( std::string const & includeName : incList )
     327              :     {
     328            0 :       dbfiles.push_back ( QString ( includeName.c_str() ) );
     329              :     }
     330              :   }
     331            0 :   catch ( dunedaq::conffwk::Exception & ex )
     332              :   {
     333            0 :     WARN ( "Include : Could not retrieve included files",
     334            0 :            dbe::config::errors::parse ( ex ).c_str() );
     335            0 :   }
     336              : 
     337            0 :   return dbfiles;
     338            0 : }
     339              : 
     340              : //------------------------------------------------------------------------------------------
     341              : 
     342              : //------------------------------------------------------------------------------------------
     343            0 : QStringList get::defaults::attribute::value ( dunedaq::conffwk::attribute_t const & attr )
     344              : {
     345            0 :   return QString::fromStdString ( attr.p_default_value ).split ( "," );
     346              : }
     347              : 
     348              : //------------------------------------------------------------------------------------------
     349              : 
     350              : //------------------------------------------------------------------------------------------
     351              : }
     352              : }
     353              : }
     354              : }
     355              : 
     356              : //------------------------------------------------------------------------------------------
     357              : 
        

Generated by: LCOV version 2.0-1