From 6222973c39ee02ad52a5d0b4b400024157ff2eeb Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 11 May 2017 01:12:11 +0200 Subject: Massive use of shared_ptr about signal and diag message. WIP Vector of shared_ptr is made to shared ownership about object around project. This is the default returned value by getter methods when lookup and manipulating them. Change-Id: Id37947bb5994b629f4bf3faecc5ffac81c55e1e6 Signed-off-by: Romain Forlot --- .../binding/configuration-generated.cpp | 80 +++++++++++----------- .../low-can-binding/binding/configuration.cpp | 6 +- .../low-can-binding/binding/configuration.hpp | 6 +- CAN-binder/low-can-binding/binding/low-can-cb.cpp | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) (limited to 'CAN-binder/low-can-binding/binding') diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp index 3ab911a..d4778ba 100644 --- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp +++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp @@ -104,7 +104,7 @@ configuration_t::configuration_t() , diagnostic_messages_ { { - { + {std::make_shared(diagnostic_message_t{ 4, "engine.load", 0, @@ -114,8 +114,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 5, "engine.coolant.temperature", 0, @@ -125,8 +125,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 10, "fuel.pressure", 0, @@ -136,8 +136,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 11, "intake.manifold.pressure", 0, @@ -147,8 +147,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 12, "engine.speed", 0, @@ -158,8 +158,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 13, "vehicle.speed", 0, @@ -169,8 +169,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 15, "intake.air.temperature", 0, @@ -180,8 +180,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 16, "mass.airflow", 0, @@ -191,8 +191,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 17, "throttle.position", 0, @@ -202,8 +202,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 31, "running.time", 0, @@ -213,8 +213,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 45, "EGR.error", 0, @@ -224,8 +224,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 47, "fuel.level", 0, @@ -235,8 +235,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 51, "barometric.pressure", 0, @@ -246,8 +246,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 76, "commanded.throttle.position", 0, @@ -257,8 +257,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 82, "ethanol.fuel.percentage", 0, @@ -268,8 +268,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 90, "accelerator.pedal.position", 0, @@ -279,8 +279,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 91, "hybrid.battery-pack.remaining.life", 0, @@ -290,8 +290,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 92, "engine.oil.temperature", 0, @@ -301,8 +301,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 94, "engine.fuel.rate", 0, @@ -312,8 +312,8 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - }, - { + })}, + {std::make_shared(diagnostic_message_t{ 99, "engine.torque", 0, @@ -323,7 +323,7 @@ configuration_t::configuration_t() decoder_t::decode_obd2_response, nullptr, true - } + })} } } {} diff --git a/CAN-binder/low-can-binding/binding/configuration.cpp b/CAN-binder/low-can-binding/binding/configuration.cpp index da9d16b..005e662 100644 --- a/CAN-binder/low-can-binding/binding/configuration.cpp +++ b/CAN-binder/low-can-binding/binding/configuration.cpp @@ -57,7 +57,7 @@ std::vector > configuration_t::get_can_signals() return can_message_set_[active_message_set_].get_can_signals(); } -std::vector& configuration_t::get_diagnostic_messages() +std::vector > configuration_t::get_diagnostic_messages() { return diagnostic_messages_[active_message_set_]; } @@ -83,7 +83,7 @@ void configuration_t::set_active_message_set(uint8_t id) } -diagnostic_message_t* configuration_t::get_diagnostic_message(std::string message_name) const +std::shared_ptr configuration_t::get_diagnostic_message(std::string message_name) const { struct utils::signals_found found; found = utils::signals_manager_t::instance().find_signals(build_DynamicField(message_name)); @@ -94,7 +94,7 @@ diagnostic_message_t* configuration_t::get_diagnostic_message(std::string messag DiagnosticRequest* configuration_t::get_request_from_diagnostic_message(std::string message_name) const { - diagnostic_message_t* diag_msg = get_diagnostic_message(message_name); + std::shared_ptr diag_msg = get_diagnostic_message(message_name); if( diag_msg != nullptr && diag_msg->get_supported()) return new DiagnosticRequest(diag_msg->build_diagnostic_request()); return nullptr; diff --git a/CAN-binder/low-can-binding/binding/configuration.hpp b/CAN-binder/low-can-binding/binding/configuration.hpp index 4488164..2f1f4fc 100644 --- a/CAN-binder/low-can-binding/binding/configuration.hpp +++ b/CAN-binder/low-can-binding/binding/configuration.hpp @@ -50,7 +50,7 @@ class configuration_t std::vector can_message_set_; ///< Vector holding all message set from JSON signals description file //std::vector> can_message_definition_; ///< Vector of vector holding all can message definition from JSON signals description file. This describe a CAN message. First vector map to message set //std::vector> can_signals_; ///< Vector of vector holding all can signasl from JSON signals description file. A CAN signal is a part of a CAN message. First vector map to message set - std::vector> diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set + std::vector > > diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set configuration_t(); ///< Private constructor with implementation generated by the AGL generator. @@ -71,7 +71,7 @@ class configuration_t std::vector > get_can_signals(); - std::vector& get_diagnostic_messages(); + std::vector > get_diagnostic_messages(); const std::vector& get_signals_prefix() const; @@ -83,7 +83,7 @@ class configuration_t void set_active_message_set(uint8_t id); - diagnostic_message_t* get_diagnostic_message(std::string message_name) const; + std::shared_ptr get_diagnostic_message(std::string message_name) const; DiagnosticRequest* get_request_from_diagnostic_message(std::string message_name) const; /* /// TODO: implement this function as method into can_bus class diff --git a/CAN-binder/low-can-binding/binding/low-can-cb.cpp b/CAN-binder/low-can-binding/binding/low-can-cb.cpp index 2183893..eaa4fab 100644 --- a/CAN-binder/low-can-binding/binding/low-can-cb.cpp +++ b/CAN-binder/low-can-binding/binding/low-can-cb.cpp @@ -189,7 +189,7 @@ static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, return -1; } struct sd_event_source* e_source; - sd_event_add_io(afb_daemon_get_event_loop(binder_interface->daemon), &e_source, sig->get_socket().socket(), EPOLLIN, read, sig); + sd_event_add_io(afb_daemon_get_event_loop(binder_interface->daemon), &e_source, sig->get_socket().socket(), EPOLLIN, read, sig.get()); rets++; DEBUG(binder_interface, "%s: signal: %s subscribed", __FUNCTION__, sig->get_name().c_str()); } -- cgit 1.2.3-korg