summaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-14 15:09:57 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 14:40:41 +0100
commit9b17d0359dedbf92de95c1150f7e576d58e0331c (patch)
treef68a21b3674f772957c925c14abaf4cdea0dfcc8 /low-can-binding
parent7188915081966da4124a457da99354beefa7dbad (diff)
application: Add dedicated function to set parents
Bug-AGL: SPEC-2988 Change-Id: Iedd493b9e4043290dae0aa9d1d94a3d9179525ae Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/binding/application.cpp32
-rw-r--r--low-can-binding/binding/application.hpp1
2 files changed, 18 insertions, 15 deletions
diff --git a/low-can-binding/binding/application.cpp b/low-can-binding/binding/application.cpp
index c4da68ae..063a11da 100644
--- a/low-can-binding/binding/application.cpp
+++ b/low-can-binding/binding/application.cpp
@@ -54,25 +54,12 @@ uint8_t application_t::get_active_message_set() const
int application_t::add_message_set(std::shared_ptr<message_set_t> new_message_set)
{
-
- vect_ptr_msg_def_t messages_definition = new_message_set->get_messages_definition();
- for(std::shared_ptr<message_definition_t> cmd : messages_definition)
- {
- cmd->set_parent(new_message_set);
- std::vector<std::shared_ptr<signal_t>> signals = cmd->get_signals();
- for(std::shared_ptr<signal_t> sig: signals)
- sig->set_parent(cmd);
- }
-
- std::vector<std::shared_ptr<diagnostic_message_t>> diagnostic_messages = new_message_set->get_diagnostic_messages();
- for(std::shared_ptr<diagnostic_message_t> dm : diagnostic_messages)
- dm->set_parent(new_message_set);
+ set_parents(new_message_set);
for(auto old_msg_set : message_set_)
{
if(old_msg_set->get_index() == new_message_set->get_index())
{
-
for(auto new_msg_def : new_message_set->get_messages_definition())
{
if(old_msg_set->add_message_definition(new_msg_def) < 0)
@@ -84,7 +71,6 @@ int application_t::add_message_set(std::shared_ptr<message_set_t> new_message_se
if(old_msg_set->add_diagnostic_message(new_diag_msg) < 0)
return -1;
}
-
return 0;
}
}
@@ -196,6 +182,22 @@ bool application_t::is_engine_on()
return engine_on;
}
+void application_t::set_parents(std::shared_ptr<message_set_t> new_message_set)
+{
+ vect_ptr_msg_def_t messages_definition = new_message_set->get_messages_definition();
+ for(std::shared_ptr<message_definition_t> cmd : messages_definition)
+ {
+ cmd->set_parent(new_message_set);
+ std::vector<std::shared_ptr<signal_t>> signals = cmd->get_signals();
+ for(std::shared_ptr<signal_t> sig: signals)
+ sig->set_parent(cmd);
+ }
+
+ std::vector<std::shared_ptr<diagnostic_message_t>> diagnostic_messages = new_message_set->get_diagnostic_messages();
+ for(std::shared_ptr<diagnostic_message_t> dm : diagnostic_messages)
+ dm->set_parent(new_message_set);
+}
+
#ifdef USE_FEATURE_J1939
std::shared_ptr<utils::socketcan_t> application_t::get_socket_address_claiming()
{
diff --git a/low-can-binding/binding/application.hpp b/low-can-binding/binding/application.hpp
index 3438c6a4..c445c899 100644
--- a/low-can-binding/binding/application.hpp
+++ b/low-can-binding/binding/application.hpp
@@ -57,6 +57,7 @@ class application_t
//std::shared_ptr<utils::socketcan_j1939_addressclaiming_t> socket_address_claiming_;
#endif
application_t(); ///< Private constructor with implementation generated by the AGL generator.
+ void set_parents(std::shared_ptr<message_set_t> new_message_set);
public:
static application_t& instance();