LCOV - code coverage report
Current view: top level - data/include - data_relationship.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 144 202 71.3 %
Date: 2024-04-07 11:14:42 Functions: 30 37 81.1 %

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