]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI/fmi_import_context.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI / fmi_import_context.h
1 /*\r
2     Copyright (C) 2012 Modelon AB\r
3 \r
4     This program is free software: you can redistribute it and/or modify\r
5     it under the terms of the BSD style license.
6 \r
7     This program is distributed in the hope that it will be useful,\r
8     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
10     FMILIB_License.txt file for more details.\r
11 \r
12     You should have received a copy of the FMILIB_License.txt file\r
13     along with this program. If not, contact Modelon AB <http://www.modelon.com>.\r
14 */\r
15 \r
16 \r
17 /** \file fmi_import_context.h\r
18 *  \brief Import context is the entry point to the library. It is used to initialize, unzip, get FMI version and start parsing.\r
19 */\r
20 \r
21 #ifndef FMI_IMPORT_CONTEXT_H_\r
22 #define FMI_IMPORT_CONTEXT_H_\r
23 \r
24 #include <stddef.h>\r
25 #include <fmilib_config.h>\r
26 #include <JM/jm_callbacks.h>\r
27 #include <FMI2/fmi2_xml_callbacks.h>\r
28 #include <FMI/fmi_version.h> \r
29 #include <FMI1/fmi1_types.h>\r
30 #include <FMI1/fmi1_enums.h>\r
31 #include <FMI2/fmi2_types.h>\r
32 #include <FMI2/fmi2_enums.h>\r
33 \r
34 #ifdef __cplusplus\r
35 extern "C" {\r
36 #endif\r
37 \r
38         \r
39 /** \r
40 \addtogroup fmi_import FMI import library\r
41 @{\r
42 \addtogroup fmi_import_context Library initialization\r
43 Interaction with an FMU by means of the FMI Library starts with allocation of \r
44 an ::fmi_import_context_t structure. This is done with a call to fmi_import_allocate_context().\r
45 The next step is detection of FMI standard used in the specific FMU. This is achieved by\r
46 calling fmi_import_get_fmi_version() function. When the standard is known a standard\r
47 specific function for processing model description XML should be called to create an\r
48 opaque FMU structure. This is done by calling either fmi1_import_parse_xml() or fmi2_import_parse_xml().\r
49 With the FMU structure available one can proceed by loading the FMU binary \r
50 (fmi1_import_create_dllfmu() or fmi2_import_create_dllfmu()). After that \r
51 the code is able to interact with the FMU by means of the methonds presented \r
52 in \ref fmi1_import_capi and \ref fmi2_import_capi.\r
53 \r
54 \addtogroup  fmi1_import\r
55 \addtogroup  fmi2_import\r
56 \addtogroup  fmi_import_utils\r
57 @}\r
58 \addtogroup fmi_import_context\r
59 @{\r
60 */\r
61 \r
62 /** \brief FMI version independent library context. \r
63         Opaque struct returned from fmi_import_allocate_context()\r
64 */\r
65 typedef struct fmi_xml_context_t fmi_import_context_t ;\r
66 \r
67 /** \brief Create fmi_import_context_t structure.\r
68         @param callbacks - a pointer to the library callbacks for memory management and logging. May be NULL if defaults are utilized.\r
69         @return A new structure if memory allocation was successful.\r
70 */\r
71 FMILIB_EXPORT fmi_import_context_t* fmi_import_allocate_context( jm_callbacks* callbacks);\r
72 \r
73 /**\r
74         \brief Free memory allocated for the library context.\r
75         @param c - library context allocated by fmi_import_allocate_context()\r
76 */\r
77 FMILIB_EXPORT void fmi_import_free_context( fmi_import_context_t* c);\r
78 \r
79 /**\r
80     \brief If this configuration option is set, the model description will be\r
81     checked to follow the variable naming conventions. Variables not following\r
82     the convention will be logged.\r
83 */\r
84 #define FMI_IMPORT_NAME_CHECK 1\r
85 \r
86 /**\r
87     \brief Sets advanced configuration, if zero is passed default configuration\r
88     is set. Currently only one non default configuration is available:\r
89     FMI_IMPORT_XML_NAME_CHECK.\r
90     @param conf - specifies the configuration to use\r
91 */\r
92 FMILIB_EXPORT void fmi_import_set_configuration( fmi_import_context_t* c, int conf);\r
93 \r
94 /**\r
95         \brief Unzip an FMU specified by the fileName into directory dirName and parse XML to get FMI standard version.\r
96         @param c - library context.\r
97         @param fileName - an FMU file name.\r
98         @param dirName - a directory name where the FMU should be unpacked\r
99 */\r
100 FMILIB_EXPORT fmi_version_enu_t fmi_import_get_fmi_version( fmi_import_context_t* c, const char* fileName, const char* dirName);\r
101 \r
102 /**\r
103         \brief FMU version 1.0 object\r
104 */\r
105 typedef struct fmi1_import_t fmi1_import_t;\r
106 \r
107 /**\r
108         \brief FMU version 2.0 object\r
109 */\r
110 typedef struct fmi2_import_t fmi2_import_t;\r
111 \r
112 /**\r
113         \brief Parse FMI 1.0 XML file found in the directory dirName.\r
114         \param c - library context.\r
115         \param dirName - a directory where the FMU was unpacked and XML file is present.\r
116         \return fmi1_import_t:: opaque object pointer\r
117 */\r
118 FMILIB_EXPORT fmi1_import_t* fmi1_import_parse_xml( fmi_import_context_t* c, const char* dirName);\r
119 \r
120 /**\r
121     \brief Create ::fmi2_import_t structure and parse the FMI 2.0 XML file found in the directory dirName.\r
122         \param context - library context.\r
123         \param dirPath - a directory where the FMU was unpacked and XML file is present.\r
124         \param xml_callbacks Callbacks to use for processing of annotations (may be NULL).\r
125         \return fmi2_import_t:: opaque object pointer\r
126 */\r
127 FMILIB_EXPORT fmi2_import_t* fmi2_import_parse_xml( fmi_import_context_t* context, const char* dirPath, fmi2_xml_callbacks_t* xml_callbacks);\r
128 \r
129 /** \r
130 @}\r
131 */\r
132 \r
133 #ifdef __cplusplus\r
134 }\r
135 #endif\r
136 #endif\r