-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides unit structure definitions and supports XML content parsing…
… for these units. (#156) Co-authored-by: Wenweil1 <[email protected]>
- Loading branch information
1 parent
2aea2f5
commit 2319123
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* File Name: unit_definitions.h | ||
* Description: Defines structures for handling physical units and their conversions, including base units, display units, and unit definitions. | ||
* Author: weilong.wen | ||
* Email: [email protected] | ||
* Created: 2025-02-03 | ||
*/ | ||
|
||
#ifndef FMI4CPP_UNITDEFINITIONS_HPP | ||
#define FMI4CPP_UNITDEFINITIONS_HPP | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace fmi4cpp::fmi2 | ||
{ | ||
|
||
struct base_unit | ||
{ | ||
std::optional<int> kg = 0; | ||
std::optional<int> m = 0; | ||
std::optional<int> s = 0; | ||
std::optional<int> A = 0; | ||
std::optional<int> K = 0; | ||
std::optional<int> mol = 0; | ||
std::optional<int> cd = 0; | ||
std::optional<int> rad = 0; | ||
std::optional<double> factor = 1.0; | ||
std::optional<double> offset = 0.0; | ||
}; | ||
|
||
struct display_unit | ||
{ | ||
std::string name; | ||
double factor = 1.0; | ||
double offset = 0.0; | ||
}; | ||
|
||
struct unit | ||
{ | ||
std::string name; | ||
base_unit base_unit; | ||
std::vector<display_unit> display_units; | ||
}; | ||
|
||
struct unit_definitions | ||
{ | ||
std::vector<unit> units; | ||
}; | ||
|
||
} // namespace fmi4cpp::fmi2 | ||
|
||
#endif // FMI4CPP_UNITDEFINITIONS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters