LCOV - code coverage report
Current view: top level - data/include - data_classifier.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 151 177 85.3 %
Date: 2024-04-07 11:14:42 Functions: 28 30 93.3 %

          Line data    Source code
       1             : /* File: data_classifier.inl; Copyright and License: see below */
       2             : 
       3             : #include "data_id.h"
       4             : #include "u8/u8_trace.h"
       5             : #include "u8/u8_log.h"
       6             : #include <assert.h>
       7             : 
       8         797 : static inline void data_classifier_init_empty ( data_classifier_t *this_ )
       9             : {
      10         797 :     (*this_).id = DATA_ROW_ID_VOID;
      11         797 :     (*this_).main_type = DATA_CLASSIFIER_TYPE_BLOCK;
      12             : 
      13         797 :     (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
      14         797 :     utf8stringbuf_clear( (*this_).stereotype );
      15         797 :     (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
      16         797 :     utf8stringbuf_clear( (*this_).name );
      17         797 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
      18         797 :     utf8stringbuf_clear( (*this_).description );
      19             : 
      20         797 :     (*this_).x_order = 0;
      21         797 :     (*this_).y_order = 0;
      22         797 :     (*this_).list_order = 0;
      23         797 :     data_uuid_init_new( &((*this_).uuid) );
      24         797 : }
      25             : 
      26           0 : static inline void data_classifier_reinit_empty ( data_classifier_t *this_ )
      27             : {
      28             :     /* data_classifier_destroy( this_ );  -- not necessary */
      29           0 :     data_classifier_init_empty( this_ );
      30           0 : }
      31             : 
      32           5 : static inline u8_error_t data_classifier_init_new ( data_classifier_t *this_,
      33             :                                                     data_classifier_type_t main_type,
      34             :                                                     const char* stereotype,
      35             :                                                     const char* name,
      36             :                                                     const char* description,
      37             :                                                     int32_t x_order,
      38             :                                                     int32_t y_order,
      39             :                                                     int32_t list_order )
      40             : {
      41           5 :     assert( NULL != stereotype );
      42           5 :     assert( NULL != name );
      43           5 :     assert( NULL != description );
      44             :     utf8error_t strerr;
      45           5 :     u8_error_t result = U8_ERROR_NONE;
      46             : 
      47           5 :     (*this_).id = DATA_ROW_ID_VOID;
      48           5 :     (*this_).main_type = main_type;
      49             : 
      50           5 :     (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
      51           5 :     strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
      52           5 :     if ( strerr != UTF8ERROR_SUCCESS )
      53             :     {
      54           0 :         U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
      55           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      56             :     }
      57             : 
      58           5 :     (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
      59           5 :     strerr = utf8stringbuf_copy_str( (*this_).name, name );
      60           5 :     if ( strerr != UTF8ERROR_SUCCESS )
      61             :     {
      62           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      63           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      64             :     }
      65             : 
      66           5 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
      67           5 :     strerr = utf8stringbuf_copy_str( (*this_).description, description );
      68           5 :     if ( strerr != UTF8ERROR_SUCCESS )
      69             :     {
      70           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
      71           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
      72             :     }
      73             : 
      74           5 :     (*this_).x_order = x_order;
      75           5 :     (*this_).y_order = y_order;
      76           5 :     (*this_).list_order = list_order;
      77           5 :     data_uuid_init_new( &((*this_).uuid) );
      78             : 
      79           5 :     return result;
      80             : }
      81             : 
      82         846 : static inline u8_error_t data_classifier_init ( data_classifier_t *this_,
      83             :                                                 data_row_id_t id,
      84             :                                                 data_classifier_type_t main_type,
      85             :                                                 const char* stereotype,
      86             :                                                 const char* name,
      87             :                                                 const char* description,
      88             :                                                 int32_t x_order,
      89             :                                                 int32_t y_order,
      90             :                                                 int32_t list_order,
      91             :                                                 const char* uuid )
      92             : {
      93         846 :     assert( NULL != stereotype );
      94         846 :     assert( NULL != name );
      95         846 :     assert( NULL != description );
      96         846 :     assert( NULL != uuid );
      97             :     utf8error_t strerr;
      98         846 :     u8_error_t result = U8_ERROR_NONE;
      99             : 
     100         846 :     (*this_).id = id;
     101         846 :     if ( main_type == DATA_CLASSIFIER_TYPE_DEPRECATED_FEATURE )
     102             :     {
     103           0 :         main_type = DATA_CLASSIFIER_TYPE_REQUIREMENT;
     104           0 :         U8_LOG_ANOMALY_INT( "Classifier type FEATURE is deprecated. Converted to REQUIREMENT. See id C", id );
     105             :     }
     106         846 :     (*this_).main_type = main_type;
     107             : 
     108         846 :     (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
     109         846 :     strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
     110         846 :     if ( strerr != UTF8ERROR_SUCCESS )
     111             :     {
     112           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     113           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     114             :     }
     115             : 
     116         846 :     (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
     117         846 :     strerr = utf8stringbuf_copy_str( (*this_).name, name );
     118         846 :     if ( strerr != UTF8ERROR_SUCCESS )
     119             :     {
     120           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     121           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     122             :     }
     123             : 
     124         846 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     125         846 :     strerr = utf8stringbuf_copy_str( (*this_).description, description );
     126         846 :     if ( strerr != UTF8ERROR_SUCCESS )
     127             :     {
     128           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     129           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     130             :     }
     131             : 
     132         846 :     (*this_).x_order = x_order;
     133         846 :     (*this_).y_order = y_order;
     134         846 :     (*this_).list_order = list_order;
     135         846 :     result |= data_uuid_init( &((*this_).uuid), uuid );
     136             : 
     137         846 :     return result;
     138             : }
     139             : 
     140          38 : static inline u8_error_t data_classifier_reinit ( data_classifier_t *this_,
     141             :                                                   data_row_id_t id,
     142             :                                                   data_classifier_type_t main_type,
     143             :                                                   const char* stereotype,
     144             :                                                   const char* name,
     145             :                                                   const char* description,
     146             :                                                   int32_t x_order,
     147             :                                                   int32_t y_order,
     148             :                                                   int32_t list_order,
     149             :                                                   const char* uuid )
     150             : {
     151          38 :     return data_classifier_init( this_, id, main_type, stereotype, name, description, x_order, y_order, list_order, uuid );
     152             : }
     153             : 
     154          43 : static inline void data_classifier_copy ( data_classifier_t *this_, const data_classifier_t *original )
     155             : {
     156          43 :     assert( NULL != original );
     157             : 
     158          43 :     (*this_) = (*original);
     159             :     /* repair the overwritten pointers */
     160          43 :     (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
     161          43 :     (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
     162          43 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     163          43 :     data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
     164          43 : }
     165             : 
     166          56 : static inline void data_classifier_replace ( data_classifier_t *this_, const data_classifier_t *that )
     167             : {
     168          56 :     assert( NULL != that );
     169             : 
     170          56 :     (*this_) = (*that);
     171             :     /* repair the overwritten pointers */
     172          56 :     (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
     173          56 :     (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
     174          56 :     (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
     175          56 :     data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
     176          56 : }
     177             : 
     178         237 : static inline void data_classifier_destroy ( data_classifier_t *this_ )
     179             : {
     180         237 :     (*this_).id = DATA_ROW_ID_VOID;
     181         237 :     data_uuid_destroy( &((*this_).uuid) );
     182         237 : }
     183             : 
     184         131 : static inline void data_classifier_trace ( const data_classifier_t *this_ )
     185             : {
     186         131 :     U8_TRACE_INFO( "data_classifier_t" );
     187         131 :     U8_TRACE_INFO_INT( "- id:", (*this_).id );
     188         131 :     U8_TRACE_INFO_INT( "- main_type:", (*this_).main_type );
     189         131 :     U8_TRACE_INFO_STR( "- stereotype:", utf8stringbuf_get_string((*this_).stereotype) );
     190         131 :     U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string((*this_).name) );
     191         131 :     U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string((*this_).description) );
     192         131 :     U8_TRACE_INFO_INT( "- x_order:", (*this_).x_order );
     193         131 :     U8_TRACE_INFO_INT( "- y_order:", (*this_).y_order );
     194         131 :     U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
     195         131 :     U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
     196         131 : }
     197             : 
     198      565956 : static inline data_row_id_t data_classifier_get_row_id ( const data_classifier_t *this_ )
     199             : {
     200      565956 :     return (*this_).id;
     201             : }
     202             : 
     203          56 : static inline void data_classifier_set_row_id ( data_classifier_t *this_, data_row_id_t id )
     204             : {
     205          56 :     (*this_).id = id;
     206          56 : }
     207             : 
     208           0 : static inline data_id_t data_classifier_get_data_id ( const data_classifier_t *this_ )
     209             : {
     210             :     data_id_t result;
     211           0 :     data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).id );
     212           0 :     return result;
     213             : }
     214             : 
     215       34435 : static inline data_classifier_type_t data_classifier_get_main_type ( const data_classifier_t *this_ )
     216             : {
     217       34435 :     return (*this_).main_type;
     218             : }
     219             : 
     220         111 : static inline void data_classifier_set_main_type ( data_classifier_t *this_, data_classifier_type_t main_type )
     221             : {
     222         111 :     (*this_).main_type = main_type;
     223         111 : }
     224             : 
     225         637 : static inline const char *data_classifier_get_stereotype_const ( const data_classifier_t *this_ )
     226             : {
     227         637 :     return utf8stringbuf_get_string( (*this_).stereotype );
     228             : }
     229             : 
     230         285 : static inline bool data_classifier_has_stereotype ( const data_classifier_t *this_ )
     231             : {
     232         285 :     return ( ! utf8stringbuf_equals_str( (*this_).stereotype, "" ) );
     233             : }
     234             : 
     235          16 : static inline u8_error_t data_classifier_set_stereotype ( data_classifier_t *this_, const char *stereotype )
     236             : {
     237          16 :     assert( NULL != stereotype );
     238             : 
     239          16 :     u8_error_t result = U8_ERROR_NONE;
     240             :     utf8error_t strerr;
     241          16 :     strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
     242          16 :     if ( strerr != UTF8ERROR_SUCCESS )
     243             :     {
     244           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     245           0 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     246             :     }
     247          16 :     return result;
     248             : }
     249             : 
     250        1176 : static inline const char *data_classifier_get_name_const ( const data_classifier_t *this_ )
     251             : {
     252        1176 :     return utf8stringbuf_get_string( (*this_).name );
     253             : }
     254             : 
     255          21 : static inline u8_error_t data_classifier_set_name ( data_classifier_t *this_, const char *name )
     256             : {
     257          21 :     assert( NULL != name );
     258             : 
     259          21 :     u8_error_t result = U8_ERROR_NONE;
     260             :     utf8error_t strerr;
     261          21 :     strerr = utf8stringbuf_copy_str( (*this_).name, name );
     262          21 :     if ( strerr != UTF8ERROR_SUCCESS )
     263             :     {
     264           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     265           0 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     266             :     }
     267          21 :     return result;
     268             : }
     269             : 
     270         103 : static inline const char *data_classifier_get_description_const ( const data_classifier_t *this_ )
     271             : {
     272         103 :     return utf8stringbuf_get_string( (*this_).description );
     273             : }
     274             : 
     275          15 : static inline u8_error_t data_classifier_set_description ( data_classifier_t *this_, const char *description )
     276             : {
     277          15 :     assert( NULL != description );
     278             : 
     279          15 :     u8_error_t result = U8_ERROR_NONE;
     280             :     utf8error_t strerr;
     281          15 :     strerr = utf8stringbuf_copy_str( (*this_).description, description );
     282          15 :     if ( strerr != UTF8ERROR_SUCCESS )
     283             :     {
     284           0 :         U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
     285           0 :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     286             :     }
     287          15 :     return result;
     288             : }
     289             : 
     290             : static inline u8_error_t data_classifier_append_description ( data_classifier_t *this_, const char *description )
     291             : {
     292             :     assert( NULL != description );
     293             : 
     294             :     u8_error_t result = U8_ERROR_NONE;
     295             :     utf8error_t strerr;
     296             :     strerr = utf8stringbuf_append_str( (*this_).description, description );
     297             :     if ( strerr != UTF8ERROR_SUCCESS )
     298             :     {
     299             :         U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
     300             :         result = U8_ERROR_STRING_BUFFER_EXCEEDED;
     301             :     }
     302             :     return result;
     303             : }
     304             : 
     305          95 : static inline int32_t data_classifier_get_x_order ( const data_classifier_t *this_ )
     306             : {
     307          95 :     return (*this_).x_order;
     308             : }
     309             : 
     310          15 : static inline void data_classifier_set_x_order ( data_classifier_t *this_, int32_t x_order )
     311             : {
     312          15 :     (*this_).x_order = x_order;
     313          15 : }
     314             : 
     315          95 : static inline int32_t data_classifier_get_y_order ( const data_classifier_t *this_ )
     316             : {
     317          95 :     return (*this_).y_order;
     318             : }
     319             : 
     320          15 : static inline void data_classifier_set_y_order ( data_classifier_t *this_, int32_t y_order )
     321             : {
     322          15 :     (*this_).y_order = y_order;
     323          15 : }
     324             : 
     325          94 : static inline int32_t data_classifier_get_list_order ( const data_classifier_t *this_ )
     326             : {
     327          94 :     return (*this_).list_order;
     328             : }
     329             : 
     330          14 : static inline void data_classifier_set_list_order ( data_classifier_t *this_, int32_t list_order )
     331             : {
     332          14 :     (*this_).list_order = list_order;
     333          14 : }
     334             : 
     335         133 : static inline const char *data_classifier_get_uuid_const ( const data_classifier_t *this_ )
     336             : {
     337         133 :     return data_uuid_get_string( &((*this_).uuid) );
     338             : }
     339             : 
     340          11 : static inline u8_error_t data_classifier_set_uuid ( data_classifier_t *this_, const char *uuid )
     341             : {
     342          11 :     assert( NULL != uuid );
     343             : 
     344          11 :     const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
     345             : 
     346          11 :     return result;
     347             : }
     348             : 
     349      173372 : static inline bool data_classifier_is_valid ( const data_classifier_t *this_ )
     350             : {
     351      173372 :     return ( DATA_ROW_ID_VOID != (*this_).id );
     352             : }
     353             : 
     354             : 
     355             : /*
     356             : Copyright 2016-2024 Andreas Warnke
     357             : 
     358             : Licensed under the Apache License, Version 2.0 (the "License");
     359             : you may not use this file except in compliance with the License.
     360             : You may obtain a copy of the License at
     361             : 
     362             :     http://www.apache.org/licenses/LICENSE-2.0
     363             : 
     364             : Unless required by applicable law or agreed to in writing, software
     365             : distributed under the License is distributed on an "AS IS" BASIS,
     366             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     367             : See the License for the specific language governing permissions and
     368             : limitations under the License.
     369             : */

Generated by: LCOV version 1.16