Skip to content

Commit 1316deb

Browse files
committed
Merge branch 'master' into fmi3
2 parents a0ae2cd + 68408df commit 1316deb

6 files changed

Lines changed: 11 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ model_info fmu4cpp::get_model_info() {
9494
return info;
9595
}
9696

97-
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, const std::string &fmuResourceLocation) {
98-
return std::make_unique<BouncingBall>(instanceName, fmuResourceLocation);
99-
}
97+
FMU4CPP_INSTANTIATE(BouncingBall);
10098

10199
```
102100

export/examples/BouncingBall/bouncing_ball.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,4 @@ model_info fmu4cpp::get_model_info() {
9898
return info;
9999
}
100100

101-
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, const std::filesystem::path &fmuResourceLocation) {
102-
return std::make_unique<BouncingBall>(instanceName, fmuResourceLocation);
103-
}
101+
FMU4CPP_INSTANTIATE(BouncingBall);

export/examples/Resource/resource.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,4 @@ model_info fmu4cpp::get_model_info() {
4949
return info;
5050
}
5151

52-
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, const std::filesystem::path &fmuResourceLocation) {
53-
return std::make_unique<Resource>(instanceName, fmuResourceLocation);
54-
}
52+
FMU4CPP_INSTANTIATE(Resource);

export/examples/SimplePendulum/simple_pendulum.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,4 @@ model_info fmu4cpp::get_model_info() {
6868
return info;
6969
}
7070

71-
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, const std::filesystem::path &fmuResourceLocation) {
72-
return std::make_unique<SimplePendulum>(instanceName, fmuResourceLocation);
73-
}
71+
FMU4CPP_INSTANTIATE(SimplePendulum);

export/include/fmu4cpp/fmu_base.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
#include <filesystem>
1818

19+
#define FMU4CPP_INSTANTIATE(MODELCLASS) \
20+
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, \
21+
const std::filesystem::path &fmuResourceLocation) { \
22+
return std::make_unique<MODELCLASS>(instanceName, fmuResourceLocation); \
23+
}
24+
1925
namespace fmu4cpp {
2026

2127
class fmu_base {

src/model.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,4 @@ model_info fmu4cpp::get_model_info() {
8787
return info;
8888
}
8989

90-
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName,
91-
const std::filesystem::path &fmuResourceLocation) {
92-
return std::make_unique<Model>(instanceName, fmuResourceLocation);
93-
}
90+
FMU4CPP_INSTANTIATE(Model); // Entry point for FMI instantiate function.

0 commit comments

Comments
 (0)