LCOV - code coverage report
Current view: top level - dbe/src/internal - config_api_set.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 8.9 % 112 10
Test Date: 2026-07-12 15:23:06 Functions: 50.0 % 4 2

            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_set.cpp
       8              :  *
       9              :  *  Created on: Apr 19, 2016
      10              :  *      Author: Leonidas Georgopoulos
      11              :  */
      12              : 
      13              : #include "dbe/config_api_set.hpp"
      14              : #include "dbe/config_api_info.hpp"
      15              : #include "dbe/config_api.hpp"
      16              : #include "dbe/config_api_commands.hpp"
      17              : #include "dbe/config_object_key.hpp"
      18              : #include "dbe/Conversion.hpp"
      19              : #include "dbe/dbcontroller.hpp"
      20              : 
      21              : #include "conffwk/Schema.hpp"
      22              : 
      23              : #include <QString>
      24              : 
      25              : #include <stdint.h>
      26              : #include <sys/types.h>
      27              : #include <algorithm>
      28              : #include <iterator>
      29              : 
      30              : //------------------------------------------------------------------------------------------
      31              : // NAMESPACE DBE::CONFIG::API::SET::NOACTIONS
      32              : //------------------------------------------------------------------------------------------
      33              : namespace dbe
      34              : {
      35              : namespace config
      36              : {
      37              : namespace api
      38              : {
      39              : namespace set
      40              : {
      41              : namespace noactions
      42              : {
      43              : 
      44            1 : void relation ( tref object, dunedaq::conffwk::relationship_t const & arelation,
      45              :                 std::vector<dbe::cokey> const & keys )
      46              : {
      47            1 :   std::vector<dbe::inner::configobject::tref> trefs;
      48              : 
      49            1 :   for ( dbe::cokey const & key : keys )
      50              :   {
      51            0 :     trefs.push_back ( dbe::inner::dbcontroller::get ( key ) );
      52              :   }
      53              : 
      54            1 :   dbe::config::api::set::noactions::relation ( object, arelation, trefs );
      55            1 : }
      56              : 
      57            1 : void relation ( tref src, dunedaq::conffwk::relationship_t const & edge,
      58              :                 std::vector<tref> const & targets )
      59              : {
      60            1 :   try
      61              :   {
      62            1 :     if ( not targets.empty() )
      63              :     {
      64            0 :       if ( info::relation::is_simple ( edge ) )
      65              :       {
      66            0 :         src.set_obj ( edge.p_name, targets.back() );
      67              :       }
      68              :       else
      69              :       {
      70            0 :         src.set_objs ( edge.p_name, targets );
      71              :       }
      72              :     }
      73              :     else
      74              :     {
      75            1 :         src.set_obj_null( edge.p_name, info::relation::is_simple(edge) );
      76              :     }
      77              :   }
      78            0 :   catch ( dunedaq::conffwk::Exception const & e )
      79              :   {
      80            0 :     throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, config::errors::parse ( e ) );
      81            0 :   }
      82            1 : }
      83              : //------------------------------------------------------------------------------------------
      84              : }
      85              : }
      86              : }
      87              : }
      88              : }
      89              : //------------------------------------------------------------------------------------------
      90              : 
      91              : //------------------------------------------------------------------------------------------
      92              : // NAMESPACE DBE::CONFIG::API::SET
      93              : //------------------------------------------------------------------------------------------
      94              : namespace dbe
      95              : {
      96              : namespace config
      97              : {
      98              : namespace api
      99              : {
     100              : namespace set
     101              : {
     102              : 
     103              : //------------------------------------------------------------------------------------------
     104            0 : void relation ( tref src, dunedaq::conffwk::relationship_t const & edge,
     105              :                 QStringList const & targets )
     106              : {
     107            0 :   std::vector<std::string> targetnames;
     108              : 
     109            0 :   for ( QString const & name : targets )
     110              :   {
     111            0 :     targetnames.push_back ( name.toStdString() );
     112              :   }
     113              : 
     114            0 :   commands::modobj ( src, edge, targetnames );
     115            0 : }
     116              : //------------------------------------------------------------------------------------------
     117              : 
     118              : //------------------------------------------------------------------------------------------
     119            0 : void attribute ( tref Object, dunedaq::conffwk::attribute_t const & attribute_info,
     120              :                  QStringList const & values )
     121              : {
     122            0 :   switch ( attribute_info.p_type )
     123              :   {
     124            0 :   case dunedaq::conffwk::bool_type:
     125            0 :   {
     126            0 :     if ( attribute_info.p_is_multi_value )
     127              :     {
     128            0 :       commands::modobj (
     129              :         Object, attribute_info,
     130            0 :         convert::to<std::vector<bool>> ( values, attribute_info.p_int_format ) );
     131              :     }
     132              :     else
     133              :     {
     134            0 :       commands::modobj ( Object, attribute_info,
     135            0 :                          convert::to<bool> ( values, attribute_info.p_int_format ) );
     136              :     }
     137              : 
     138              :     break;
     139              :   }
     140              : 
     141            0 :   case dunedaq::conffwk::enum_type:
     142            0 :   case dunedaq::conffwk::date_type:
     143            0 :   case dunedaq::conffwk::time_type:
     144            0 :   case dunedaq::conffwk::string_type:
     145            0 :   case dunedaq::conffwk::class_type:
     146            0 :   {
     147            0 :     if ( attribute_info.p_is_multi_value )
     148              :     {
     149            0 :       commands::modobj ( Object, attribute_info,
     150            0 :                          convert::to<std::vector<std::string>> ( values ) );
     151              :     }
     152              :     else
     153              :     {
     154            0 :       commands::modobj ( Object, attribute_info, convert::to<std::string> ( values ) );
     155              :     }
     156              : 
     157              :     break;
     158              :   }
     159              : 
     160            0 :   case dunedaq::conffwk::float_type:
     161            0 :   {
     162            0 :     if ( attribute_info.p_is_multi_value )
     163              :     {
     164            0 :       commands::modobj (
     165              :         Object, attribute_info,
     166            0 :         convert::to<std::vector<float>> ( values, attribute_info.p_int_format ) );
     167              :     }
     168              :     else
     169              :     {
     170            0 :       commands::modobj ( Object, attribute_info,
     171            0 :                          convert::to<float> ( values, attribute_info.p_int_format ) );
     172              :     }
     173              : 
     174              :     break;
     175              :   }
     176              : 
     177            0 :   case dunedaq::conffwk::double_type:
     178            0 :   {
     179            0 :     if ( attribute_info.p_is_multi_value )
     180              :     {
     181            0 :       commands::modobj (
     182              :         Object, attribute_info,
     183            0 :         convert::to<std::vector<double>> ( values, attribute_info.p_int_format ) );
     184              :     }
     185              :     else
     186              :     {
     187            0 :       commands::modobj ( Object, attribute_info,
     188            0 :                          convert::to<double> ( values, attribute_info.p_int_format ) );
     189              :     }
     190              : 
     191              :     break;
     192              :   }
     193              : 
     194            0 :   case dunedaq::conffwk::s8_type:
     195            0 :   {
     196            0 :     if ( attribute_info.p_is_multi_value )
     197              :     {
     198            0 :       commands::modobj (
     199              :         Object, attribute_info,
     200            0 :         convert::to<std::vector<int8_t>> ( values, attribute_info.p_int_format ) );
     201              :     }
     202              :     else
     203              :     {
     204            0 :       commands::modobj ( Object, attribute_info,
     205            0 :                          convert::to<int8_t> ( values, attribute_info.p_int_format ) );
     206              :     }
     207              : 
     208              :     break;
     209              :   }
     210              : 
     211            0 :   case dunedaq::conffwk::s16_type:
     212            0 :   {
     213            0 :     if ( attribute_info.p_is_multi_value )
     214              :     {
     215            0 :       commands::modobj (
     216              :         Object, attribute_info,
     217            0 :         convert::to<std::vector<int16_t>> ( values, attribute_info.p_int_format ) );
     218              :     }
     219              :     else
     220              :     {
     221            0 :       commands::modobj ( Object, attribute_info,
     222            0 :                          convert::to<int16_t> ( values, attribute_info.p_int_format ) );
     223              :     }
     224              : 
     225              :     break;
     226              :   }
     227              : 
     228            0 :   case dunedaq::conffwk::s32_type:
     229            0 :   {
     230            0 :     if ( attribute_info.p_is_multi_value )
     231              :     {
     232            0 :       commands::modobj (
     233              :         Object, attribute_info,
     234            0 :         convert::to<std::vector<int32_t>> ( values, attribute_info.p_int_format ) );
     235              :     }
     236              :     else
     237              :     {
     238            0 :       commands::modobj ( Object, attribute_info,
     239            0 :                          convert::to<int32_t> ( values, attribute_info.p_int_format ) );
     240              :     }
     241              : 
     242              :     break;
     243              :   }
     244              : 
     245            0 :   case dunedaq::conffwk::s64_type:
     246            0 :   {
     247            0 :     if ( attribute_info.p_is_multi_value )
     248              :     {
     249            0 :       commands::modobj (
     250              :         Object, attribute_info,
     251            0 :         convert::to<std::vector<int64_t>> ( values, attribute_info.p_int_format ) );
     252              :     }
     253              :     else
     254              :     {
     255            0 :       commands::modobj ( Object, attribute_info,
     256            0 :                          convert::to<int64_t> ( values, attribute_info.p_int_format ) );
     257              :     }
     258              : 
     259              :     break;
     260              :   }
     261              : 
     262            0 :   case dunedaq::conffwk::u8_type:
     263            0 :   {
     264            0 :     if ( attribute_info.p_is_multi_value )
     265              :     {
     266            0 :       commands::modobj (
     267              :         Object, attribute_info,
     268            0 :         convert::to<std::vector<u_int8_t>> ( values, attribute_info.p_int_format ) );
     269              :     }
     270              :     else
     271              :     {
     272            0 :       commands::modobj ( Object, attribute_info,
     273            0 :                          convert::to<u_int8_t> ( values, attribute_info.p_int_format ) );
     274              :     }
     275              : 
     276              :     break;
     277              :   }
     278              : 
     279            0 :   case dunedaq::conffwk::u16_type:
     280            0 :   {
     281            0 :     if ( attribute_info.p_is_multi_value )
     282              :     {
     283            0 :       commands::modobj (
     284              :         Object, attribute_info,
     285            0 :         convert::to<std::vector<u_int16_t>> ( values, attribute_info.p_int_format ) );
     286              :     }
     287              :     else
     288              :     {
     289            0 :       commands::modobj (
     290              :         Object, attribute_info,
     291            0 :         convert::to<u_int16_t> ( values, attribute_info.p_int_format ) );
     292              :     }
     293              : 
     294              :     break;
     295              :   }
     296              : 
     297            0 :   case dunedaq::conffwk::u32_type:
     298            0 :   {
     299            0 :     if ( attribute_info.p_is_multi_value )
     300              :     {
     301            0 :       commands::modobj (
     302              :         Object, attribute_info,
     303            0 :         convert::to<std::vector<u_int32_t>> ( values, attribute_info.p_int_format ) );
     304              :     }
     305              :     else
     306              :     {
     307            0 :       commands::modobj (
     308              :         Object, attribute_info,
     309            0 :         convert::to<u_int32_t> ( values, attribute_info.p_int_format ) );
     310              :     }
     311              : 
     312              :     break;
     313              :   }
     314              : 
     315            0 :   case dunedaq::conffwk::u64_type:
     316            0 :   {
     317            0 :     if ( attribute_info.p_is_multi_value ) commands::modobj (
     318              :         Object, attribute_info,
     319            0 :         convert::to<std::vector<u_int64_t>> ( values, attribute_info.p_int_format ) );
     320            0 :     else commands::modobj (
     321              :         Object, attribute_info,
     322            0 :         convert::to<u_int64_t> ( values, attribute_info.p_int_format ) );
     323              : 
     324              :     break;
     325              :   }
     326              : 
     327              :   default:
     328              :     break;
     329              :   }
     330            0 : }
     331              : //------------------------------------------------------------------------------------------
     332              : }
     333              : }
     334              : }
     335              : }
     336              : //------------------------------------------------------------------------------------------
     337              : 
        

Generated by: LCOV version 2.0-1