2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
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.
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>.
18 /** \file fmi2_import_type.h
19 * \brief Public interface to the FMI XML C-library: variable types handling.
22 #ifndef FMI2_IMPORT_TYPE_H_
23 #define FMI2_IMPORT_TYPE_H_
25 #include "fmi2_import_unit.h"
32 \addtogroup fmi2_import
34 \addtogroup fmi2_import_typedef Support for processing variable types
36 \addtogroup fmi2_import_typedef Support for processing variable types
39 /**@name Type definitions supporting structures*/
\r
41 /** \brief Opaque type definition object. */
\r
42 typedef struct fmi2_xml_real_typedef_t fmi2_import_real_typedef_t;
\r
43 /** \brief Opaque integer type definition object. */
\r
44 typedef struct fmi2_xml_integer_typedef_t fmi2_import_integer_typedef_t;
\r
45 /** \brief Opaque enumeration type definition object. */
\r
46 typedef struct fmi2_xml_enumeration_typedef_t fmi2_import_enumeration_typedef_t;
\r
47 /** \brief Opaque general variable type definition object. */
\r
48 typedef struct fmi2_xml_variable_typedef_t fmi2_import_variable_typedef_t;
\r
49 /** \brief Opaque list of the type definitions in the model */
\r
50 typedef struct fmi2_xml_type_definitions_t fmi2_import_type_definitions_t;
\r
53 /** \brief Get the number of available type definitions */
54 FMILIB_EXPORT unsigned int fmi2_import_get_type_definition_number(fmi2_import_type_definitions_t* td);
56 /** \brief Get a type definition specified by the index
57 @param td the type definition list object
58 @param index the index of type definition. Must be less than the numbere returned by fmi2_import_get_type_definition_number()
59 @return A type definition object or NULL if index is out of range.
61 FMILIB_EXPORT fmi2_import_variable_typedef_t* fmi2_import_get_typedef(fmi2_import_type_definitions_t* td, unsigned int index);
63 /** \brief Get associated display unit for a type defition if any. */
64 FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_type_display_unit(fmi2_import_real_typedef_t*);
66 /** \brief Get the type name*/
67 FMILIB_EXPORT const char* fmi2_import_get_type_name(fmi2_import_variable_typedef_t*);
69 /**\brief Get type description.
71 Note that an empty string is returned if the attribute is not present in the XML.*/
72 FMILIB_EXPORT const char* fmi2_import_get_type_description(fmi2_import_variable_typedef_t*);
74 /** \brief Get base type used for the type definition */
75 FMILIB_EXPORT fmi2_base_type_enu_t fmi2_import_get_base_type(fmi2_import_variable_typedef_t*);
77 /* Boolean and String has no extra attributes -> not needed*/
79 /** \brief Cast the general type definition object to an object with a specific base type
80 @return Pointer to the specific type object or NULL if base type does not match.
82 FMILIB_EXPORT fmi2_import_real_typedef_t* fmi2_import_get_type_as_real(fmi2_import_variable_typedef_t*);
83 /** \brief Cast the general type definition object to an object with a specific base type
84 @return Pointer to the specific type object or NULL if base type does not match.
86 FMILIB_EXPORT fmi2_import_integer_typedef_t* fmi2_import_get_type_as_int(fmi2_import_variable_typedef_t*);
87 /** \brief Cast the general type definition object to an object with a specific base type
88 @return Pointer to the specific type object or NULL if base type does not match.
90 FMILIB_EXPORT fmi2_import_enumeration_typedef_t* fmi2_import_get_type_as_enum(fmi2_import_variable_typedef_t*);
92 /** \brief Get the quantity associated with the type definition.
94 @return NULL-pointer is always returned for strings and booleans.
95 Empty string is returned if attribute is not present for other types.
97 FMILIB_EXPORT const char* fmi2_import_get_type_quantity(fmi2_import_variable_typedef_t*);
99 /** \brief Get minimal value for the type.
101 @return Either the value specified in the XML file or negated DBL_MAX as defined in <float.h>
103 FMILIB_EXPORT double fmi2_import_get_real_type_min(fmi2_import_real_typedef_t*);
104 /** \brief Get maximum value for the type
106 @return Either the value specified in the XML file or DBL_MAX as defined in <float.h>
108 FMILIB_EXPORT double fmi2_import_get_real_type_max(fmi2_import_real_typedef_t*);
110 /** \brief Get the nominal value associated with the type definition */
111 FMILIB_EXPORT double fmi2_import_get_real_type_nominal(fmi2_import_real_typedef_t*);
113 /** \brief Get the unit object associated with the type definition if any*/
114 FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_real_type_unit(fmi2_import_real_typedef_t*);
116 /** \brief Get the 'relativeQuantity' flag */
117 FMILIB_EXPORT int fmi2_import_get_real_type_is_relative_quantity(fmi2_import_real_typedef_t*);
119 /** \brief Get the 'unbounded' flag */
120 FMILIB_EXPORT int fmi2_import_get_real_type_is_unbounded(fmi2_import_real_typedef_t*);
122 /** \brief Get minimal value for the type.
124 @return Either the value specified in the XML file or INT_MIN as defined in <limits.h>
126 FMILIB_EXPORT int fmi2_import_get_integer_type_min(fmi2_import_integer_typedef_t*);
127 /** \brief Get maximum value for the type
129 @return Either the value specified in the XML file or INT_MAX as defined in <limits.h>
131 FMILIB_EXPORT int fmi2_import_get_integer_type_max(fmi2_import_integer_typedef_t*);
133 /** \brief Get minimal value for the type.
135 @return Either the value specified in the XML file or 0
137 FMILIB_EXPORT unsigned int fmi2_import_get_enum_type_min(fmi2_import_enumeration_typedef_t*);
139 /** \brief Get maximum value for the type.
141 @return Either the value specified in the XML file or INT_MAX as defined in <limits.h>
143 FMILIB_EXPORT unsigned int fmi2_import_get_enum_type_max(fmi2_import_enumeration_typedef_t*);
145 /** \brief Get the number of elements in the enum */
146 FMILIB_EXPORT unsigned int fmi2_import_get_enum_type_size(fmi2_import_enumeration_typedef_t*);
148 /** \brief Get an enumeration item name by index */
149 FMILIB_EXPORT const char* fmi2_import_get_enum_type_item_name(fmi2_import_enumeration_typedef_t*, unsigned int item);
151 /** \brief Get an enumeration item value by index */
152 FMILIB_EXPORT int fmi2_import_get_enum_type_item_value(fmi2_import_enumeration_typedef_t*, unsigned int item);
154 /** \brief Get an enumeration item description by index */
155 FMILIB_EXPORT const char* fmi2_import_get_enum_type_item_description(fmi2_import_enumeration_typedef_t*, unsigned int item);
157 /** \brief Get an enumeration item name for the given value */
158 FMILIB_EXPORT const char* fmi2_import_get_enum_type_value_name(fmi2_import_enumeration_typedef_t* t, int value);
161 \brief Get display unit associated with a real type definition.
162 @return Display unit object of NULL if none was given.
164 FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_type_display_unit(fmi2_import_real_typedef_t*);