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: 2025-12-21 13:07:08 Functions: 50.0 % 4 2

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

Generated by: LCOV version 2.0-1