LCOV - code coverage report
Current view: top level - data/include/set - data_stat.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 28 40 70.0 %
Date: 2024-04-07 11:14:42 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /* File: data_stat.inl; Copyright and License: see below */
       2             : 
       3             : #include "utf8stringbuf/utf8stringbuf.h"
       4             : #include "u8/u8_trace.h"
       5             : #include <assert.h>
       6             : 
       7         186 : static inline void data_stat_init ( data_stat_t *this_ )
       8             : {
       9             :     assert( (int)DATA_TABLE_CLASSIFIER < (int)DATA_STAT_TABLE_MAX );
      10             :     assert( (int)DATA_TABLE_FEATURE < (int)DATA_STAT_TABLE_MAX );
      11             :     assert( (int)DATA_TABLE_RELATIONSHIP < (int)DATA_STAT_TABLE_MAX );
      12             :     assert( (int)DATA_TABLE_DIAGRAMELEMENT < (int)DATA_STAT_TABLE_MAX );
      13             :     assert( (int)DATA_TABLE_DIAGRAM < (int)DATA_STAT_TABLE_MAX );
      14             : 
      15        1302 :     for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
      16             :     {
      17        7812 :         for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
      18             :         {
      19        6696 :             (*this_).data[tables_idx][series_idx] = 0;
      20             :         }
      21             :     }
      22         186 : }
      23             : 
      24         186 : static inline void data_stat_destroy ( data_stat_t *this_ )
      25             : {
      26         186 : }
      27             : 
      28         228 : static inline uint_fast32_t data_stat_get_count ( const data_stat_t *this_,
      29             :                                                   data_stat_table_t table,
      30             :                                                   data_stat_series_t series )
      31             : {
      32         228 :     assert( table < DATA_STAT_TABLE_MAX );
      33         228 :     assert( series < DATA_STAT_SERIES_MAX );
      34         228 :     return (*this_).data[table][series];
      35             : }
      36             : 
      37         261 : static inline void data_stat_inc_count ( data_stat_t *this_,
      38             :                                          data_stat_table_t table,
      39             :                                          data_stat_series_t series )
      40             : {
      41         261 :     assert( table < DATA_STAT_TABLE_MAX );
      42         261 :     assert( series < DATA_STAT_SERIES_MAX );
      43         261 :     (*this_).data[table][series]++;
      44         261 : }
      45             : 
      46             : static inline void data_stat_add_count ( data_stat_t *this_,
      47             :                                          data_stat_table_t table,
      48             :                                          data_stat_series_t series,
      49             :                                          int_fast32_t increment )
      50             : {
      51             :     assert( table < DATA_STAT_TABLE_MAX );
      52             :     assert( series < DATA_STAT_SERIES_MAX );
      53             :     (*this_).data[table][series] += increment;
      54             : }
      55             : 
      56           0 : static inline void data_stat_add ( data_stat_t *this_, const data_stat_t *that )
      57             : {
      58           0 :     assert( that != NULL );
      59           0 :     for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
      60             :     {
      61           0 :         for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
      62             :         {
      63           0 :             (*this_).data[tables_idx][series_idx] += (*that).data[tables_idx][series_idx];
      64             :         }
      65             :     }
      66           0 : }
      67             : 
      68           0 : static inline uint_fast32_t data_stat_get_series_count ( const data_stat_t *this_,
      69             :                                                          data_stat_series_t series )
      70             : {
      71           0 :     assert( series < DATA_STAT_SERIES_MAX );
      72           0 :     uint_fast32_t result = 0;
      73           0 :     for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
      74             :     {
      75           0 :         result += (*this_).data[tables_idx][series];
      76             :     }
      77           0 :     return result;
      78             : }
      79             : 
      80          13 : static inline uint_fast32_t data_stat_get_table_count ( const data_stat_t *this_,
      81             :                                                         data_stat_table_t table )
      82             : {
      83          13 :     assert( table < DATA_STAT_TABLE_MAX );
      84          13 :     uint_fast32_t result = 0;
      85          91 :     for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
      86             :     {
      87          78 :         result += (*this_).data[table][series_idx];
      88             :     }
      89          13 :     return result;
      90             : }
      91             : 
      92         185 : static inline uint_fast32_t data_stat_get_total_count ( const data_stat_t *this_ )
      93             : {
      94         185 :     uint_fast32_t result = 0;
      95        1295 :     for ( int series_idx = 0; series_idx < DATA_STAT_SERIES_MAX; series_idx ++ )
      96             :     {
      97        7770 :         for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
      98             :         {
      99        6660 :             result += (*this_).data[tables_idx][series_idx];
     100             :         }
     101             :     }
     102         185 :     return result;
     103             : }
     104             : 
     105             : static void inline data_stat_reset_series( data_stat_t *this_, data_stat_series_t series )
     106             : {
     107             :     assert( series < DATA_STAT_SERIES_MAX );
     108             :     for ( int tables_idx = 0; tables_idx < DATA_STAT_TABLE_MAX; tables_idx ++ )
     109             :     {
     110             :         (*this_).data[tables_idx][series] = 0;
     111             :     }
     112             : }
     113             : 
     114             : 
     115             : /*
     116             : Copyright 2020-2024 Andreas Warnke
     117             : 
     118             : Licensed under the Apache License, Version 2.0 (the "License");
     119             : you may not use this file except in compliance with the License.
     120             : You may obtain a copy of the License at
     121             : 
     122             :     http://www.apache.org/licenses/LICENSE-2.0
     123             : 
     124             : Unless required by applicable law or agreed to in writing, software
     125             : distributed under the License is distributed on an "AS IS" BASIS,
     126             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     127             : See the License for the specific language governing permissions and
     128             : limitations under the License.
     129             : */

Generated by: LCOV version 1.16