Skip to content

Commit

Permalink
Fixing documentation for terminalsAndIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Meisrimel authored and Peter Meisrimel committed Jul 30, 2024
1 parent 9996580 commit 69807f8
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 32 deletions.
10 changes: 5 additions & 5 deletions Test/FMI2/fmi2_import_terminals_and_icons_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ TEST_CASE("Test parse terminals and icons") {
// test the existing ones
term = fmi2_import_get_terminal_by_name(xml, "terminalA");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalA");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalA");

term = fmi2_import_get_terminal_by_name(xml, "terminalB");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalB");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalB");

term = fmi2_import_get_terminal_by_name(xml, "terminalC");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalC");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalC");

term = fmi2_import_get_terminal_by_name(xml, "");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "");
}

SECTION("Testing edge cases of import functions; should not crash") {
REQUIRE(fmi2_import_get_terminal_by_name(xml, "terminalD") == nullptr); // terminal does not exists
REQUIRE(fmi2_import_get_terminal_by_name(nullptr, "terminalA") == nullptr); // NULL
REQUIRE(fmi2_import_get_terminal_by_name(xml, NULL) == nullptr); // NULL

REQUIRE(fmi3_import_get_terminal_name(nullptr) == nullptr);
REQUIRE(fmi_import_get_terminal_name(nullptr) == nullptr);
}

// TODO: Current example xml includes elements/attributes not yet parsed
Expand Down
12 changes: 6 additions & 6 deletions Test/FMI3/fmi3_import_terminals_and_icons_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ TEST_CASE("Test parse terminals and icons") {
// test the existing ones
term = fmi3_import_get_terminal_by_name(xml, "terminalA");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalA");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalA");

term = fmi3_import_get_terminal_by_name(xml, "terminalB");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalB");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalB");

term = fmi3_import_get_terminal_by_name(xml, "terminalC");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalC");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalC");

term = fmi3_import_get_terminal_by_name(xml, "");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "");
}

SECTION("Testing edge cases of import functions; should not crash") {
REQUIRE(fmi3_import_get_terminal_by_name(xml, "terminalD") == nullptr); // terminal does not exists
REQUIRE(fmi3_import_get_terminal_by_name(nullptr, "terminalA") == nullptr); // NULL
REQUIRE(fmi3_import_get_terminal_by_name(xml, NULL) == nullptr); // NULL

REQUIRE(fmi3_import_get_terminal_name(nullptr) == nullptr);
REQUIRE(fmi_import_get_terminal_name(nullptr) == nullptr);
}

// TODO: Current example xml includes elements/attributes not yet parsed
Expand Down Expand Up @@ -141,7 +141,7 @@ TEST_CASE("Test clearing of attribute buffer with invalid elements") {

fmi_import_terminal_t* term = fmi3_import_get_terminal_by_name(fmu, "terminalA");
REQUIRE(term != nullptr);
REQUIRE_STREQ(fmi3_import_get_terminal_name(term), "terminalA");
REQUIRE_STREQ(fmi_import_get_terminal_name(term), "terminalA");
// TODO: Check that optional attributes from Terminal without name are not present in this one

// TODO: Current example xml includes elements/attributes not yet parsed
Expand Down
1 change: 1 addition & 0 deletions src/Import/include/FMI/fmi_import_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ in \ref fmi1_import_capi, \ref fmi2_import_capi and \ref fmi3_import_capi.
\addtogroup fmi1_import
\addtogroup fmi2_import
\addtogroup fmi3_import
\addtogroup fmi_termicon_import
\addtogroup fmi_import_utils
@}
\addtogroup fmi_import_context
Expand Down
64 changes: 44 additions & 20 deletions src/Import/include/FMI/fmi_import_terminals_and_icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,53 @@
#include <FMI2/fmi2_import.h>
#include <FMI3/fmi3_import.h>

// TODO: Some functions are FMI2/3 specific, should these be in fmi2/3_....h files?

#ifdef __cplusplus
extern "C" {
#endif

/**
\addtogroup fmi_import_terminals_and_icons
\defgroup fmi_termicon_import FMI Terminals and Icons import interface
@{
\defgroup fmi_import_terminals_and_icons Handling of terminals and icons
\defgroup fmi_import_terminals_and_icons General Handling of Terminals and Icons
\addtogroup fmi_import_terminals_and_icons
\addtogroup fmi2_import_terminals_and_icons
\addtogroup fmi3_import_terminals_and_icons
@}
*/
*/

/**
\addtogroup fmi_import_terminals_and_icons
\brief Handling of terminals and icons.
\brief Common API for Terminals and Icons.
Functionality and API common to FMI 2 and FMI 3 import.
@{
*/
*/

/** \brief Opaque Terminal type */
typedef struct fmi_xml_terminal_t fmi_import_terminal_t;

/**
\brief Get the variable name
@param term An #fmi_import_terminal_t pointer
@return name
*/
FMILIB_EXPORT const char* fmi_import_get_terminal_name(fmi_import_terminal_t* term);

/** @} */

// TODO: Should one move the FMI 2/3 specific content to separate files?

/**
* \brief Returns non-zero if terminalsAndIcons.xml has been found and successfully parsed.
* @param fmu An #fmi2_import_t object as returned by #fmi2_import_parse_xml().
*/
FMILIB_EXPORT int fmi2_import_get_has_terminals_and_icons(fmi2_import_t* fmu);
\addtogroup fmi2_import_terminals_and_icons Terminals and Icons in FMI2
\brief FMI2 specific API for Terminals and Icons.
@{
*/

/**
* \brief Returns non-zero if terminalsAndIcons.xml has been found and successfully parsed.
* @param fmu An #fmi3_import_t object as returned by #fmi3_import_parse_xml().
* @param fmu An #fmi2_import_t object as returned by #fmi2_import_parse_xml().
*/
FMILIB_EXPORT int fmi3_import_get_has_terminals_and_icons(fmi3_import_t* fmu);
FMILIB_EXPORT int fmi2_import_get_has_terminals_and_icons(fmi2_import_t* fmu);

/**
\brief Get terminal by terminal name.
Expand All @@ -67,6 +81,22 @@ FMILIB_EXPORT int fmi3_import_get_has_terminals_and_icons(fmi3_import_t* fmu);
*/
FMILIB_EXPORT fmi_import_terminal_t* fmi2_import_get_terminal_by_name(fmi2_import_t* fmu, const char* name);

/** @} */



/**
\addtogroup fmi3_import_terminals_and_icons Terminals and Icons in FMI3
\brief FMI3 specific API for Terminals and Icons.
@{
*/

/**
* \brief Returns non-zero if terminalsAndIcons.xml has been found and successfully parsed.
* @param fmu An #fmi3_import_t object as returned by #fmi3_import_parse_xml().
*/
FMILIB_EXPORT int fmi3_import_get_has_terminals_and_icons(fmi3_import_t* fmu);

/**
\brief Get terminal by terminal name.
@param fmu An #fmi3_import_t object as returned by #fmi3_import_parse_xml().
Expand All @@ -75,15 +105,9 @@ FMILIB_EXPORT fmi_import_terminal_t* fmi2_import_get_terminal_by_name(fmi2_impor
*/
FMILIB_EXPORT fmi_import_terminal_t* fmi3_import_get_terminal_by_name(fmi3_import_t* fmu, const char* name);

/**
\brief Get the variable name
@param term An #fmi_import_terminal_t pointer
@return name
*/
FMILIB_EXPORT const char* fmi3_import_get_terminal_name(fmi_import_terminal_t* term);

/** @} */


#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/Import/include/FMI3/fmi3_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern "C" {
* @{
* \brief Convenient functions for calling the FMI functions. This interface wraps the "C" API.
* @}
* \addtogroup fmi3_import_options Functions for handling FMI Library options
* @}
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Import/src/FMI/fmi_import_terminals_and_icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ fmi_import_terminal_t* fmi3_import_get_terminal_by_name(fmi3_import_t* fmu, cons
return fmu ? fmi_xml_get_terminal_by_name(fmu->termIcon, name) : NULL;
}

const char* fmi3_import_get_terminal_name(fmi_import_terminal_t* term){
const char* fmi_import_get_terminal_name(fmi_import_terminal_t* term){
return term ? fmi_xml_get_terminal_name(term) : NULL;
}

0 comments on commit 69807f8

Please sign in to comment.