LCOV - code coverage report
Current view: top level - data/include - data_rules.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 68 86 79.1 %
Date: 2024-10-26 21:44:38 Functions: 11 13 84.6 %

          Line data    Source code
       1             : /* File: data_rules.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_trace.h"
       4             : #include "u8/u8_log.h"
       5             : #include <assert.h>
       6             : 
       7          88 : static inline void data_rules_init ( data_rules_t *this_ )
       8             : {
       9          88 :     (*this_).dummy = 0;  /* prevent warnings on uninitialized usage */
      10          88 : }
      11             : 
      12          88 : static inline void data_rules_destroy ( data_rules_t *this_ )
      13             : {
      14          88 : }
      15             : 
      16             : /* ================================ DIAGRAM ================================ */
      17             : 
      18          42 : static inline bool data_rules_diagram_is_scenario ( const data_rules_t *this_, data_diagram_type_t diagram_type )
      19             : {
      20             :     bool result;
      21          42 :     result = (( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
      22          20 :              || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
      23          20 :              || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
      24          62 :              || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
      25          42 :     return result;
      26             : }
      27             : 
      28             : /* ================================ CLASSIFIER ================================ */
      29             : 
      30             : /* ================================ FEATURE ================================ */
      31             : 
      32       33534 : static inline bool data_rules_classifier_has_uncond_features ( const data_rules_t *this_, data_classifier_type_t classifier_type )
      33             : {
      34             :     bool result;
      35             : 
      36       33534 :     switch ( classifier_type )
      37             :     {
      38       33531 :         case DATA_CLASSIFIER_TYPE_BLOCK:
      39             :         case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK:
      40             :         case DATA_CLASSIFIER_TYPE_REQUIREMENT: /* for requirements, there is a predefined set of: id, text, ... */
      41             :         case DATA_CLASSIFIER_TYPE_INTERFACE:
      42             :         case DATA_CLASSIFIER_TYPE_CLASS:
      43             :         case DATA_CLASSIFIER_TYPE_OBJECT:
      44             :         case DATA_CLASSIFIER_TYPE_USE_CASE:
      45             :         case DATA_CLASSIFIER_TYPE_NODE:
      46             :         case DATA_CLASSIFIER_TYPE_SUBSYSTEM:
      47             :         case DATA_CLASSIFIER_TYPE_COMPONENT:
      48             :         case DATA_CLASSIFIER_TYPE_PART:
      49             :         case DATA_CLASSIFIER_TYPE_PACKAGE:
      50             :         case DATA_CLASSIFIER_TYPE_ARTIFACT:
      51             :         case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION:
      52             :         case DATA_CLASSIFIER_TYPE_ACTIVITY:
      53             :         case DATA_CLASSIFIER_TYPE_STATE:
      54             :         case DATA_CLASSIFIER_TYPE_STEREOTYPE:
      55             :         {
      56       33531 :             result = true;
      57             :         }
      58       33531 :         break;
      59             : 
      60           3 :         case DATA_CLASSIFIER_TYPE_ACTOR:
      61             :         case DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE:
      62             :         case DATA_CLASSIFIER_TYPE_COMMENT:
      63             :         case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE:
      64             :         case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE:
      65             :         case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE:
      66             :         case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE:
      67             :         case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE:
      68             :         case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY:
      69             :         case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY:
      70             :         case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT :
      71             :         case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT:
      72             :         case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL:
      73             :         case DATA_CLASSIFIER_TYPE_IMAGE:
      74             :         {
      75           3 :             result = false;
      76             :         }
      77           3 :         break;
      78             : 
      79           0 :         default:
      80             :         {
      81           0 :             U8_LOG_ANOMALY("data_classifier_type_t out of range in data_rules_has_features");
      82           0 :             result = true;
      83             :             /* this case can happen if a model file of a new cfu version is opened with an older version of cfu */
      84             :         }
      85           0 :         break;
      86             :     }
      87             : 
      88       33534 :     return result;
      89             : }
      90             : 
      91       33560 : static inline bool data_rules_feature_is_scenario_cond ( const data_rules_t *this_, data_feature_type_t feature_type )
      92             : {
      93             :     bool result;
      94       33560 :     result = ( feature_type == DATA_FEATURE_TYPE_LIFELINE );
      95       33560 :     return result;
      96             : }
      97             : 
      98         296 : static inline bool data_rules_diagram_shows_uncond_features ( const data_rules_t *this_, data_diagram_type_t diagram_type )
      99             : {
     100             :     bool hide;
     101         296 :     hide = (( diagram_type == DATA_DIAGRAM_TYPE_LIST )
     102         296 :            || ( diagram_type == DATA_DIAGRAM_TYPE_BOX_DIAGRAM )
     103         294 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     104         292 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     105         292 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     106         592 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     107         296 :     return ( ! hide );
     108             : }
     109             : 
     110           9 : static inline bool data_rules_diagram_shows_scenario_features ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     111             : {
     112             :     bool show;
     113           9 :     show = (( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     114           6 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     115           6 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     116          15 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     117           9 :     return show;
     118             : }
     119             : 
     120       33238 : static inline bool data_rules_vis_classifier_has_feature ( const data_rules_t *this_,
     121             :                                                            const data_visible_classifier_t *vis_classifier,
     122             :                                                            const data_feature_t *feature )
     123             : {
     124       33238 :     assert( vis_classifier != NULL );
     125       33238 :     assert( feature != NULL );
     126       33238 :     const bool valid = data_visible_classifier_is_valid ( vis_classifier ) && data_feature_is_valid ( feature );
     127       33238 :     const data_classifier_t *clasfy = data_visible_classifier_get_classifier_const ( vis_classifier );
     128       33238 :     const data_diagramelement_t *diagele = data_visible_classifier_get_diagramelement_const ( vis_classifier );
     129       33238 :     assert( clasfy != NULL );
     130       33238 :     assert( diagele != NULL );
     131       33238 :     const bool belongs = ( data_feature_get_classifier_row_id( feature ) == data_classifier_get_row_id( clasfy ) );
     132       33238 :     const bool scenario = data_rules_feature_is_scenario_cond( this_, data_feature_get_main_type( feature ) );
     133       33238 :     const bool focused = ( data_diagramelement_get_focused_feature_row_id( diagele ) == data_feature_get_row_id( feature ) );
     134       33238 :     const bool visible = data_rules_classifier_has_uncond_features( this_, data_classifier_get_main_type( clasfy ) );
     135       33238 :     return valid && belongs && (((!scenario)&&visible) || (scenario&&focused));
     136             : }
     137             : 
     138           0 : static inline bool data_rules_classifier_has_scenario_semantics ( const data_rules_t *this_,
     139             :                                                                   data_diagram_type_t diagram_type,
     140             :                                                                   data_classifier_type_t classifier_type )
     141             : {
     142           0 :     const bool lifeline_has_no_semantics
     143             :         = ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     144           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_COMMENT )
     145           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_IMAGE )
     146           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_STEREOTYPE )
     147           0 :         || (( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     148           0 :         && (( classifier_type == DATA_CLASSIFIER_TYPE_INTERACTION )
     149           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE )));
     150           0 :     return ( ! lifeline_has_no_semantics);
     151             : }
     152             : 
     153           0 : static inline bool data_rules_feature_value_is_stereotype ( const data_rules_t *this_, data_feature_type_t feature_type )
     154             : {
     155             :     bool has_value;
     156           0 :     has_value = (( feature_type == DATA_FEATURE_TYPE_PROPERTY )
     157           0 :            || ( feature_type == DATA_FEATURE_TYPE_OPERATION )
     158           0 :            || ( feature_type == DATA_FEATURE_TYPE_TAGGED_VALUE ));
     159           0 :     return ( ! has_value );
     160             : }
     161             : 
     162             : /* ================================ RELATIONSHIP ================================ */
     163             : 
     164        1074 : static inline bool data_rules_relationship_is_scenario_cond ( const data_rules_t *this_,
     165             :                                                               data_feature_type_t from_feature_type,
     166             :                                                               data_feature_type_t to_feature_type
     167             :                                                             )
     168             : {
     169             :     bool result;
     170        1074 :     result = ( from_feature_type == DATA_FEATURE_TYPE_LIFELINE )
     171        1074 :              || ( to_feature_type == DATA_FEATURE_TYPE_LIFELINE );
     172        1074 :     return result;
     173             : }
     174             : 
     175        1059 : static inline bool data_rules_diagram_shows_uncond_relationships ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     176             : {
     177             :     bool hide;
     178        1059 :     hide = (( diagram_type == DATA_DIAGRAM_TYPE_LIST )
     179        1059 :            || ( diagram_type == DATA_DIAGRAM_TYPE_BOX_DIAGRAM )
     180        1055 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     181        1051 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     182        1051 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     183        2118 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     184        1059 :     return ( ! hide );
     185             : }
     186             : 
     187          12 : static inline bool data_rules_diagram_shows_scenario_relationships ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     188             : {
     189             :     bool show;
     190          12 :     show = (( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     191           9 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     192           9 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     193          21 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     194          12 :     return show;
     195             : }
     196             : 
     197             : /*
     198             : static inline bool data_rules_is_relationship_compliant ( const data_rules_t *this_,
     199             :                                                           data_relationship_type_t relation_type,
     200             :                                                           data_classifier_type_t from_c_type,
     201             :                                                           data_feature_type_t from_f_type,
     202             :                                                           data_classifier_type_t to_c_type,
     203             :                                                           data_feature_type_t to_f_type )
     204             : {
     205             :     bool comply;
     206             :     comply = true;
     207             :     TODO
     208             :     return comply;
     209             : }
     210             : */
     211             : 
     212             : 
     213             : /*
     214             : Copyright 2017-2024 Andreas Warnke
     215             : 
     216             : Licensed under the Apache License, Version 2.0 (the "License");
     217             : you may not use this file except in compliance with the License.
     218             : You may obtain a copy of the License at
     219             : 
     220             :     http://www.apache.org/licenses/LICENSE-2.0
     221             : 
     222             : Unless required by applicable law or agreed to in writing, software
     223             : distributed under the License is distributed on an "AS IS" BASIS,
     224             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     225             : See the License for the specific language governing permissions and
     226             : limitations under the License.
     227             : */

Generated by: LCOV version 1.16