LCOV - code coverage report
Current view: top level - data/source - data_rules.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.70.5_covts Lines: 100.0 % 80 80
Test Date: 2026-05-28 21:31:40 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /* File: data_rules.c; Copyright and License: see below */
       2              : 
       3              : #include "data_rules.h"
       4              : #include "u8/u8_trace.h"
       5              : #include "u8/u8_log.h"
       6              : 
       7              : /* ================================ VISIBLE_SET ================================ */
       8              : 
       9          315 : bool data_rules_diagram_shows_feature ( const data_rules_t *this_, const data_visible_set_t *diagram_set, data_row_t feature_id )
      10              : {
      11          315 :     U8_TRACE_BEGIN();
      12          315 :     assert( NULL != diagram_set );
      13          315 :     bool result = false;
      14              : 
      15              :     /* search objects */
      16          315 :     const data_diagram_t *diag_ptr = data_visible_set_get_diagram_const( diagram_set );
      17          315 :     assert( diag_ptr != NULL );
      18          315 :     assert( data_diagram_is_valid( diag_ptr ) );
      19          315 :     const data_diagram_type_t diagram_type = data_diagram_get_diagram_type ( diag_ptr );
      20              : 
      21          315 :     const data_feature_t *feat_ptr = data_visible_set_get_feature_by_id_const ( diagram_set, feature_id );  /* SEARCH */
      22          315 :     assert( feat_ptr != NULL );
      23          315 :     assert( data_feature_is_valid( feat_ptr ) );
      24          315 :     const data_feature_type_t feature_type = data_feature_get_main_type ( feat_ptr );
      25              : 
      26          315 :     const bool is_feat_scenario = data_rules_feature_is_scenario_cond ( this_, feature_type );
      27              : 
      28          315 :     if ( is_feat_scenario )
      29              :     {
      30              :         /* a scenario-typed feature(=lifeline) that belongs to a different diagram is always filtered */
      31           10 :         bool is_foreign_scenario = true;
      32           10 :         const uint32_t vc_count = data_visible_set_get_visible_classifier_count ( diagram_set );
      33          424 :         for ( uint32_t vc_idx = 0; vc_idx < vc_count; vc_idx ++ )  /* SEARCH */
      34              :         {
      35          421 :             const data_visible_classifier_t *vc_probe = data_visible_set_get_visible_classifier_const ( diagram_set, vc_idx );
      36          421 :             assert ( NULL != vc_probe );
      37          421 :             const data_diagramelement_t *diag_ele = data_visible_classifier_get_diagramelement_const ( vc_probe );
      38          421 :             assert ( NULL != diag_ele );
      39          421 :             const data_row_t diag_ele_feat_id = data_diagramelement_get_focused_feature_row( diag_ele );
      40          421 :             if ( feature_id == diag_ele_feat_id )
      41              :             {
      42            7 :                 is_foreign_scenario = false;
      43            7 :                 break;
      44              :             }
      45              :         }
      46              : 
      47              :         /* evaluate filter */
      48           10 :         const bool ok_by_diagram = data_rules_diagram_shows_scenario_features ( this_, diagram_type );
      49           10 :         const bool ok_by_scenario = ! is_foreign_scenario;
      50           10 :         result = ok_by_diagram && ok_by_scenario;
      51              :     }
      52              :     else
      53              :     {
      54              :         /* evaluate diagram filter */
      55          305 :         result = data_rules_diagram_shows_uncond_features ( this_, diagram_type );
      56              :     }
      57              : 
      58          315 :     U8_TRACE_END();
      59          315 :     return result;
      60              : }
      61              : 
      62          444 : bool data_rules_diagram_shows_relationship ( const data_rules_t *this_, const data_visible_set_t *diagram_set, data_row_t relationship_id )
      63              : {
      64          444 :     U8_TRACE_BEGIN();
      65          444 :     assert( NULL != diagram_set );
      66          444 :     bool result = false;
      67              : 
      68              :     /* search objects */
      69          444 :     const data_diagram_t *diag_ptr = data_visible_set_get_diagram_const( diagram_set );
      70          444 :     assert( diag_ptr != NULL );
      71          444 :     assert( data_diagram_is_valid( diag_ptr ) );
      72          444 :     const data_diagram_type_t diagram_type = data_diagram_get_diagram_type ( diag_ptr );
      73              : 
      74          444 :     const data_relationship_t *relation_ptr = data_visible_set_get_relationship_by_id_const ( diagram_set, relationship_id );  /* SEARCH */
      75          444 :     assert( relation_ptr != NULL );
      76          444 :     assert( data_relationship_is_valid( relation_ptr ) );
      77          444 :     const data_row_t from_classifier_id = data_relationship_get_from_classifier_row( relation_ptr );
      78          444 :     const data_row_t from_feat_id = data_relationship_get_from_feature_row( relation_ptr );
      79          444 :     const data_row_t to_classifier_id = data_relationship_get_to_classifier_row( relation_ptr );
      80          444 :     const data_row_t to_feat_id = data_relationship_get_to_feature_row( relation_ptr );
      81              : 
      82          444 :     const data_classifier_t *from_classifier_or_null = data_visible_set_get_classifier_by_id_const( diagram_set, from_classifier_id );  /* SEARCH */
      83          444 :     const data_classifier_t *to_classifier_or_null = data_visible_set_get_classifier_by_id_const( diagram_set, to_classifier_id );  /* SEARCH */
      84          444 :     if (( from_classifier_or_null != NULL )&&( to_classifier_or_null != NULL ))
      85          431 :     {
      86          431 :         const data_feature_t *from_feat_or_null = data_visible_set_get_feature_by_id_const( diagram_set, from_feat_id );  /* SEARCH */
      87          431 :         const data_feature_t *to_feat_or_null = data_visible_set_get_feature_by_id_const( diagram_set, to_feat_id );  /* SEARCH */
      88          416 :         const data_feature_type_t from_feature_type = (NULL==from_feat_or_null)
      89              :                                                       ? DATA_FEATURE_TYPE_VOID
      90          431 :                                                       : data_feature_get_main_type( from_feat_or_null );
      91          415 :         const data_feature_type_t to_feature_type = (NULL==to_feat_or_null)
      92              :                                                     ? DATA_FEATURE_TYPE_VOID
      93          431 :                                                     : data_feature_get_main_type( to_feat_or_null );
      94          431 :         const bool is_rel_scenario = data_rules_relationship_is_scenario_cond( this_, from_feature_type, to_feature_type);
      95              : 
      96          431 :         if ( is_rel_scenario )
      97              :         {
      98              :             /* a scenario-typed feature that belongs to a different diagram is always filtered */
      99           12 :             bool is_from_foreign_scenario = (NULL!=from_feat_or_null);
     100           12 :             bool is_to_foreign_scenario = (NULL!=to_feat_or_null);
     101           12 :             const uint32_t vc_count = data_visible_set_get_visible_classifier_count ( diagram_set );
     102         1548 :             for ( uint32_t vc_idx = 0; vc_idx < vc_count; vc_idx ++ )  /* SEARCH */
     103              :             {
     104         1536 :                 const data_visible_classifier_t *vc_probe = data_visible_set_get_visible_classifier_const ( diagram_set, vc_idx );
     105         1536 :                 assert ( NULL != vc_probe );
     106         1536 :                 const data_diagramelement_t *diag_ele = data_visible_classifier_get_diagramelement_const ( vc_probe );
     107         1536 :                 assert ( NULL != diag_ele );
     108         1536 :                 const data_row_t diag_ele_feat_id = data_diagramelement_get_focused_feature_row( diag_ele );
     109         1536 :                 if ( from_feat_id == diag_ele_feat_id )
     110              :                 {
     111          440 :                     is_from_foreign_scenario = false;
     112              :                 }
     113         1536 :                 if ( to_feat_id == diag_ele_feat_id )
     114              :                 {
     115          440 :                     is_to_foreign_scenario = false;
     116              :                 }
     117              :             }
     118              : 
     119              :             /* evaluate filter */
     120           12 :             const bool ok_by_diagram = data_rules_diagram_shows_scenario_relationships ( this_, diagram_type );
     121           12 :             const bool ok_by_scenario = ( ! is_from_foreign_scenario )&&( ! is_to_foreign_scenario );
     122           12 :             result = ok_by_diagram && ok_by_scenario;
     123              :         }
     124              :         else
     125              :         {
     126              :             /* evaluate filter */
     127          419 :             const bool ok_by_diagram = data_rules_diagram_shows_uncond_relationships ( this_, diagram_type );
     128          419 :             result = ok_by_diagram;
     129              :         }
     130              :     }
     131              :     else
     132              :     {
     133           13 :         if (( from_classifier_or_null == NULL )&&( to_classifier_or_null == NULL ))
     134              :         {
     135              :             /* maybe the data_visible_set_t was full and the classifier could not be stored? */
     136           10 :             U8_LOG_ANOMALY_INT( "data_visible_set_t contains a relationship but no related classifier.", relationship_id );
     137              :         }
     138              :         else
     139              :         {
     140              :             /* it is normal behavior that only one end of the relation is contained in the data_visible_set_t */
     141              :         }
     142              :     }
     143              : 
     144          444 :     U8_TRACE_END();
     145          444 :     return result;
     146              : }
     147              : 
     148              : 
     149              : /*
     150              : Copyright 2019-2026 Andreas Warnke
     151              : 
     152              : Licensed under the Apache License, Version 2.0 (the "License");
     153              : you may not use this file except in compliance with the License.
     154              : You may obtain a copy of the License at
     155              : 
     156              :     http://www.apache.org/licenses/LICENSE-2.0
     157              : 
     158              : Unless required by applicable law or agreed to in writing, software
     159              : distributed under the License is distributed on an "AS IS" BASIS,
     160              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     161              : See the License for the specific language governing permissions and
     162              : limitations under the License.
     163              : */
        

Generated by: LCOV version 2.0-1