Skip to content

Commit

Permalink
Adapt to changes in everest-framework
Browse files Browse the repository at this point in the history
Mappings are now included in Fulfillments not Requirements anymore

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass committed Oct 17, 2024
1 parent 10de40c commit 228de8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ev-dev-tools/src/ev_cli/templates/interface-Base.hpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public:
if (error_factory == nullptr) {
EVLOG_error << "error_factory is nullptr";
}
impl_mapping = ev->get_impl_mapping(name);
impl_mapping = Everest::get_impl_mapping(ev->get_mapping(), name);
}
}

Expand Down
8 changes: 5 additions & 3 deletions ev-dev-tools/src/ev_cli/templates/interface-Exports.hpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

class {{ info.class_name }} {
public:
{{ info.class_name }}(Everest::ModuleAdapter* adapter, Requirement req, const std::string& module_id)
{{ info.class_name }}(Everest::ModuleAdapter* adapter, Requirement req, const std::string& module_id, std::optional<Mapping> mapping)
: module_id(module_id),
_adapter(adapter),
_req(req) {
_req(req),
_mapping(mapping) {
if (adapter == nullptr) {
EVLOG_error << "adapter is nullptr, please check the initialization of the module";
error_manager = nullptr;
Expand Down Expand Up @@ -146,13 +147,14 @@ public:
std::shared_ptr<Everest::error::ErrorStateMonitor> error_state_monitor;

std::optional<Mapping> get_mapping() {
return _req.mapping;
return _mapping;
}

private:
std::shared_ptr<Everest::error::ErrorManagerReq> error_manager;
Everest::ModuleAdapter* const _adapter;
Requirement _req;
std::optional<Mapping> _mapping;
};

#endif // {{ info.hpp_guard }}
7 changes: 5 additions & 2 deletions ev-dev-tools/src/ev_cli/templates/ld-ev.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,23 @@ std::vector<Everest::cmd> everest_register(const std::map<std::string, std::vect
for (size_t idx = 0; idx < fulfillment.size(); idx++) {
auto requirement_module_id = fulfillment.at(idx).module_id;
auto requirement = fulfillment.at(idx).requirement;
r_{{ requirement.id }}.emplace_back(std::make_unique<{{ requirement.class_name }}>(&adapter, requirement, requirement_module_id));
auto mapping = fulfillment.at(idx).mapping;
r_{{ requirement.id }}.emplace_back(std::make_unique<{{ requirement.class_name }}>(&adapter, requirement, requirement_module_id, mapping));
}
}
{% else %}
std::string r_{{ requirement.id }}_requirement_module_id;
Requirement r_{{ requirement.id }}_requirement;
std::optional<Mapping> r_{{ requirement.id }}_mapping;
if (fulfillments.find("{{ requirement.id }}") != fulfillments.end()) {
auto fulfillment = fulfillments.at("{{ requirement.id }}");
if (fulfillment.size() > 0) {
r_{{ requirement.id }}_requirement_module_id = fulfillment.at(0).module_id;
r_{{ requirement.id }}_requirement = fulfillment.at(0).requirement;
r_{{ requirement.id }}_mapping = fulfillment.at(0).mapping;
}
}
auto r_{{ requirement.id }} = std::make_unique<{{ requirement.class_name }}>(&adapter, r_{{ requirement.id }}_requirement, r_{{ requirement.id }}_requirement_module_id);
auto r_{{ requirement.id }} = std::make_unique<{{ requirement.class_name }}>(&adapter, r_{{ requirement.id }}_requirement, r_{{ requirement.id }}_requirement_module_id, r_{{ requirement.id }}_mapping);
{% endif %}
{% else %}
(void) fulfillments; // no requirements -> unused fulfillments
Expand Down

0 comments on commit 228de8f

Please sign in to comment.