LCOV - code coverage report
Current view: top level - io/source/xmi - xmi_type_converter.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.67.0_covts Lines: 0.0 % 280 0
Test Date: 2025-11-06 17:22:08 Functions: 0.0 % 12 0

            Line data    Source code
       1              : /* File: xmi_type_converter.c; Copyright and License: see below */
       2              : 
       3              : #include "xmi/xmi_type_converter.h"
       4              : #include "xmi/xmi_element_info_map.h"
       5              : #include "u8/u8_trace.h"
       6              : #include "u8/u8_log.h"
       7              : #include <assert.h>
       8              : 
       9            0 : void xmi_type_converter_init ( xmi_type_converter_t *this_ )
      10              : {
      11            0 :     U8_TRACE_BEGIN();
      12              : 
      13            0 :     (*this_).dummy = 0;  /* prevent warnings on uninitialized usage */
      14              : 
      15            0 :     U8_TRACE_END();
      16            0 : }
      17              : 
      18            0 : void xmi_type_converter_destroy( xmi_type_converter_t *this_ )
      19              : {
      20            0 :     U8_TRACE_BEGIN();
      21              : 
      22            0 :     U8_TRACE_END();
      23            0 : }
      24              : 
      25              : /* ================================ CLASSIFIER ================================ */
      26              : 
      27            0 : xmi_spec_t xmi_type_converter_get_xmi_spec_of_classifier ( xmi_type_converter_t *this_, data_classifier_type_t c_type )
      28              : {
      29            0 :     U8_TRACE_BEGIN();
      30              : 
      31            0 :     const xmi_element_info_t *classifier_info = NULL;
      32            0 :     u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
      33              :                                                               DATA_CLASSIFIER_TYPE_PACKAGE, /*this parameter does not matter for this use case*/
      34              :                                                               c_type,
      35              :                                                               &classifier_info
      36              :                                                             );
      37            0 :     if ( map_err != 0 )
      38              :     {
      39            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", c_type );
      40              :     }
      41            0 :     assert ( classifier_info != NULL );
      42              : 
      43            0 :     const xmi_spec_t result
      44            0 :         = (*classifier_info).specification;
      45              : 
      46            0 :     U8_TRACE_END();
      47            0 :     return result;
      48              : }
      49              : 
      50            0 : const char* xmi_type_converter_get_xmi_type_of_classifier ( xmi_type_converter_t *this_,
      51              :                                                             data_classifier_type_t parent_type,
      52              :                                                             data_classifier_type_t c_type,
      53              :                                                             xmi_spec_t spec )
      54              : {
      55            0 :     U8_TRACE_BEGIN();
      56              : 
      57            0 :     const xmi_element_info_t *classifier_info = NULL;
      58            0 :     const u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
      59              :                                                                     parent_type,
      60              :                                                                     c_type,
      61              :                                                                     &classifier_info
      62              :                                                                   );
      63            0 :     if ( map_err != U8_ERROR_NONE )
      64              :     {
      65            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", c_type );
      66              :     }
      67            0 :     assert ( classifier_info != NULL );
      68              : 
      69            0 :     const char* result
      70            0 :         = (( (spec & (XMI_SPEC_SYSML|XMI_SPEC_STANDARD)) != 0 )&&( (*classifier_info).profile_name != NULL ))
      71            0 :         ? (*classifier_info).profile_name
      72            0 :         : (*classifier_info).base_name;
      73            0 :     assert ( result != NULL );
      74              : 
      75            0 :     U8_TRACE_END();
      76            0 :     return result;
      77              : }
      78              : 
      79            0 : u8_error_t xmi_type_converter_get_xmi_nesting_property_of_classifier ( xmi_type_converter_t *this_,
      80              :                                                                        data_classifier_type_t parent_type,
      81              :                                                                        data_classifier_type_t child_type,
      82              :                                                                        char const * *out_xmi_name )
      83              : {
      84            0 :     U8_TRACE_BEGIN();
      85            0 :     assert( out_xmi_name != NULL );
      86            0 :     const char* result = NULL;
      87              : 
      88            0 :     const xmi_element_info_t *parent_info = NULL;
      89            0 :     u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
      90              :                                                               DATA_CLASSIFIER_TYPE_PACKAGE, /*TODO: fix guess*/
      91              :                                                               parent_type,
      92              :                                                               &parent_info
      93              :                                                             );
      94            0 :     if ( map_err != U8_ERROR_NONE )
      95              :     {
      96            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", parent_type );
      97              :     }
      98            0 :     assert ( parent_info != NULL );
      99              : 
     100            0 :     const bool p_is_state = ( parent_type == DATA_CLASSIFIER_TYPE_STATE );
     101            0 :     const bool p_is_activity = ( parent_type == DATA_CLASSIFIER_TYPE_ACTIVITY );
     102            0 :     const bool p_is_interruptable_region = ( parent_type == DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION );
     103            0 :     const bool p_is_interaction = ( parent_type == DATA_CLASSIFIER_TYPE_INTERACTION );
     104            0 :     const xmi_element_info_t *child_info = NULL;
     105            0 :     map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     106              :                                                    parent_type,
     107              :                                                    child_type,
     108              :                                                    &child_info
     109              :                                                  );
     110            0 :     if ( map_err != U8_ERROR_NONE )
     111              :     {
     112            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", child_type );
     113              :     }
     114            0 :     assert ( child_info != NULL );
     115              : 
     116            0 :     if ( xmi_element_info_is_a_package(parent_info) &&  xmi_element_info_is_a_packageable_element(child_info) )
     117              :     {
     118              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 12.4.5.6 */
     119            0 :         result = "packagedElement";
     120              :     }
     121            0 :     else if ( xmi_element_info_is_a_comment(child_info) )
     122              :     {
     123              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 7.2 */
     124              :         /* any element can own 0..* comments */
     125            0 :         result = "ownedComment";
     126              :     }
     127            0 :     else if ( xmi_element_info_is_a_classifier(parent_info) && (child_type==DATA_CLASSIFIER_TYPE_USE_CASE) )
     128              :     {
     129              :         /* spec: https://www.omg.org/spec/UML/20161101/UML.xmi (v2.5.1) pkg: Classifier */
     130            0 :         result = "ownedUseCase";
     131              :     }
     132            0 :     else if ( xmi_element_info_is_a_node(parent_info) && xmi_element_info_is_a_node(child_info) )
     133              :     {
     134              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 19.5.10.5 */
     135            0 :         result = "nestedNode";
     136              :     }
     137            0 :     else if ( p_is_activity && xmi_element_info_is_a_activity_node(child_info) )
     138              :     {
     139              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 15.7.1.5 */
     140            0 :         result = "node";
     141              :     }
     142            0 :     else if ( p_is_activity && xmi_element_info_is_a_activity_group(child_info) )
     143              :     {
     144              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 15.7.1.5 */
     145            0 :         result = "group";
     146              :     }
     147            0 :     else if ( p_is_interruptable_region && xmi_element_info_is_a_activity_node(child_info) )
     148              :     {
     149              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 15.7.19.4 */
     150            0 :         result = "node";
     151              :     }
     152            0 :     else if ( xmi_element_info_is_a_behaviored_classifier(parent_info) && xmi_element_info_is_a_behavior(child_info) )
     153              :     {
     154              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 10.5.1 */
     155            0 :         result = "ownedBehavior";
     156              :     }
     157            0 :     else if ( xmi_element_info_is_a_class(parent_info) && xmi_element_info_is_a_classifier(child_info) )
     158              :     {
     159              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 11.8.3.6 */
     160            0 :         result = "nestedClassifier";
     161              :     }
     162            0 :     else if ( xmi_element_info_is_a_artifact(parent_info) && xmi_element_info_is_a_artifact(child_info) )
     163              :     {
     164              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 19.5.1.6 */
     165            0 :         result = "nestedArtifact";
     166              :     }
     167            0 :     else if ( p_is_state && xmi_element_info_is_a_vertex(child_info) )
     168              :     {
     169              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 14.5.8 (note: states have an implicit Region) */
     170            0 :         result = "subvertex";
     171              :     }
     172            0 :     else if ( p_is_interaction && xmi_element_info_is_a_interaction_fragment(child_info) )
     173              :     {
     174              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 17.12.11.4 */
     175            0 :         result = "fragment";
     176              :     }
     177              : 
     178            0 :     *out_xmi_name = (result==NULL) ? "" : result;
     179            0 :     const u8_error_t result_err = (result==NULL) ? U8_ERROR_NOT_FOUND : U8_ERROR_NONE;
     180            0 :     U8_TRACE_END_ERR( result_err );
     181            0 :     return result_err;
     182              : }
     183              : 
     184            0 : u8_error_t xmi_type_converter_get_xmi_owning_property_of_feature ( xmi_type_converter_t *this_,
     185              :                                                                    data_classifier_type_t parent_type,
     186              :                                                                    data_feature_type_t feature_type,
     187              :                                                                    char const * *out_xmi_name )
     188              : {
     189            0 :     U8_TRACE_BEGIN();
     190            0 :     assert( out_xmi_name != NULL );
     191            0 :     const char* result = NULL;
     192            0 :     u8_error_t result_err = U8_ERROR_NOT_FOUND;
     193              : 
     194            0 :     const xmi_element_info_t *parent_info = NULL;
     195            0 :     u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     196              :                                                               DATA_CLASSIFIER_TYPE_PACKAGE, /*TODO: fix guess*/
     197              :                                                               parent_type,
     198              :                                                               &parent_info
     199              :                                                             );
     200            0 :     if ( map_err != U8_ERROR_NONE )
     201              :     {
     202            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", parent_type );
     203              :     }
     204            0 :     assert ( parent_info != NULL );
     205              : 
     206            0 :     switch ( feature_type )
     207              :     {
     208            0 :         case DATA_FEATURE_TYPE_PROPERTY:
     209              :         {
     210            0 :             const bool p_is_interface = ( parent_type == DATA_CLASSIFIER_TYPE_INTERFACE );
     211              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 11.8.3.6 */
     212              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 10.5.5.4 */
     213            0 :             result = "ownedAttribute";
     214            0 :             result_err = ( xmi_element_info_is_a_class(parent_info) || p_is_interface ) ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     215              :         }
     216            0 :         break;
     217              : 
     218            0 :         case DATA_FEATURE_TYPE_OPERATION:
     219              :         {
     220            0 :             const bool p_is_interface = ( parent_type == DATA_CLASSIFIER_TYPE_INTERFACE );
     221              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 11.8.3.6 */
     222              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 10.5.5.4 */
     223            0 :             result = "ownedOperation";
     224            0 :             result_err = ( xmi_element_info_is_a_class(parent_info) || p_is_interface ) ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     225              :         }
     226            0 :         break;
     227              : 
     228            0 :         case DATA_FEATURE_TYPE_PORT:  /* or */
     229              :         case DATA_FEATURE_TYPE_IN_PORT_PIN:  /* or */
     230              :         case DATA_FEATURE_TYPE_OUT_PORT_PIN:
     231              :         {
     232            0 :             const bool is_behavioral_parent = data_classifier_type_is_behavioral( parent_type );
     233            0 :             if ( is_behavioral_parent )
     234              :             {
     235            0 :                 const bool p_is_activity_or_group
     236            0 :                     = ( parent_type == DATA_CLASSIFIER_TYPE_ACTIVITY )||( parent_type == DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION );
     237              :                 /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 15.7.1.5 */
     238            0 :                 result = "node";
     239            0 :                 result_err = p_is_activity_or_group ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     240              :             }
     241              :             else
     242              :             {
     243              :                 /* spec: https://www.omg.org/spec/UML/2.5.1/PDF ch 11.8.13.5 */
     244            0 :                 result = "ownedPort";
     245            0 :                 result_err = xmi_element_info_is_a_encapsulated_classifier(parent_info) ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     246              :                 /*TODO ownedPort is a derived value*/
     247              :             }
     248              :         }
     249            0 :         break;
     250              : 
     251            0 :         case DATA_FEATURE_TYPE_LIFELINE:
     252              :         {
     253            0 :             const bool p_is_interaction = ( parent_type == DATA_CLASSIFIER_TYPE_INTERACTION );
     254              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF 17.3.2 */
     255            0 :             result = "lifeline";
     256            0 :             result_err = p_is_interaction ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND; /* note, DATA_CLASSIFIER_TYPE_INTERACTION is a fake type - only here, lifelines are valid. */
     257              :         }
     258            0 :         break;
     259              : 
     260            0 :         case DATA_FEATURE_TYPE_PROVIDED_INTERFACE:
     261              :         {
     262            0 :             const bool p_is_component
     263              :                 = ( parent_type == DATA_CLASSIFIER_TYPE_COMPONENT )
     264            0 :                   ||( parent_type == DATA_CLASSIFIER_TYPE_PART );
     265              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF ch 11.6.2 */
     266            0 :             result = "provided";
     267            0 :             result_err = p_is_component ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     268              :             /*TODO provided is a derived value*/
     269              :         }
     270            0 :         break;
     271              : 
     272            0 :         case DATA_FEATURE_TYPE_REQUIRED_INTERFACE:
     273              :         {
     274            0 :             const bool p_is_component
     275              :                 = ( parent_type == DATA_CLASSIFIER_TYPE_COMPONENT )
     276            0 :                   ||( parent_type == DATA_CLASSIFIER_TYPE_PART );
     277              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF ch 11.6.2 */
     278            0 :             result = "required";
     279            0 :             result_err = p_is_component ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     280              :             /*TODO required is a derived value*/
     281              :         }
     282            0 :         break;
     283              : 
     284            0 :         case DATA_FEATURE_TYPE_ENTRY:  /* or */
     285              :         case DATA_FEATURE_TYPE_EXIT:
     286              :         {
     287            0 :             const bool p_is_state = ( parent_type == DATA_CLASSIFIER_TYPE_STATE );
     288              :             /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 14.5.8 (note: states have an implicit Region) */
     289            0 :             result = "subvertex";
     290            0 :             result_err = ( p_is_state ) ? U8_ERROR_NONE : U8_ERROR_NOT_FOUND;
     291              :         }
     292            0 :         break;
     293              : 
     294            0 :         case DATA_FEATURE_TYPE_TAGGED_VALUE:
     295              :         {
     296              :             /* tagges values belong to the profile section, not to the parent classifier */
     297            0 :             result = NULL;
     298            0 :             result_err = U8_ERROR_PARAM_OUT_OF_RANGE;
     299              :         }
     300            0 :         break;
     301              : 
     302            0 :         default:
     303              :         {
     304            0 :             U8_LOG_ERROR_INT( "switch case statement for data_relationship_type_t incomplete", feature_type );
     305              :             /* this is a possible error case that can happen when a database created with a newer version of the program is opened with this version */
     306            0 :             result = NULL;
     307              :         }
     308            0 :         break;
     309              :     }
     310              : 
     311            0 :     *out_xmi_name = (result==NULL) ? "" : result;
     312            0 :     U8_TRACE_END_ERR( result_err );
     313            0 :     return result_err;
     314              : }
     315              : 
     316            0 : u8_error_t xmi_type_converter_get_xmi_nesting_property_of_relationship ( xmi_type_converter_t *this_,
     317              :                                                                          data_classifier_type_t hosting_type,
     318              :                                                                          data_relationship_type_t child_type,
     319              :                                                                          char const * *out_xmi_name )
     320              : {
     321            0 :     U8_TRACE_BEGIN();
     322            0 :     assert( out_xmi_name != NULL );
     323            0 :     const char* result = NULL;
     324              : 
     325            0 :     const xmi_element_info_t *host_info = NULL;
     326            0 :     u8_error_t map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     327              :                                                               DATA_CLASSIFIER_TYPE_PACKAGE, /*TODO: fix guess*/
     328              :                                                               hosting_type,
     329              :                                                               &host_info
     330              :                                                             );
     331            0 :     if ( map_err != U8_ERROR_NONE )
     332              :     {
     333            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", hosting_type );
     334              :     }
     335            0 :     assert ( host_info != NULL );
     336              : 
     337            0 :     const bool host_is_activity = ( hosting_type == DATA_CLASSIFIER_TYPE_ACTIVITY );
     338              :     /*const bool host_is_interface = ( hosting_type == DATA_CLASSIFIER_TYPE_INTERFACE );*/
     339            0 :     const bool host_is_implicit_region = ( hosting_type == DATA_CLASSIFIER_TYPE_STATE );
     340            0 :     const bool host_is_usecase = ( hosting_type == DATA_CLASSIFIER_TYPE_USE_CASE );
     341            0 :     const bool host_is_state = ( hosting_type == DATA_CLASSIFIER_TYPE_STATE );
     342            0 :     const bool host_is_interaction = ( hosting_type == DATA_CLASSIFIER_TYPE_INTERACTION );
     343            0 :     const bool host_is_comment = ( hosting_type == DATA_CLASSIFIER_TYPE_COMMENT );
     344            0 :     const xmi_element_info_t *child_info = NULL;
     345            0 :     map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
     346              :                                                      host_is_state,
     347              :                                                      child_type,
     348              :                                                      &child_info
     349              :                                                    );
     350            0 :     if ( map_err != U8_ERROR_NONE )
     351              :     {
     352            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_relationship could not map unknown type", child_type );
     353              :     }
     354            0 :     assert ( child_info != NULL );
     355              : 
     356            0 :     const bool c_is_generalization = ( child_type == DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION );
     357              : 
     358            0 :     if ( xmi_element_info_is_a_package(host_info) && xmi_element_info_is_a_packageable_element(child_info) )
     359              :     {
     360              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 12.4.5.6 */
     361            0 :         result = "packagedElement";
     362              :     }
     363            0 :     else if ( xmi_element_info_is_a_classifier(host_info) && c_is_generalization )
     364              :     {
     365              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 9.9.4 */
     366            0 :         result = "generalization";
     367              :     }
     368            0 :     else if ( host_is_activity && xmi_element_info_is_a_activity_edge(child_info) )
     369              :     {
     370              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 15.7.1.5 */
     371            0 :         result = "edge";
     372              :     }
     373              :     /*
     374              :     else if ( host_is_interface && xmi_element_info_is_a_reception(child_info) )
     375              :     {
     376              :         / * spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 10.5.5.4 * /
     377              :         result = "ownedReception";
     378              :     }
     379              :     */
     380              :     /*
     381              :     else if ( xmi_element_info_is_a_class(host_info) && xmi_element_info_is_a_reception(child_info) )
     382              :     {
     383              :         / * spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 11.8.3.6 * /
     384              :         result = "ownedReception";
     385              :     }
     386              :     */
     387            0 :     else if ( host_is_implicit_region && xmi_element_info_is_a_transition(child_info) )
     388              :     {
     389              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 14.5.8.4 */
     390            0 :         result = "transition";
     391              :     }
     392            0 :     else if ( host_is_usecase && (child_type==DATA_RELATIONSHIP_TYPE_UML_EXTEND) )
     393              :     {
     394              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 18.2.5.4 */
     395            0 :         result = "extend";
     396              :     }
     397            0 :     else if ( host_is_usecase && (child_type==DATA_RELATIONSHIP_TYPE_UML_INCLUDE) )
     398              :     {
     399              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 18.2.5.4 */
     400            0 :         result = "include";
     401              :     }
     402            0 :     else if ( host_is_interaction && xmi_element_info_is_a_message(child_info) )
     403              :     {
     404              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 17.4 */
     405            0 :         result = "message";
     406              :     }
     407            0 :     else if ( host_is_comment && (child_type==DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY) )
     408              :     {
     409              :         /* spec: https://www.omg.org/spec/UML/2.5.1/PDF chapter 7.8.2 */
     410            0 :         result = "annotatedElement";
     411              :     }
     412              : 
     413            0 :     *out_xmi_name = (result==NULL) ? "" : result;
     414            0 :     const u8_error_t result_err = (result==NULL) ? U8_ERROR_NOT_FOUND : U8_ERROR_NONE;
     415            0 :     U8_TRACE_END_ERR( result_err );
     416            0 :     return result_err;
     417              : }
     418              : 
     419              : /* ================================ FEATURE ================================ */
     420              : 
     421            0 : xmi_spec_t xmi_type_converter_get_xmi_spec_of_feature ( xmi_type_converter_t *this_, data_feature_type_t feature_type )
     422              : {
     423            0 :     U8_TRACE_BEGIN();
     424            0 :     xmi_spec_t result = XMI_SPEC_UML;  /* all currently known features are defined in the uml specification */
     425              : 
     426            0 :     U8_TRACE_END();
     427            0 :     return result;
     428              : }
     429              : 
     430            0 : const char* xmi_type_converter_get_xmi_type_of_feature ( xmi_type_converter_t *this_,
     431              :                                                          data_classifier_type_t parent_type,
     432              :                                                          data_feature_type_t feature_type,
     433              :                                                          xmi_spec_t spec )
     434              : {
     435            0 :     U8_TRACE_BEGIN();
     436              : 
     437            0 :     const xmi_element_info_t *feature_info = NULL;
     438            0 :     u8_error_t map_err = xmi_element_info_map_get_feature( &xmi_element_info_map_standard,
     439              :                                                            parent_type,
     440              :                                                            feature_type,
     441              :                                                            &feature_info
     442              :                                                          );
     443            0 :     if ( map_err != U8_ERROR_NONE )
     444              :     {
     445            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_feature could not map unknown type", feature_type );
     446              :     }
     447            0 :     assert ( feature_info != NULL );
     448              : 
     449            0 :     const char* result
     450            0 :         = (( (spec & (XMI_SPEC_SYSML|XMI_SPEC_STANDARD|XMI_SPEC_MOF)) != 0 )&&( (*feature_info).profile_name != NULL ))
     451            0 :         ? (*feature_info).profile_name
     452            0 :         : (*feature_info).base_name;
     453            0 :     assert ( result != NULL );
     454              : 
     455            0 :     U8_TRACE_END();
     456            0 :     return result;
     457              : }
     458              : 
     459              : /* ================================ RELATIONSHIP ================================ */
     460              : 
     461            0 : xmi_spec_t xmi_type_converter_get_xmi_spec_of_relationship ( xmi_type_converter_t *this_, data_relationship_type_t r_type )
     462              : {
     463            0 :     U8_TRACE_BEGIN();
     464              : 
     465            0 :     const xmi_element_info_t *rel_info = NULL;
     466            0 :     u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
     467              :                                                                 false, /*this parameter does not matter for this use case*/
     468              :                                                                 r_type,
     469              :                                                                 &rel_info
     470              :                                                               );
     471            0 :     if ( map_err != U8_ERROR_NONE )
     472              :     {
     473            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_relationship could not map unknown type", r_type );
     474              :     }
     475            0 :     assert ( rel_info != NULL );
     476              : 
     477            0 :     const xmi_spec_t result
     478            0 :         = (*rel_info).specification;
     479              : 
     480            0 :     U8_TRACE_END();
     481            0 :     return result;
     482              : }
     483              : 
     484            0 : const char* xmi_type_converter_get_xmi_type_of_relationship ( xmi_type_converter_t *this_,
     485              :                                                               data_classifier_type_t hosting_type,
     486              :                                                               data_relationship_type_t r_type,
     487              :                                                               xmi_spec_t spec  )
     488              : {
     489            0 :     U8_TRACE_BEGIN();
     490              : 
     491            0 :     const bool host_is_state = ( hosting_type == DATA_CLASSIFIER_TYPE_STATE );
     492            0 :     const xmi_element_info_t *rel_info = NULL;
     493            0 :     u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
     494              :                                                                 host_is_state,
     495              :                                                                 r_type,
     496              :                                                                 &rel_info
     497              :                                                               );
     498            0 :     if ( map_err != U8_ERROR_NONE )
     499              :     {
     500            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_relationship could not map unknown type", r_type );
     501              :     }
     502            0 :     assert ( rel_info != NULL );
     503              : 
     504            0 :     const char* result
     505            0 :         = (( (spec & (XMI_SPEC_SYSML|XMI_SPEC_STANDARD)) != 0 )&&( (*rel_info).profile_name != NULL ))
     506            0 :         ? (*rel_info).profile_name
     507            0 :         : (*rel_info).base_name;
     508            0 :     assert ( result != NULL );
     509              : 
     510            0 :     U8_TRACE_END();
     511            0 :     return result;
     512              : }
     513              : 
     514            0 : u8_error_t xmi_type_converter_private_get_xmi_end_property_of_relationship ( xmi_type_converter_t *this_,
     515              :                                                                              data_classifier_type_t hosting_type,
     516              :                                                                              data_relationship_type_t rel_type,
     517              :                                                                              bool from_end,
     518              :                                                                              data_classifier_type_t end_classifier_type,
     519              :                                                                              data_feature_type_t end_feature_type,
     520              :                                                                              char const * *out_xmi_name )
     521              : {
     522            0 :     U8_TRACE_BEGIN();
     523            0 :     assert( out_xmi_name != NULL );
     524            0 :     u8_error_t err = U8_ERROR_NONE;
     525              : 
     526            0 :     const bool host_is_state = ( hosting_type == DATA_CLASSIFIER_TYPE_STATE );
     527            0 :     const xmi_element_info_t *rel_info = NULL;
     528            0 :     u8_error_t map_err = xmi_element_info_map_get_relationship( &xmi_element_info_map_standard,
     529              :                                                                 host_is_state,
     530              :                                                                 rel_type,
     531              :                                                                 &rel_info
     532              :                                                               );
     533            0 :     if ( map_err != U8_ERROR_NONE )
     534              :     {
     535            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_relationship could not map unknown type", rel_type );
     536              :     }
     537            0 :     assert ( rel_info != NULL );
     538              : 
     539            0 :     const char* result
     540              :         = ( from_end )
     541            0 :         ? (*rel_info).property_from
     542            0 :         : (*rel_info).property_to;
     543            0 :     assert ( result != NULL );
     544              : 
     545            0 :     *out_xmi_name = ( result == NULL ) ? "" : result;
     546            0 :     err = ( result == NULL ) ? U8_ERROR_NOT_FOUND : U8_ERROR_NONE;
     547              : 
     548            0 :     const xmi_element_info_t *classifier_info = NULL;
     549            0 :     map_err = xmi_element_info_map_get_classifier( &xmi_element_info_map_standard,
     550              :                                                    hosting_type,
     551              :                                                    end_classifier_type,
     552              :                                                    &classifier_info
     553              :                                                  );
     554            0 :     if ( map_err != U8_ERROR_NONE )
     555              :     {
     556            0 :         U8_LOG_WARNING_INT("xmi_element_info_map_get_classifier could not map unknown type", end_classifier_type );
     557              :     }
     558            0 :     assert ( classifier_info != NULL );
     559              : 
     560            0 :     if ( end_feature_type == DATA_FEATURE_TYPE_VOID )
     561              :     {
     562              :         /* relationship end is at a classifier */
     563              : 
     564              :         /* DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW and DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW */
     565            0 :         if ( xmi_element_info_is_a_transition( rel_info ) && xmi_element_info_is_a_vertex( classifier_info ) )
     566              :         {
     567              :             /* valid relationship according to uml 2.5.1 spec, chapter 14.5.11 */
     568              :         }
     569            0 :         else if ( xmi_element_info_is_a_activity_edge( rel_info ) && xmi_element_info_is_a_activity_node( classifier_info ) )
     570              :         {
     571              :             /* valid relationship according to uml 2.5.1 spec, chapter 15.7.2 */
     572              :         }
     573              :         //else if ( xmi_element_info_is_a_activity_edge( rel_info ) && ( end_classifier_type == DATA_CLASSIFIER_TYPE_ACTIVITY ))
     574              :         //{
     575              :             /* valid relationship according to uml 2.5.1 spec, chapter 16.14.55 */
     576              :             // this is duplicate for XMI_ELEMENT_INFO_MAP_INDEX_STRUCTURED_ACTIVITY_NODE
     577              :             // this is not true for XMI_ELEMENT_INFO_MAP_INDEX_ACTIVITY
     578              :             // see https://issues.omg.org/issues/lists/uml2-rtf#issue-47324
     579              :         //}
     580              : 
     581              :         /* DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY, DATA_RELATIONSHIP_TYPE_UML_REALIZATION, DATA_RELATIONSHIP_TYPE_UML_MANIFEST, */
     582              :         /* DATA_RELATIONSHIP_TYPE_UML_DEPLOY, DATA_RELATIONSHIP_TYPE_UML_REFINE,  DATA_RELATIONSHIP_TYPE_UML_TRACE */
     583            0 :         else if ( xmi_element_info_is_a_dependency( rel_info ) && xmi_element_info_is_a_named_element( classifier_info ) )
     584              :         {
     585              :             /* a dependency can connect any named elements according to uml 2.5.1 spec, chapter 7.8.4  */
     586              :         }
     587              : 
     588              :         /* DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION, DATA_RELATIONSHIP_TYPE_UML_AGGREGATION, DATA_RELATIONSHIP_TYPE_UML_COMPOSITION, */
     589              :         /* DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH, DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT */
     590            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && xmi_element_info_is_a_class( classifier_info ) )
     591              :         {
     592              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     593              :             /* a property can connect a class according to uml 2.5.1 spec, chapter 9.9.17  */
     594              :         }
     595            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && ( end_classifier_type == DATA_CLASSIFIER_TYPE_INTERFACE ))
     596              :         {
     597              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     598              :             /* a property can connect an interface according to uml 2.5.1 spec, chapter 9.9.17  */
     599              :         }
     600            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && xmi_element_info_is_a_classifier( classifier_info ) )
     601              :         {
     602              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     603              :             /* a property is a typedelelemnt and can therefore connect a classifier(type) according to uml 2.5.1 spec, chapter 7.8.22  */
     604              :         }
     605              : 
     606              :         /* DATA_RELATIONSHIP_TYPE_UML_EXTEND and DATA_RELATIONSHIP_TYPE_UML_INCLUDE */
     607            0 :         else if (( rel_type == DATA_RELATIONSHIP_TYPE_UML_EXTEND ) && ( end_classifier_type == DATA_CLASSIFIER_TYPE_USE_CASE ))
     608              :         {
     609              :             /* an extend directed relationship can connect to a use case according to uml 2.5.1 spec, chapter 18.2.2  */
     610              :         }
     611            0 :         else if (( rel_type == DATA_RELATIONSHIP_TYPE_UML_INCLUDE ) && ( end_classifier_type == DATA_CLASSIFIER_TYPE_USE_CASE ))
     612              :         {
     613              :             /* an include directed relationship can connect to a use case according to uml 2.5.1 spec, chapter 18.2.4  */
     614              :         }
     615              : 
     616              :         /* DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION */
     617            0 :         else if (( rel_type == DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION ) && xmi_element_info_is_a_classifier( classifier_info ) )
     618              :         {
     619              :             /* a generalization can connect any classifiers according to uml 2.5.1 spec, chapter 9.9.7  */
     620              :         }
     621              : 
     622              :         else
     623              :         {
     624              :             /* no valid end type for given relationship type */
     625            0 :             err = U8_ERROR_NOT_FOUND;
     626              :         }
     627              :     }
     628              :     else
     629              :     {
     630              :         /* relationship end is at feature */
     631            0 :         const xmi_element_info_t *feature_info = NULL;
     632            0 :         map_err = xmi_element_info_map_get_feature( &xmi_element_info_map_standard,
     633              :                                                     end_classifier_type,
     634              :                                                     end_feature_type,
     635              :                                                     &feature_info
     636              :                                                   );
     637            0 :         if ( map_err != U8_ERROR_NONE )
     638              :         {
     639            0 :             U8_LOG_WARNING_INT("xmi_element_info_map_get_feature could not map unknown type", end_feature_type );
     640              :         }
     641            0 :         assert ( feature_info != NULL );
     642              : 
     643              :         /* DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW and DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW */
     644            0 :         if ( xmi_element_info_is_a_transition( rel_info )
     645            0 :             && (( end_feature_type == DATA_FEATURE_TYPE_ENTRY )||( end_feature_type == DATA_FEATURE_TYPE_EXIT )))
     646              :         {
     647              :             /* valid relationship according to uml 2.5.1 spec, chapter 14.5.11 */
     648              :         }
     649            0 :         else if ( xmi_element_info_is_a_activity_edge( rel_info ) && xmi_element_info_is_a_activity_node( feature_info ) )
     650              :         {
     651              :             /* valid relationship according to uml 2.5.1 spec, chapter 15.7.2 */
     652              :         }
     653              : 
     654              :         /* DATA_RELATIONSHIP_TYPE_UML_ASYNC_CALL or DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL or DATA_RELATIONSHIP_TYPE_UML_RETURN_CALL */
     655            0 :         else if ( xmi_element_info_is_a_message ( rel_info ) && ( end_feature_type == DATA_FEATURE_TYPE_LIFELINE ))
     656              :         {
     657              :             /* valid relationship according to uml 2.5.1 spec, chapter 17.12.23 */
     658              :         }
     659              : 
     660              :         /* DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY, DATA_RELATIONSHIP_TYPE_UML_REALIZATION, DATA_RELATIONSHIP_TYPE_UML_MANIFEST, */
     661              :         /* DATA_RELATIONSHIP_TYPE_UML_DEPLOY, DATA_RELATIONSHIP_TYPE_UML_REFINE,  DATA_RELATIONSHIP_TYPE_UML_TRACE */
     662            0 :         else if ( xmi_element_info_is_a_dependency( rel_info ) && xmi_element_info_is_a_named_element( feature_info ) )
     663              :         {
     664              :             /* a dependency can connect any named elements according to uml 2.5.1 spec, chapter 7.8.4  */
     665              :         }
     666              : 
     667              :         /* DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION, DATA_RELATIONSHIP_TYPE_UML_AGGREGATION, DATA_RELATIONSHIP_TYPE_UML_COMPOSITION, */
     668              :         /* DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH, DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT */
     669            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && xmi_element_info_is_a_class( feature_info ) )
     670              :         {
     671              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     672              :             /* a property can connect a class according to uml 2.5.1 spec, chapter 9.9.17  */
     673              :         }
     674            0 :         else if ( xmi_element_info_is_a_association( rel_info )
     675            0 :             && (( end_feature_type ==  DATA_FEATURE_TYPE_PROVIDED_INTERFACE )||( end_feature_type == DATA_FEATURE_TYPE_REQUIRED_INTERFACE )))
     676              :         {
     677              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     678              :             /* a property can connect an interface according to uml 2.5.1 spec, chapter 9.9.17  */
     679              :         }
     680            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && xmi_element_info_is_a_classifier( feature_info ) )
     681              :         {
     682              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     683              :             /* a property is a typedelelemnt and can therefore connect a classifier(type) according to uml 2.5.1 spec, chapter 7.8.22  */
     684              :         }
     685            0 :         else if ( xmi_element_info_is_a_association( rel_info ) && xmi_element_info_is_a_property( feature_info ) )
     686              :         {
     687              :             /* an association can connect to a propoerty according to uml 2.5.1 spec, chapter 11.8.1  */
     688              :             /* a port is a property */
     689              :         }
     690              : 
     691              :         else
     692              :         {
     693              :             /* no valid end type for given relationship type */
     694            0 :             err = U8_ERROR_NOT_FOUND;
     695              :         }
     696              : 
     697              :     }
     698              : 
     699            0 :     U8_TRACE_END_ERR( err );
     700            0 :     return err;
     701              : }
     702              : 
     703              : 
     704              : /*
     705              : Copyright 2020-2025 Andreas Warnke
     706              : 
     707              : Licensed under the Apache License, Version 2.0 (the "License");
     708              : you may not use this file except in compliance with the License.
     709              : You may obtain a copy of the License at
     710              : 
     711              :     http://www.apache.org/licenses/LICENSE-2.0
     712              : 
     713              : Unless required by applicable law or agreed to in writing, software
     714              : distributed under the License is distributed on an "AS IS" BASIS,
     715              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     716              : See the License for the specific language governing permissions and
     717              : limitations under the License.
     718              : */
        

Generated by: LCOV version 2.0-1