diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-11 01:12:11 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-11 01:12:11 +0200 |
commit | 6222973c39ee02ad52a5d0b4b400024157ff2eeb (patch) | |
tree | 08fff1571d6089dd7674166aac6e424a9826b4b3 /CAN-binder/low-can-binding/can | |
parent | d253ada94487232ccd33b68a69fd44ff7840fab7 (diff) |
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/can')
-rw-r--r-- | CAN-binder/low-can-binding/can/can-decoder.cpp | 16 | ||||
-rw-r--r-- | CAN-binder/low-can-binding/can/can-decoder.hpp | 14 | ||||
-rw-r--r-- | CAN-binder/low-can-binding/can/can-message-definition.cpp | 2 | ||||
-rw-r--r-- | CAN-binder/low-can-binding/can/can-message-set.cpp | 2 | ||||
-rw-r--r-- | CAN-binder/low-can-binding/can/can-signals.cpp | 6 | ||||
-rw-r--r-- | CAN-binder/low-can-binding/can/can-signals.hpp | 2 |
6 files changed, 21 insertions, 21 deletions
diff --git a/CAN-binder/low-can-binding/can/can-decoder.cpp b/CAN-binder/low-can-binding/can/can-decoder.cpp index 419eac1..eae4ef2 100644 --- a/CAN-binder/low-can-binding/can/can-decoder.cpp +++ b/CAN-binder/low-can-binding/can/can-decoder.cpp @@ -54,7 +54,7 @@ float decoder_t::parseSignalBitfield(can_signal_t& signal, const can_message_t& /// always succeeds. /// openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal, - const std::vector<can_signal_t>& signals, float value, bool* send) + const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send) { openxc_DynamicField decoded_value = build_DynamicField(value); @@ -76,7 +76,7 @@ openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal, /// decoder always succeeds. /// openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal, - const std::vector<can_signal_t>& signals, float value, bool* send) + const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send) { openxc_DynamicField decoded_value = build_DynamicField(value == 0.0 ? false : true); @@ -98,7 +98,7 @@ openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal, /// @return Return value is undefined. /// openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal, - const std::vector<can_signal_t>& signals, float value, bool* send) + const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send) { if(send) *send = false; @@ -125,7 +125,7 @@ openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal, /// return value is undefined. /// openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal, - const std::vector<can_signal_t>& signals, float value, bool* send) + const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send) { const std::string signal_state = signal.get_states((uint8_t)value); openxc_DynamicField decoded_value = build_DynamicField(signal_state); @@ -154,7 +154,7 @@ openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal, /// string or boolean. /// openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_message_t& message, - const std::vector<std::shared_ptr<can_signal_t> >& signals, bool* send) + const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send) { float value = decoder_t::parseSignalBitfield(signal, message); DEBUG(binder_interface, "%s: Decoded message from parseSignalBitfield: %f", __FUNCTION__, value); @@ -172,7 +172,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m *send = false; } signal.set_last_value(value); - signal.get_message().set_last_value(message); + signal.get_message()->set_last_value(message); return decoded_value; } @@ -192,7 +192,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m /// string or boolean. If 'send' is false, the return value is undefined. /// openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, - float value, const std::vector<can_signal_t>& signals, bool* send) + float value, const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send) { SignalDecoder decoder = signal.get_decoder() == nullptr ? noopDecoder : signal.get_decoder(); @@ -215,7 +215,7 @@ openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, /// not be decoded. /// openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, - const can_message_t& message, const std::vector<can_signal_t>& signals, bool* send) + const can_message_t& message, const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send) { float value = parseSignalBitfield(signal, message); return decodeSignal(signal, value, signals, send); diff --git a/CAN-binder/low-can-binding/can/can-decoder.hpp b/CAN-binder/low-can-binding/can/can-decoder.hpp index 1e7efc6..238bfea 100644 --- a/CAN-binder/low-can-binding/can/can-decoder.hpp +++ b/CAN-binder/low-can-binding/can/can-decoder.hpp @@ -26,23 +26,23 @@ class decoder_t public: static float parseSignalBitfield(can_signal_t& signal, const can_message_t& message); - static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals, + static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send); - static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals, + static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send); - static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals, + static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send); - static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector<can_signal_t>& signals, + static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send); static openxc_DynamicField translateSignal(can_signal_t& signal, const can_message_t& message, - const std::vector<std::shared_ptr<can_signal_t> >& signals, bool* send); + const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send); static openxc_DynamicField decodeSignal(can_signal_t& signal, const can_message_t& message, - const std::vector<can_signal_t>& signals, bool* send); + const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send); static openxc_DynamicField decodeSignal(can_signal_t& signal, float value, - const std::vector<can_signal_t>& signals, bool* send); + const std::vector<std::shared_ptr<can_signal_t> > signals, bool* send); static float decode_obd2_response(const DiagnosticResponse* response, float parsed_payload); diff --git a/CAN-binder/low-can-binding/can/can-message-definition.cpp b/CAN-binder/low-can-binding/can/can-message-definition.cpp index 18a07bb..e947026 100644 --- a/CAN-binder/low-can-binding/can/can-message-definition.cpp +++ b/CAN-binder/low-can-binding/can/can-message-definition.cpp @@ -67,7 +67,7 @@ can_message_definition_t::can_message_definition_t( { for(auto& sig: can_signals_) { - sig->set_parent(std::make_shared<can_signal_t>(this)); + sig->set_parent(std::make_shared<can_message_definition_t>(*this)); } } diff --git a/CAN-binder/low-can-binding/can/can-message-set.cpp b/CAN-binder/low-can-binding/can/can-message-set.cpp index 1877f3a..7ee2a01 100644 --- a/CAN-binder/low-can-binding/can/can-message-set.cpp +++ b/CAN-binder/low-can-binding/can/can-message-set.cpp @@ -38,7 +38,7 @@ can_message_set_t::can_message_set_t( { for(auto& cmd : can_messages_definition_) { - cmd->set_parent(std::make_shared<can_message_set_t>(this)); + cmd->set_parent(std::make_shared<can_message_set_t>(*this)); } } diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp index 96d0b70..04d328b 100644 --- a/CAN-binder/low-can-binding/can/can-signals.cpp +++ b/CAN-binder/low-can-binding/can/can-signals.cpp @@ -197,7 +197,7 @@ float can_signal_t::get_last_value() const void can_signal_t::set_parent(std::shared_ptr<can_message_definition_t> parent) { - parent_(parent); + parent_ = parent; } void can_signal_t::set_prefix(std::string val) @@ -223,9 +223,9 @@ int can_signal_t::create_rx_filter() // Make sure that socket has been opened. if(! socket_) socket_.open( - get_message().get_bus_name()); + get_message()->get_bus_name()); - uint32_t can_id = get_message().get_id(); + uint32_t can_id = get_message()->get_id(); struct utils::simple_bcm_msg bcm_msg; struct can_frame cfd; diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp index 6497a3c..4b726c3 100644 --- a/CAN-binder/low-can-binding/can/can-signals.hpp +++ b/CAN-binder/low-can-binding/can/can-signals.hpp @@ -57,7 +57,7 @@ class can_message_definition_t; /// @return a decoded value in an openxc_DynamicField struct. /// typedef openxc_DynamicField (*SignalDecoder)(can_signal_t& signal, - const std::vector<can_signal_t>& signals, float value, bool* send); + const std::vector<std::shared_ptr<can_signal_t> > signals, float value, bool* send); /// /// @brief: The type signature for a CAN signal encoder. |