LCOV - code coverage report
Current view: top level - data/include/entity - data_relationship.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 100.0 % 210 210
Test Date: 2025-05-01 10:10:14 Functions: 100.0 % 38 38

            Line data    Source code
       1              : /* File: data_relationship.inl; Copyright and License: see below */
       2              : 
       3              : #include "entity/data_id.h"
       4              : #include <assert.h>
       5              : 
       6           55 : static inline void data_relationship_init_empty ( data_relationship_t *this_ )
       7              : {
       8           55 :     (*this_).id = DATA_ROW_VOID;
       9           55 :     (*this_).from_classifier_id = DATA_ROW_VOID;
      10           55 :     (*this_).from_feature_id = DATA_ROW_VOID;
      11           55 :     (*this_).to_classifier_id = DATA_ROW_VOID;
      12           55 :     (*this_).to_feature_id = DATA_ROW_VOID;
      13           55 :     (*this_).main_type = DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY;
      14              : 
      15           55 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      16           55 :     utf8stringbuf_clear( &((*this_).stereotype) );
      17           55 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      18           55 :     utf8stringbuf_clear( &((*this_).name) );
      19           55 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      20           55 :     utf8stringbuf_clear( &((*this_).description) );
      21              : 
      22           55 :     (*this_).list_order = 0;
      23           55 :     data_uuid_init_new( &((*this_).uuid) );
      24           55 : }
      25              : 
      26            1 : static inline void data_relationship_reinit_empty ( data_relationship_t *this_ )
      27              : {
      28              :     /* data_relationship_destroy( this_ );  -- not necessary */
      29            1 :     data_relationship_init_empty( this_ );
      30            1 : }
      31              : 
      32            2 : static inline u8_error_t data_relationship_init_new ( data_relationship_t *this_,
      33              :                                                       data_row_t from_classifier_id,
      34              :                                                       data_row_t from_feature_id,
      35              :                                                       data_row_t to_classifier_id,
      36              :                                                       data_row_t to_feature_id,
      37              :                                                       data_relationship_type_t relationship_main_type,
      38              :                                                       const char* stereotype,
      39              :                                                       const char* name,
      40              :                                                       const char* description,
      41              :                                                       int32_t list_order)
      42              : {
      43            2 :     assert( NULL != stereotype );
      44            2 :     assert( NULL != name );
      45            2 :     assert( NULL != description );
      46              :     utf8error_t strerr;
      47            2 :     u8_error_t result = U8_ERROR_NONE;
      48              : 
      49            2 :     (*this_).id = DATA_ROW_VOID;
      50            2 :     (*this_).from_classifier_id = from_classifier_id;
      51            2 :     (*this_).from_feature_id = from_feature_id;
      52            2 :     (*this_).to_classifier_id = to_classifier_id;
      53            2 :     (*this_).to_feature_id = to_feature_id;
      54            2 :     (*this_).main_type = relationship_main_type;
      55              : 
      56            2 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
      57            2 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
      58            2 :     if ( strerr != UTF8ERROR_SUCCESS )
      59              :     {
      60            1 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      61            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      62              :     }
      63              : 
      64            2 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
      65            2 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
      66            2 :     if ( strerr != UTF8ERROR_SUCCESS )
      67              :     {
      68            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      69            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      70              :     }
      71              : 
      72            2 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
      73            2 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
      74            2 :     if ( strerr != UTF8ERROR_SUCCESS )
      75              :     {
      76            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      77            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      78              :     }
      79              : 
      80            2 :     (*this_).list_order = list_order;
      81            2 :     data_uuid_init_new( &((*this_).uuid) );
      82              : 
      83            2 :     return result;
      84              : }
      85              : 
      86         3187 : static inline u8_error_t data_relationship_init ( data_relationship_t *this_,
      87              :                                                   data_row_t relationship_id,
      88              :                                                   data_row_t from_classifier_id,
      89              :                                                   data_row_t from_feature_id,
      90              :                                                   data_row_t to_classifier_id,
      91              :                                                   data_row_t to_feature_id,
      92              :                                                   data_relationship_type_t relationship_main_type,
      93              :                                                   const char* stereotype,
      94              :                                                   const char* name,
      95              :                                                   const char* description,
      96              :                                                   int32_t list_order,
      97              :                                                   const char* uuid )
      98              : {
      99         3187 :     assert( NULL != stereotype );
     100         3187 :     assert( NULL != name );
     101         3187 :     assert( NULL != description );
     102         3187 :     assert( NULL != uuid );
     103              :     utf8error_t strerr;
     104         3187 :     u8_error_t result = U8_ERROR_NONE;
     105              : 
     106         3187 :     (*this_).id = relationship_id;
     107         3187 :     (*this_).from_classifier_id = from_classifier_id;
     108         3187 :     (*this_).from_feature_id = from_feature_id;
     109         3187 :     (*this_).to_classifier_id = to_classifier_id;
     110         3187 :     (*this_).to_feature_id = to_feature_id;
     111         3187 :     (*this_).main_type = relationship_main_type;
     112              : 
     113         3187 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     114         3187 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     115         3187 :     if ( strerr != UTF8ERROR_SUCCESS )
     116              :     {
     117            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     118            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     119              :     }
     120              : 
     121         3187 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     122         3187 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     123         3187 :     if ( strerr != UTF8ERROR_SUCCESS )
     124              :     {
     125            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     126            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     127              :     }
     128              : 
     129         3187 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     130         3187 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     131         3187 :     if ( strerr != UTF8ERROR_SUCCESS )
     132              :     {
     133            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     134            1 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     135              :     }
     136              : 
     137         3187 :     (*this_).list_order = list_order;
     138         3187 :     result |= data_uuid_init( &((*this_).uuid), uuid );
     139              : 
     140         3187 :     return result;
     141              : }
     142              : 
     143          413 : static inline void data_relationship_copy ( data_relationship_t *this_, const data_relationship_t *original )
     144              : {
     145          413 :     assert( NULL != original );
     146              : 
     147          413 :     (*this_) = (*original);
     148              :     /* repair the overwritten pointers */
     149          413 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     150          413 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     151          413 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     152          413 :     data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
     153          413 : }
     154              : 
     155           31 : static inline void data_relationship_replace ( data_relationship_t *this_, const data_relationship_t *that )
     156              : {
     157           31 :     assert( NULL != that );
     158              : 
     159           31 :     (*this_) = (*that);
     160              :     /* repair the overwritten pointers */
     161           31 :     (*this_).stereotype = utf8stringbuf_new( (*this_).private_stereotype_buffer, sizeof((*this_).private_stereotype_buffer) );
     162           31 :     (*this_).name = utf8stringbuf_new( (*this_).private_name_buffer, sizeof((*this_).private_name_buffer) );
     163           31 :     (*this_).description = utf8stringbuf_new( (*this_).private_description_buffer, sizeof((*this_).private_description_buffer) );
     164           31 :     data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
     165           31 : }
     166              : 
     167         1236 : static inline void data_relationship_destroy ( data_relationship_t *this_ )
     168              : {
     169         1236 :     (*this_).id = DATA_ROW_VOID;
     170         1236 :     data_uuid_destroy( &((*this_).uuid) );
     171         1236 : }
     172              : 
     173        75984 : static inline data_row_t data_relationship_get_row_id ( const data_relationship_t *this_ )
     174              : {
     175        75984 :     return (*this_).id;
     176              : }
     177              : 
     178           43 : static inline void data_relationship_set_row_id ( data_relationship_t *this_, data_row_t id )
     179              : {
     180           43 :     (*this_).id = id;
     181           43 : }
     182              : 
     183            6 : static inline data_id_t data_relationship_get_data_id ( const data_relationship_t *this_ )
     184              : {
     185              :     data_id_t result;
     186            6 :     data_id_init ( &result, DATA_TABLE_RELATIONSHIP, (*this_).id );
     187            6 :     return result;
     188              : }
     189              : 
     190         3829 : static inline data_row_t data_relationship_get_from_classifier_row_id ( const data_relationship_t *this_ )
     191              : {
     192         3829 :     return (*this_).from_classifier_id;
     193              : }
     194              : 
     195           22 : static inline void data_relationship_set_from_classifier_row_id ( data_relationship_t *this_, data_row_t from_classifier_id )
     196              : {
     197           22 :     (*this_).from_classifier_id = from_classifier_id;
     198           22 : }
     199              : 
     200            1 : static inline data_id_t data_relationship_get_from_classifier_data_id ( const data_relationship_t *this_ )
     201              : {
     202              :     data_id_t result;
     203            1 :     data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).from_classifier_id );
     204            1 :     return result;
     205              : }
     206              : 
     207         3424 : static inline data_row_t data_relationship_get_from_feature_row_id ( const data_relationship_t *this_ )
     208              : {
     209         3424 :     return (*this_).from_feature_id;
     210              : }
     211              : 
     212          429 : static inline void data_relationship_set_from_feature_row_id ( data_relationship_t *this_, data_row_t from_feature_id )
     213              : {
     214          429 :     (*this_).from_feature_id = from_feature_id;
     215          429 : }
     216              : 
     217            1 : static inline data_id_t data_relationship_get_from_feature_data_id ( const data_relationship_t *this_ )
     218              : {
     219              :     data_id_t result;
     220            1 :     data_id_init ( &result, DATA_TABLE_FEATURE, (*this_).from_feature_id );
     221            1 :     return result;
     222              : }
     223              : 
     224         3394 : static inline data_row_t data_relationship_get_to_classifier_row_id ( const data_relationship_t *this_ )
     225              : {
     226         3394 :     return (*this_).to_classifier_id;
     227              : }
     228              : 
     229           22 : static inline void data_relationship_set_to_classifier_row_id ( data_relationship_t *this_, data_row_t to_classifier_id )
     230              : {
     231           22 :     (*this_).to_classifier_id = to_classifier_id;
     232           22 : }
     233              : 
     234            1 : static inline data_id_t data_relationship_get_to_classifier_data_id ( const data_relationship_t *this_ )
     235              : {
     236              :     data_id_t result;
     237            1 :     data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).to_classifier_id );
     238            1 :     return result;
     239              : }
     240              : 
     241         3427 : static inline data_row_t data_relationship_get_to_feature_row_id ( const data_relationship_t *this_ )
     242              : {
     243         3427 :     return (*this_).to_feature_id;
     244              : }
     245              : 
     246          420 : static inline void data_relationship_set_to_feature_row_id ( data_relationship_t *this_, data_row_t to_feature_id )
     247              : {
     248          420 :     (*this_).to_feature_id = to_feature_id;
     249          420 : }
     250              : 
     251            1 : static inline data_id_t data_relationship_get_to_feature_data_id ( const data_relationship_t *this_ )
     252              : {
     253              :     data_id_t result;
     254            1 :     data_id_init ( &result, DATA_TABLE_FEATURE, (*this_).to_feature_id );
     255            1 :     return result;
     256              : }
     257              : 
     258         3178 : static inline data_relationship_type_t data_relationship_get_main_type ( const data_relationship_t *this_ )
     259              : {
     260         3178 :     return (*this_).main_type;
     261              : }
     262              : 
     263           15 : static inline void data_relationship_set_main_type ( data_relationship_t *this_, data_relationship_type_t main_type )
     264              : {
     265           15 :     (*this_).main_type = main_type;
     266           15 : }
     267              : 
     268          451 : static inline const char *data_relationship_get_stereotype_const ( const data_relationship_t *this_ )
     269              : {
     270          451 :     return utf8stringbuf_get_string( &((*this_).stereotype) );
     271              : }
     272              : 
     273            3 : static inline bool data_relationship_has_stereotype ( const data_relationship_t *this_ )
     274              : {
     275            3 :     return ( ! utf8stringbuf_equals_str( &((*this_).stereotype), "" ) );
     276              : }
     277              : 
     278            3 : static inline u8_error_t data_relationship_set_stereotype ( data_relationship_t *this_, const char *stereotype )
     279              : {
     280            3 :     assert( NULL != stereotype );
     281              : 
     282            3 :     u8_error_t result = U8_ERROR_NONE;
     283              :     utf8error_t strerr;
     284            3 :     strerr = utf8stringbuf_copy_str( &((*this_).stereotype), stereotype );
     285            3 :     if ( strerr != UTF8ERROR_SUCCESS )
     286              :     {
     287            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     288            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     289              :     }
     290            3 :     return result;
     291              : }
     292              : 
     293          450 : static inline const char *data_relationship_get_name_const ( const data_relationship_t *this_ )
     294              : {
     295          450 :     return utf8stringbuf_get_string( &((*this_).name) );
     296              : }
     297              : 
     298           16 : static inline u8_error_t data_relationship_set_name ( data_relationship_t *this_, const char *name )
     299              : {
     300           16 :     assert( NULL != name );
     301           16 :     u8_error_t result = U8_ERROR_NONE;
     302              :     utf8error_t strerr;
     303           16 :     strerr = utf8stringbuf_copy_str( &((*this_).name), name );
     304           16 :     if ( strerr != UTF8ERROR_SUCCESS )
     305              :     {
     306            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     307            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     308              :     }
     309           16 :     return result;
     310              : }
     311              : 
     312          453 : static inline const char *data_relationship_get_description_const ( const data_relationship_t *this_ )
     313              : {
     314          453 :     return utf8stringbuf_get_string( &((*this_).description) );
     315              : }
     316              : 
     317           17 : static inline u8_error_t data_relationship_set_description ( data_relationship_t *this_, const char *description )
     318              : {
     319           17 :     assert( NULL != description );
     320           17 :     u8_error_t result = U8_ERROR_NONE;
     321              :     utf8error_t strerr;
     322           17 :     strerr = utf8stringbuf_copy_str( &((*this_).description), description );
     323           17 :     if ( strerr != UTF8ERROR_SUCCESS )
     324              :     {
     325            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     326            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     327              :     }
     328           17 :     return result;
     329              : }
     330              : 
     331            2 : static inline u8_error_t data_relationship_append_description ( data_relationship_t *this_, const char *description )
     332              : {
     333            2 :     assert( NULL != description );
     334            2 :     u8_error_t result = U8_ERROR_NONE;
     335              :     utf8error_t strerr;
     336            2 :     strerr = utf8stringbuf_append_str( &((*this_).description), description );
     337            2 :     if ( strerr != UTF8ERROR_SUCCESS )
     338              :     {
     339            1 :         U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
     340            1 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     341              :     }
     342            2 :     return result;
     343              : }
     344              : 
     345          448 : static inline int32_t data_relationship_get_list_order ( const data_relationship_t *this_ )
     346              : {
     347          448 :     return (*this_).list_order;
     348              : }
     349              : 
     350           15 : static inline void data_relationship_set_list_order ( data_relationship_t *this_, int32_t list_order )
     351              : {
     352           15 :     (*this_).list_order = list_order;
     353           15 : }
     354              : 
     355          461 : static inline const char *data_relationship_get_uuid_const ( const data_relationship_t *this_ )
     356              : {
     357          461 :     return data_uuid_get_string( &((*this_).uuid) );
     358              : }
     359              : 
     360           11 : static inline u8_error_t data_relationship_set_uuid ( data_relationship_t *this_, const char *uuid )
     361              : {
     362           11 :     assert( NULL != uuid );
     363              : 
     364           11 :     const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
     365              : 
     366           11 :     return result;
     367              : }
     368              : 
     369         4539 : static inline bool data_relationship_is_valid ( const data_relationship_t *this_ )
     370              : {
     371         4539 :     return ( DATA_ROW_VOID != (*this_).id );
     372              : }
     373              : 
     374          435 : static inline void data_relationship_trace ( const data_relationship_t *this_ )
     375              : {
     376          435 :     U8_TRACE_INFO( "data_relationship_t" );
     377          435 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     378          435 :     U8_TRACE_INFO_INT( "- from_classifier_id:", (*this_).from_classifier_id );
     379          435 :     U8_TRACE_INFO_INT( "- from_feature_id:", (*this_).from_feature_id );
     380          435 :     U8_TRACE_INFO_INT( "- to_classifier_id:", (*this_).to_classifier_id );
     381          435 :     U8_TRACE_INFO_INT( "- to_feature_id:", (*this_).to_feature_id );
     382          435 :     U8_TRACE_INFO_INT( "- main_type:", (*this_).main_type );
     383          435 :     U8_TRACE_INFO_STR( "- stereotype:", utf8stringbuf_get_string( &((*this_).stereotype)) );
     384          435 :     U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string( &((*this_).name)) );
     385          435 :     U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string( &((*this_).description)) );
     386          435 :     U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
     387          435 :     U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
     388          435 : }
     389              : 
     390              : 
     391              : /*
     392              : Copyright 2016-2025 Andreas Warnke
     393              : 
     394              : Licensed under the Apache License, Version 2.0 (the "License");
     395              : you may not use this file except in compliance with the License.
     396              : You may obtain a copy of the License at
     397              : 
     398              :     http://www.apache.org/licenses/LICENSE-2.0
     399              : 
     400              : Unless required by applicable law or agreed to in writing, software
     401              : distributed under the License is distributed on an "AS IS" BASIS,
     402              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     403              : See the License for the specific language governing permissions and
     404              : limitations under the License.
     405              : */
        

Generated by: LCOV version 2.0-1