]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/XML/src/FMI1/fmi1_xml_variable_impl.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / XML / src / FMI1 / fmi1_xml_variable_impl.h
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
7      This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10     FMILIB_License.txt file for more details.
11
12     You should have received a copy of the FMILIB_License.txt file
13     along with this program. If not, contact Modelon AB <http://www.modelon.com>.
14 */
15
16 #ifndef FMI1_XML_VARIABLEIMPL_H
17 #define FMI1_XML_VARIABLEIMPL_H
18
19 #include <JM/jm_vector.h>
20
21 #include <FMI1/fmi1_xml_model_description.h>
22
23 #include "fmi1_xml_type_impl.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* General variable type is convenien to unify all the variable list operations */
30 struct fmi1_xml_variable_t {
31     fmi1_xml_variable_type_base_t* typeBase;
32
33     const char* description;
34     jm_vector(jm_voidp)* directDependency;
35
36         size_t originalIndex;
37     fmi1_value_reference_t vr;
38     char aliasKind;
39     char variability;
40     char causality;
41
42     char name[1];
43 };
44
45 static int fmi1_xml_compare_vr (const void* first, const void* second) {
46     fmi1_xml_variable_t* a = *(fmi1_xml_variable_t**)first;
47     fmi1_xml_variable_t* b = *(fmi1_xml_variable_t**)second;
48     fmi1_base_type_enu_t at = fmi1_xml_get_variable_base_type(a);
49     fmi1_base_type_enu_t bt = fmi1_xml_get_variable_base_type(b);
50         if(at == fmi1_base_type_enum) at = fmi1_base_type_int;
51         if(bt == fmi1_base_type_enum) bt = fmi1_base_type_int;
52     if(at!=bt) return at - bt;
53     if(a->vr < b->vr) return -1;
54     if(a->vr > b->vr) return 1;
55     return ((int)a->aliasKind - (int)b->aliasKind);
56 }
57
58 void fmi1_xml_free_direct_dependencies(jm_named_ptr named);
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif /* FMI1_XML_VARIABLEIMPL_H */