LCOV - code coverage report
Current view: top level - data/source/set - data_profile_part.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 100.0 % 51 51
Test Date: 2025-05-01 10:10:14 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /* File: data_profile_part.c; Copyright and License: see below */
       2              : 
       3              : #include "set/data_profile_part.h"
       4              : #include "u8/u8_trace.h"
       5              : #include <stdio.h>
       6              : #include <stdlib.h>
       7              : #include <assert.h>
       8              : 
       9            9 : void data_profile_part_init( data_profile_part_t *this_ )
      10              : {
      11            9 :     U8_TRACE_BEGIN();
      12            9 :     U8_TRACE_INFO_INT( "sizeof(data_profile_part_t):", sizeof(data_profile_part_t) );
      13              : 
      14            9 :     (*this_).stereotype_count = 0;
      15              : 
      16            9 :     U8_TRACE_END();
      17            9 : }
      18              : 
      19            3 : void data_profile_part_reinit( data_profile_part_t *this_ )
      20              : {
      21            3 :     U8_TRACE_BEGIN();
      22              : 
      23            3 :     data_profile_part_destroy( this_ );
      24            3 :     data_profile_part_init( this_ );
      25              : 
      26            3 :     U8_TRACE_END();
      27            3 : }
      28              : 
      29            9 : void data_profile_part_destroy( data_profile_part_t *this_ )
      30              : {
      31            9 :     U8_TRACE_BEGIN();
      32            9 :     assert( (*this_).stereotype_count <= DATA_PROFILE_PART_MAX_STEREOTYPES );
      33              : 
      34           58 :     for ( int index = 0; index < (*this_).stereotype_count; index ++ )
      35              :     {
      36           49 :         data_classifier_destroy ( &((*this_).stereotypes[index]) );
      37              :     }
      38            9 :     (*this_).stereotype_count = 0;
      39              : 
      40            9 :     U8_TRACE_END();
      41            9 : }
      42              : 
      43            3 : u8_error_t data_profile_part_load( data_profile_part_t *this_,
      44              :                                    const data_visible_set_t *diagram_elements,
      45              :                                    data_database_reader_t *db_reader )
      46              : {
      47            3 :     U8_TRACE_BEGIN();
      48            3 :     assert( NULL != db_reader );
      49            3 :     assert( NULL != diagram_elements );
      50            3 :     u8_error_t result = U8_ERROR_NONE;
      51              : 
      52              :     /* re-init */
      53            3 :     data_profile_part_reinit( this_ );
      54              : 
      55              : 
      56              :     /* load stereotype of diagram */
      57            3 :     const data_diagram_t *const diag = data_visible_set_get_diagram_const( diagram_elements );
      58            3 :     if ( data_diagram_has_stereotype( diag ) )
      59              :     {
      60            3 :         const char *const diag_stereotype = data_diagram_get_stereotype_const( diag );
      61            3 :         result |= data_profile_part_private_load_stereotype( this_, diag_stereotype, db_reader );
      62              :     }
      63              : 
      64              :     /* load stereotypes of classifiers */
      65            3 :     const uint32_t clsfy_count = data_visible_set_get_visible_classifier_count( diagram_elements );
      66           56 :     for ( uint32_t clsfy_index = 0; ( clsfy_index < clsfy_count )&&( result == U8_ERROR_NONE ); clsfy_index ++ )
      67              :     {
      68           53 :         const data_visible_classifier_t *const vis_clsfy = data_visible_set_get_visible_classifier_const( diagram_elements, clsfy_index );
      69           53 :         const data_classifier_t *const clsfy = data_visible_classifier_get_classifier_const( vis_clsfy );
      70           53 :         if ( data_classifier_has_stereotype( clsfy ) )
      71              :         {
      72           53 :             const char *const clsfy_stereotype = data_classifier_get_stereotype_const( clsfy );
      73           53 :             result |= data_profile_part_private_load_stereotype( this_, clsfy_stereotype, db_reader );
      74              :         }
      75              :     }
      76              : 
      77              :     /* load stereotypes of relationships */
      78            3 :     const uint32_t rel_count = data_visible_set_get_relationship_count( diagram_elements );
      79            4 :     for ( uint32_t rel_index = 0; ( rel_index < rel_count )&&( result == U8_ERROR_NONE ); rel_index ++ )
      80              :     {
      81            1 :         const data_relationship_t *const rel = data_visible_set_get_relationship_const( diagram_elements, rel_index );
      82            1 :         if ( data_relationship_has_stereotype( rel ) )
      83              :         {
      84            1 :             const char *const rel_stereotype = data_relationship_get_stereotype_const( rel );
      85            1 :             result |= data_profile_part_private_load_stereotype( this_, rel_stereotype, db_reader );
      86              :         }
      87              :     }
      88              : 
      89              :     /* load stereotypes of features (from the value field) */
      90            3 :     const uint32_t feat_count = data_visible_set_get_feature_count( diagram_elements );
      91            4 :     for ( uint32_t feat_index = 0; ( feat_index < feat_count )&&( result == U8_ERROR_NONE ); feat_index ++ )
      92              :     {
      93            1 :         const data_feature_t *const feat = data_visible_set_get_feature_const( diagram_elements, feat_index );
      94            1 :         if ( data_feature_has_value( feat ) )
      95              :         {
      96            1 :             const char *const feat_stereotype = data_feature_get_value_const( feat );
      97            1 :             result |= data_profile_part_private_load_stereotype( this_, feat_stereotype, db_reader );
      98              :         }
      99              :     }
     100              : 
     101            3 :     U8_TRACE_END_ERR(result);
     102            3 :     return result;
     103              : }
     104              : 
     105              : 
     106              : /*
     107              : Copyright 2023-2025 Andreas Warnke
     108              : 
     109              : Licensed under the Apache License, Version 2.0 (the "License");
     110              : you may not use this file except in compliance with the License.
     111              : You may obtain a copy of the License at
     112              : 
     113              :     http://www.apache.org/licenses/LICENSE-2.0
     114              : 
     115              : Unless required by applicable law or agreed to in writing, software
     116              : distributed under the License is distributed on an "AS IS" BASIS,
     117              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     118              : See the License for the specific language governing permissions and
     119              : limitations under the License.
     120              : */
        

Generated by: LCOV version 2.0-1