diff --git a/score/mw/com/impl/bindings/lola/BUILD b/score/mw/com/impl/bindings/lola/BUILD index 0b8ae1b55..bef169f46 100644 --- a/score/mw/com/impl/bindings/lola/BUILD +++ b/score/mw/com/impl/bindings/lola/BUILD @@ -236,7 +236,6 @@ cc_library( ":application_id_pid_mapping", ":element_fq_id", ":event_control", - ":event_meta_info", "@score_baselibs//score/memory/shared", ], ) @@ -264,6 +263,33 @@ cc_library( ], ) +cc_library( + name = "skeleton_service_data_control_local_view", + srcs = ["skeleton_service_data_control_local_view.cpp"], + hdrs = ["skeleton_service_data_control_local_view.h"], + features = COMPILER_WARNING_FEATURES, + tags = ["FFI"], + deps = [ + ":element_fq_id", + ":service_data_control", + ":skeleton_event_control_local_view", + ], +) + +cc_library( + name = "proxy_service_data_control_local_view", + srcs = ["proxy_service_data_control_local_view.cpp"], + hdrs = ["proxy_service_data_control_local_view.h"], + features = COMPILER_WARNING_FEATURES, + tags = ["FFI"], + deps = [ + ":application_id_pid_mapping", + ":element_fq_id", + ":proxy_event_control_local_view", + ":service_data_control", + ], +) + cc_library( name = "skeleton", srcs = [ @@ -292,10 +318,12 @@ cc_library( ":i_shm_path_builder", ":partial_restart_path_builder", ":proxy_instance_identifier", + ":proxy_service_data_control_local_view", ":service_data_control", ":service_data_storage", ":shm_path_builder", ":skeleton_instance_identifier", + ":skeleton_service_data_control_local_view", ":transaction_log_registration_guard", ":type_erased_sample_ptrs_guard", "//score/mw/com/impl:error", @@ -350,7 +378,9 @@ cc_library( ":event", ":event_control", ":event_subscription_control", + ":proxy_event_control_local_view", ":proxy_instance_identifier", + ":proxy_service_data_control_local_view", ":service_data_control", ":service_data_storage", ":shm_path_builder", @@ -420,7 +450,7 @@ cc_library( "//score/mw/com/impl:__subpackages__", ], deps = [ - ":event_data_control", + ":proxy_event_data_control_local_view", ":slot_decrementer", ], ) @@ -435,7 +465,7 @@ cc_library( "//score/mw/com/impl:__subpackages__", ], deps = [ - ":event_data_control", + ":proxy_event_data_control_local_view", ":transaction_log_set", ], ) @@ -463,9 +493,9 @@ cc_library( features = COMPILER_WARNING_FEATURES, tags = ["FFI"], deps = [ - ":event_control", - ":event_data_control", ":i_runtime", + ":proxy_event_control_local_view", + ":proxy_event_data_control_local_view", ":slot_collector", ":transaction_log_id", ":transaction_log_registration_guard", @@ -482,8 +512,8 @@ cc_library( features = COMPILER_WARNING_FEATURES, tags = ["FFI"], deps = [ - ":event_data_control", ":event_slot_status", + ":proxy_event_data_control_local_view", ":transaction_log_set", ], ) @@ -530,42 +560,53 @@ cc_library( ) cc_library( - name = "control_slot_indicator", - srcs = [ - "control_slot_composite_indicator.cpp", - "control_slot_indicator.cpp", - ], - hdrs = [ - "control_slot_composite_indicator.h", - "control_slot_indicator.h", + name = "event_data_control", + srcs = ["event_data_control.cpp"], + hdrs = ["event_data_control.h"], + features = COMPILER_WARNING_FEATURES, + tags = ["FFI"], + visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], + deps = [ + ":control_slot_types", + ":event_slot_status", + ":transaction_log", + ":transaction_log_id", + ":transaction_log_set", + "@score_baselibs//score/containers:dynamic_array", + "@score_baselibs//score/memory/shared:atomic_indirector", + "@score_baselibs//score/memory/shared:types", ], +) + +cc_library( + name = "skeleton_event_data_control_local_view", + srcs = ["skeleton_event_data_control_local_view.cpp"], + hdrs = ["skeleton_event_data_control_local_view.h"], features = COMPILER_WARNING_FEATURES, tags = ["FFI"], visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], deps = [ ":control_slot_types", + ":event_data_control", ":event_slot_status", - "@score_baselibs//score/language/futurecpp", + ":transaction_log_set", + "@score_baselibs//score/memory/shared:atomic_indirector", ], ) cc_library( - name = "event_data_control", - srcs = ["event_data_control.cpp"], - hdrs = ["event_data_control.h"], + name = "proxy_event_data_control_local_view", + srcs = ["proxy_event_data_control_local_view.cpp"], + hdrs = ["proxy_event_data_control_local_view.h"], features = COMPILER_WARNING_FEATURES, tags = ["FFI"], visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], deps = [ - ":control_slot_indicator", ":control_slot_types", + ":event_data_control", ":event_slot_status", - ":transaction_log", - ":transaction_log_id", ":transaction_log_set", - "@score_baselibs//score/containers:dynamic_array", "@score_baselibs//score/memory/shared:atomic_indirector", - "@score_baselibs//score/memory/shared:types", ], ) @@ -597,6 +638,33 @@ cc_library( ], ) +cc_library( + name = "skeleton_event_control_local_view", + srcs = ["skeleton_event_control_local_view.cpp"], + hdrs = ["skeleton_event_control_local_view.h"], + features = COMPILER_WARNING_FEATURES, + tags = ["FFI"], + visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], + deps = [ + ":event_control", + ":skeleton_event_data_control_local_view", + ], +) + +cc_library( + name = "proxy_event_control_local_view", + srcs = ["proxy_event_control_local_view.cpp"], + hdrs = ["proxy_event_control_local_view.h"], + features = COMPILER_WARNING_FEATURES, + tags = ["FFI"], + visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], + deps = [ + ":event_control", + ":event_data_control", + ":proxy_event_data_control_local_view", + ], +) + cc_library( name = "event_subscription_control", srcs = ["event_subscription_control.cpp"], @@ -638,6 +706,8 @@ cc_library( ":control_slot_types", ":event_data_control", ":event_slot_status", + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", "@score_baselibs//score/memory/shared:atomic_indirector", ], ) @@ -751,7 +821,7 @@ cc_library( tags = ["FFI"], visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], deps = [ - ":service_data_control", + ":proxy_service_data_control_local_view", ":transaction_log_id", ":transaction_log_set", "//score/mw/com/impl:runtime", @@ -773,8 +843,10 @@ cc_library( tags = ["FFI"], visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"], deps = [ - ":event_data_control", + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", ":transaction_log_id", + ":transaction_log_set", "@score_baselibs//score/result", ], ) @@ -943,28 +1015,58 @@ cc_unit_test( ], ) -cc_test( +cc_gtest_unit_test( name = "event_data_control_test", + srcs = ["event_data_control_test.cpp"], + features = COMPILER_WARNING_FEATURES, + deps = [ + ":event_data_control", + ":event_slot_status", + "@score_baselibs//score/containers:dynamic_array", + ], +) + +cc_test( + name = "skeleton_event_data_control_local_view_test", size = "small", timeout = "long", srcs = [ - "event_data_control_test.cpp", + "skeleton_event_data_control_local_view_test.cpp", ], features = COMPILER_WARNING_FEATURES + [ "aborts_upon_exception", ], tags = ["unit"], deps = [ - "//score/mw/com/impl:instance_specifier", + ":skeleton_event_data_control_local_view", + "//score/mw/com/impl/bindings/lola:event_data_control", + "//score/mw/com/impl/bindings/lola:event_slot_status", + "//score/mw/com/impl/bindings/lola/test_doubles:fake_memory_resource", + "@googletest//:gtest_main", + "@score_baselibs//score/language/safecpp/coverage_termination_handler", + "@score_baselibs//score/memory/shared:atomic_indirector_mock_binding", + ], +) + +cc_test( + name = "proxy_event_data_control_local_view_test", + size = "small", + timeout = "long", + srcs = [ + "proxy_event_data_control_local_view_test.cpp", + ], + features = COMPILER_WARNING_FEATURES + [ + "aborts_upon_exception", + ], + tags = ["unit"], + deps = [ + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", "//score/mw/com/impl/bindings/lola:event_data_control", - "//score/mw/com/impl/bindings/lola:event_data_control_composite", "//score/mw/com/impl/bindings/lola/test_doubles:fake_memory_resource", "@googletest//:gtest_main", - "@score_baselibs//score/containers:dynamic_array", - "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/language/safecpp/coverage_termination_handler", "@score_baselibs//score/memory/shared:atomic_indirector_mock_binding", - "@score_baselibs//score/memory/shared:new_delete_delegate_resource", ], ) @@ -973,6 +1075,8 @@ cc_gtest_unit_test( srcs = ["event_data_control_composite_test.cpp"], features = COMPILER_WARNING_FEATURES, deps = [ + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", "//score/mw/com/impl:instance_specifier", "//score/mw/com/impl/bindings/lola:event_data_control", "//score/mw/com/impl/bindings/lola:event_data_control_composite", @@ -1082,6 +1186,8 @@ cc_gtest_unit_test( features = COMPILER_WARNING_FEATURES, deps = [ ":event_data_control", + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", ":slot_decrementer", "//score/mw/com/impl/bindings/lola/test_doubles:fake_memory_resource", ], @@ -1105,28 +1211,6 @@ cc_gtest_unit_test( ], ) -cc_gtest_unit_test( - name = "control_slot_composite_indicator_test", - srcs = [ - "control_slot_composite_indicator_test.cpp", - ], - features = COMPILER_WARNING_FEATURES, - deps = [ - ":control_slot_indicator", - ], -) - -cc_gtest_unit_test( - name = "control_slot_indicator_test", - srcs = [ - "control_slot_indicator_test.cpp", - ], - features = COMPILER_WARNING_FEATURES, - deps = [ - ":control_slot_indicator", - ], -) - cc_gtest_unit_test( name = "element_fq_id_test", srcs = [ @@ -1275,6 +1359,8 @@ cc_gtest_unit_test( ], features = COMPILER_WARNING_FEATURES, deps = [ + ":proxy_event_data_control_local_view", + ":skeleton_event_data_control_local_view", ":slot_collector", "//score/mw/com/impl/bindings/lola/test_doubles", ], @@ -1421,8 +1507,6 @@ cc_unit_test( cc_unit_test_suites_for_host_and_qnx( name = "unit_test_suite", cc_unit_tests = [ - ":control_slot_composite_indicator_test", - ":control_slot_indicator_test", ":element_fq_id_test", ":event_data_storage_test", ":event_slot_status_test", @@ -1447,6 +1531,8 @@ cc_unit_test_suites_for_host_and_qnx( ":dynamic_array_bounds_checking_test", ":event_data_control_test", ":event_data_control_composite_test", + ":proxy_event_data_control_local_view_test", + ":skeleton_event_data_control_local_view_test", ":generic_proxy_event_test", ":partial_restart_path_builder_test", ":proxy_instance_identifier_test", diff --git a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.cpp b/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.cpp deleted file mode 100644 index c43ca995a..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#include "score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h" - -#include - -namespace score::mw::com::impl::lola -{ - -// Suppress "AUTOSAR C++14 A12-1-5" rule finding. This rule declares: "Common class initialization for non-constant -// members shall be done by a delegating constructor.". -// Here we can not delegate to the 2nd ctor as it needs VALID references forControlSlotType args! -// coverity[autosar_cpp14_a12_1_5_violation] -ControlSlotCompositeIndicator::ControlSlotCompositeIndicator() noexcept - : slot_index_{0U}, slot_pointer_qm_{nullptr}, slot_pointer_asil_b_{nullptr} -{ -} - -ControlSlotCompositeIndicator::ControlSlotCompositeIndicator(SlotIndexType slot_index, - ControlSlotType& slot_qm, - ControlSlotType& slot_asil_b) - : slot_index_{slot_index}, slot_pointer_qm_{&slot_qm}, slot_pointer_asil_b_{&slot_asil_b} -{ -} - -ControlSlotCompositeIndicator::ControlSlotCompositeIndicator(SlotIndexType slot_index, - ControlSlotType& slot, - CompositeSlotTagType type) - : slot_index_{slot_index}, - slot_pointer_qm_{type == CompositeSlotTagType::QM ? &slot : nullptr}, - slot_pointer_asil_b_{type == CompositeSlotTagType::ASIL_B ? &slot : nullptr} -{ -} - -bool ControlSlotCompositeIndicator::IsValidQmAndAsilB() const -{ - return ((slot_pointer_qm_ != nullptr) && (slot_pointer_asil_b_ != nullptr)); -} - -bool ControlSlotCompositeIndicator::IsValidQM() const -{ - return (slot_pointer_qm_ != nullptr); -} - -bool ControlSlotCompositeIndicator::IsValidAsilB() const -{ - return (slot_pointer_asil_b_ != nullptr); -} - -SlotIndexType ControlSlotCompositeIndicator::GetIndex() const -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD((slot_pointer_qm_ != nullptr) || (slot_pointer_asil_b_ != nullptr)); - return slot_index_; -} - -ControlSlotType& ControlSlotCompositeIndicator::GetSlotQM() -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_qm_ != nullptr); - return *slot_pointer_qm_; -} - -const ControlSlotType& ControlSlotCompositeIndicator::GetSlotQM() const -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_qm_ != nullptr); - return *slot_pointer_qm_; -} - -ControlSlotType& ControlSlotCompositeIndicator::GetSlotAsilB() -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_asil_b_ != nullptr); - return *slot_pointer_asil_b_; -} - -const ControlSlotType& ControlSlotCompositeIndicator::GetSlotAsilB() const -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_asil_b_ != nullptr); - return *slot_pointer_asil_b_; -} - -void ControlSlotCompositeIndicator::Reset() -{ - slot_pointer_qm_ = nullptr; - slot_pointer_asil_b_ = nullptr; -} - -bool operator==(const ControlSlotCompositeIndicator& lhs, const ControlSlotCompositeIndicator& rhs) noexcept -{ - // Suppress "AUTOSAR C++14 A5-2-6" rule finding. This rule states:"The operands of a logical && or \\ shall be - // parenthesized if the operands contain binary operators". - // This a false-positive, all operands are parenthesized. - // A bug ticket has been created to track this: [Ticket-165315](broken_link_j/Ticket-165315) - // coverity[autosar_cpp14_a5_2_6_violation : FALSE] - return (lhs.IsValidQM() == rhs.IsValidQM()) && (lhs.IsValidAsilB() == rhs.IsValidAsilB()) && - ((lhs.IsValidQM() == false) || (lhs.GetIndex() == rhs.GetIndex())) && - ((lhs.IsValidQM() == false) || (&(lhs.GetSlotQM()) == &(rhs.GetSlotQM()))) && - ((lhs.IsValidAsilB() == false) || (&(lhs.GetSlotAsilB()) == &(rhs.GetSlotAsilB()))); -} - -} // namespace score::mw::com::impl::lola diff --git a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h b/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h deleted file mode 100644 index b9817e951..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#ifndef SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_COMPOSITE_INDICATOR_H -#define SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_COMPOSITE_INDICATOR_H - -#include "score/mw/com/impl/bindings/lola/control_slot_types.h" -#include "score/mw/com/impl/bindings/lola/event_slot_status.h" - -#include -#include - -namespace score::mw::com::impl::lola -{ - -/// \brief Helper class (similar to ControlSlotIndicator), which identifies a slot in our "control slot array" using -/// both the slot index and a raw pointer to the element. -/// \details Opposed to ControlSlotIndicator, this is an slot indicator for QM slots AND ASIL-B slots! Normally such a -/// ControlSlotCompositeIndicator returned e.g. by a slot allocation for an event/field supporting QM and -/// ASIL-B contains a slot-pointer for a QM slot and an ASIL-B slot. If the underlying event/field just has -/// QM support only a valid slot-pointer for QM is contained. In case only a ASIL-B slot pointer is contained -/// (#IsValidAsilB() = true), but no QM slot pointer is contained (#IsValidQM() = false), then we have the -/// case, where QM consumers have been disconnected and the composite is falling back to ASIL-B only. -class ControlSlotCompositeIndicator -{ - public: - enum class CompositeSlotTagType : std::uint8_t - { - QM, - ASIL_B - }; - ControlSlotCompositeIndicator() noexcept; - - ControlSlotCompositeIndicator(SlotIndexType slot_index, ControlSlotType& slot_qm, ControlSlotType& slot_asil_b); - - ControlSlotCompositeIndicator(SlotIndexType slot_index, ControlSlotType& slot, CompositeSlotTagType type); - - bool IsValidQmAndAsilB() const; - - bool IsValidQM() const; - - bool IsValidAsilB() const; - - SlotIndexType GetIndex() const; - - ControlSlotType& GetSlotQM(); - - const ControlSlotType& GetSlotQM() const; - - ControlSlotType& GetSlotAsilB(); - - const ControlSlotType& GetSlotAsilB() const; - - void Reset(); - - private: - SlotIndexType slot_index_; - ControlSlotType* slot_pointer_qm_; - ControlSlotType* slot_pointer_asil_b_; -}; - -bool operator==(const ControlSlotCompositeIndicator& lhs, const ControlSlotCompositeIndicator& rhs) noexcept; - -} // namespace score::mw::com::impl::lola - -#endif // SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_COMPOSITE_INDICATOR_H diff --git a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator_test.cpp b/score/mw/com/impl/bindings/lola/control_slot_composite_indicator_test.cpp deleted file mode 100644 index 1839675c0..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_composite_indicator_test.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#include "score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h" -#include - -#include - -namespace score::mw::com::impl::lola -{ -namespace -{ - -TEST(ControlSlotCompositeIndicator, Creation_Default) -{ - // given a default constructed ControlSlotIndicator - ControlSlotCompositeIndicator unit{}; - - // expect it to be completely invalid - EXPECT_FALSE(unit.IsValidQM()); - EXPECT_FALSE(unit.IsValidAsilB()); - EXPECT_FALSE(unit.IsValidQmAndAsilB()); -} - -TEST(ControlSlotCompositeIndicator, Creation_ValidQM) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, ControlSlotCompositeIndicator::CompositeSlotTagType::QM}; - - // expect QM to be valid - EXPECT_TRUE(unit.IsValidQM()); - // but ASIL-B not - EXPECT_FALSE(unit.IsValidAsilB()); - EXPECT_FALSE(unit.IsValidQmAndAsilB()); -} - -TEST(ControlSlotCompositeIndicator, Creation_ValidAsilB) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{ - slot_index, slot_asilb, ControlSlotCompositeIndicator::CompositeSlotTagType::ASIL_B}; - - // expect ASIL-B to be valid - EXPECT_TRUE(unit.IsValidAsilB()); - // but QM not - EXPECT_FALSE(unit.IsValidQM()); - EXPECT_FALSE(unit.IsValidQmAndAsilB()); -} - -TEST(ControlSlotCompositeIndicator, Creation_ValidQmAndAsilB) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_asilb{27U}; - ControlSlotType slot_qm{28U}; - // given a ControlSlotCompositeIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // expect ASIL-B and QM to be valid - EXPECT_TRUE(unit.IsValidAsilB()); - EXPECT_TRUE(unit.IsValidQM()); - EXPECT_TRUE(unit.IsValidQmAndAsilB()); -} - -TEST(ControlSlotCompositeIndicator, GetSlotQM) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, ControlSlotCompositeIndicator::CompositeSlotTagType::QM}; - - // expect slot being accessible and containing expected value - EXPECT_EQ(unit.GetSlotQM(), 27U); -} - -TEST(ControlSlotCompositeIndicator, GetSlotAsilB) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{ - slot_index, slot_asilb, ControlSlotCompositeIndicator::CompositeSlotTagType::ASIL_B}; - - // expect slot being accessible and containing expected value - EXPECT_EQ(unit.GetSlotAsilB(), 27U); -} - -TEST(ControlSlotCompositeIndicator, GetIndex_QmOnly) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot for QM - ControlSlotCompositeIndicator unit{slot_index, slot_qm, ControlSlotCompositeIndicator::CompositeSlotTagType::QM}; - - // expect index being accessible and containing expected value - EXPECT_EQ(unit.GetIndex(), slot_index); -} - -TEST(ControlSlotCompositeIndicator, GetIndex_AsilBOnly) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotCompositeIndicator created with a given index/slot for ASIL-B - ControlSlotCompositeIndicator unit{ - slot_index, slot_asilb, ControlSlotCompositeIndicator::CompositeSlotTagType::ASIL_B}; - - // expect index being accessible and containing expected value - EXPECT_EQ(unit.GetIndex(), slot_index); -} - -TEST(ControlSlotCompositeIndicator, Copy) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // and a copy from it - ControlSlotCompositeIndicator unit2{unit}; - - // expect the members of both being equal - EXPECT_EQ(unit.GetIndex(), unit2.GetIndex()); - EXPECT_EQ(unit.GetSlotQM(), unit2.GetSlotQM()); - EXPECT_EQ(unit.GetSlotAsilB(), unit2.GetSlotAsilB()); -} - -TEST(ControlSlotCompositeIndicator, Equal) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // and a copy from it - ControlSlotCompositeIndicator unit2{unit}; - - // expect both comparing equal - EXPECT_EQ(unit, unit2); -} - -TEST(ControlSlotCompositeIndicator, NotEqual) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // and a 2nd unit with a different qm-slot - ControlSlotType slot_qm2{27U}; - ControlSlotCompositeIndicator unit2{slot_index, slot_qm2, slot_asilb}; - - // expect both NOT comparing equal - EXPECT_FALSE(unit == unit2); -} - -TEST(ControlSlotCompositeIndicator, Reset) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // when calling Reset() - unit.Reset(); - - // expect, that the unit is invalid - EXPECT_FALSE(unit.IsValidQM()); - EXPECT_FALSE(unit.IsValidAsilB()); -} - -TEST(ControlSlotCompositeIndicatorDeathTest, QmSlotAccessDies) -{ - // given a default constructed ControlSlotCompositeIndicator - ControlSlotCompositeIndicator unit{}; - - // expect it to die, when accessing the qm-slot - EXPECT_DEATH(unit.GetSlotQM(), ".*"); -} - -TEST(ControlSlotCompositeIndicatorDeathTest, AsilBSlotAccessDies) -{ - // given a default constructed ControlSlotCompositeIndicator - ControlSlotCompositeIndicator unit{}; - - // expect it to die, when accessing the asil-b slot - EXPECT_DEATH(unit.GetSlotAsilB(), ".*"); -} - -TEST(ControlSlotCompositeIndicatorDeathTest, IndexAccessDies) -{ - // given a default constructed ControlSlotCompositeIndicator - ControlSlotCompositeIndicator unit{}; - - // expect it to die, when accessing the index - EXPECT_DEATH(unit.GetIndex(), ".*"); -} - -TEST(ControlSlotCompositeIndicatorDeathTest, IndexAccessAfterResetDies) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // when calling Reset() - unit.Reset(); - - // expect it to die, when accessing the index afterwards - EXPECT_DEATH(unit.GetIndex(), ".*"); -} - -TEST(ControlSlotCompositeIndicatorDeathTest, SlotAccessAfterResetDies) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot_qm{27U}; - ControlSlotType slot_asilb{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotCompositeIndicator unit{slot_index, slot_qm, slot_asilb}; - - // when calling Reset() - unit.Reset(); - - // expect it to die, when accessing a slot afterwards - EXPECT_DEATH(unit.GetSlotQM(), ".*"); -} - -} // namespace -} // namespace score::mw::com::impl::lola diff --git a/score/mw/com/impl/bindings/lola/control_slot_indicator.cpp b/score/mw/com/impl/bindings/lola/control_slot_indicator.cpp deleted file mode 100644 index 2cc25bae6..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_indicator.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#include "score/mw/com/impl/bindings/lola/control_slot_indicator.h" - -#include - -namespace score::mw::com::impl::lola -{ -// Suppress "AUTOSAR C++14 A12-1-5" rule finding. This rule declares: "Common class initialization for non-constant -// members shall be done by a delegating constructor.". -// Here we can not delegate to the 2nd ctor as it needs VALID reference for ControlSlotType! -// coverity[autosar_cpp14_a12_1_5_violation] -ControlSlotIndicator::ControlSlotIndicator() : slot_index_{0U}, slot_pointer_{nullptr} {} - -ControlSlotIndicator::ControlSlotIndicator(SlotIndexType slot_index, ControlSlotType& slot) - : slot_index_{slot_index}, slot_pointer_{&slot} -{ -} - -bool ControlSlotIndicator::IsValid() const -{ - return (slot_pointer_ != nullptr); -} - -SlotIndexType ControlSlotIndicator::GetIndex() const -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_ != nullptr); - return slot_index_; -} - -ControlSlotType& ControlSlotIndicator::GetSlot() -{ - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(slot_pointer_ != nullptr); - return *slot_pointer_; -} - -void ControlSlotIndicator::Reset() -{ - slot_pointer_ = nullptr; -} - -} // namespace score::mw::com::impl::lola diff --git a/score/mw/com/impl/bindings/lola/control_slot_indicator.h b/score/mw/com/impl/bindings/lola/control_slot_indicator.h deleted file mode 100644 index b67141660..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_indicator.h +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#ifndef SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_INDICATOR_H -#define SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_INDICATOR_H - -#include "score/mw/com/impl/bindings/lola/control_slot_types.h" -#include "score/mw/com/impl/bindings/lola/event_slot_status.h" - -#include -#include - -namespace score::mw::com::impl::lola -{ - -/// \brief Helper class which identifies a slot in our "control slot array" using both the slot index and a raw pointer -/// to the element. -/// \details We combine identification by the index of the slot and a (raw) pointer to the slot. Reasoning: -/// Sometimes the index is more appropriate - as we have a 1:1 relation between slot indices in DATA and -/// CONTROL arrays. But the slot access via index might be not as efficient! (Hint: DynamicArrays based -/// on OffsetPtr, which represent our "control slot array", will give you the penalty of bounds-checking, when -/// doing index based access). If the access can be performance critical, the access via the raw-pointer is -/// preferred (and if its safe as the slot has been already bounds-checked. -class ControlSlotIndicator -{ - public: - ControlSlotIndicator(); - - ControlSlotIndicator(SlotIndexType slot_index, ControlSlotType& slot); - - bool IsValid() const; - - SlotIndexType GetIndex() const; - - ControlSlotType& GetSlot(); - - void Reset(); - - private: - SlotIndexType slot_index_; - ControlSlotType* slot_pointer_; -}; - -} // namespace score::mw::com::impl::lola - -#endif // SCORE_MW_COM_IMPL_BINDINGS_LOLA_SLOT_INDICATOR_H diff --git a/score/mw/com/impl/bindings/lola/control_slot_indicator_test.cpp b/score/mw/com/impl/bindings/lola/control_slot_indicator_test.cpp deleted file mode 100644 index 82a135b24..000000000 --- a/score/mw/com/impl/bindings/lola/control_slot_indicator_test.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -#include "score/mw/com/impl/bindings/lola/control_slot_indicator.h" -#include - -#include - -namespace score::mw::com::impl::lola -{ -namespace -{ - -TEST(ControlSlotIndicator, Creation_Default) -{ - // given a default constructed ControlSlotIndicator - ControlSlotIndicator unit{}; - - // expect it to be invalid - EXPECT_FALSE(unit.IsValid()); -} - -TEST(ControlSlotIndicator, Creation_Valid) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotIndicator unit{slot_index, slot}; - - // expect it to be valid - EXPECT_TRUE(unit.IsValid()); -} - -TEST(ControlSlotIndicator, GetSlot) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotIndicator unit{slot_index, slot}; - - // expect slot being accessible and containing expected value - EXPECT_EQ(unit.GetSlot(), 27U); -} - -TEST(ControlSlotIndicator, GetIndex) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotIndicator unit{slot_index, slot}; - - // expect it to be valid - EXPECT_EQ(unit.GetIndex(), 42U); -} - -TEST(ControlSlotIndicator, Copy) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotIndicator unit{slot_index, slot}; - - // and a copy from it - ControlSlotIndicator unit2{unit}; - - // expect the members of both being equal - EXPECT_EQ(unit.GetIndex(), unit2.GetIndex()); - EXPECT_EQ(unit.GetSlot(), unit2.GetSlot()); -} - -TEST(ControlSlotIndicator, Reset) -{ - SlotIndexType slot_index{42U}; - ControlSlotType slot{27U}; - // given a ControlSlotIndicator created with a given index/slot - ControlSlotIndicator unit{slot_index, slot}; - - // when calling Reset() - unit.Reset(); - - // expect, that the unit is invalid - EXPECT_FALSE(unit.IsValid()); -} - -TEST(ControlSlotIndicatorDeathTest, SlotAccessDies) -{ - // given a default constructed ControlSlotIndicator - ControlSlotIndicator unit{}; - - // expect it to die, when accessing the slot - EXPECT_DEATH(unit.GetSlot(), ".*"); -} - -TEST(ControlSlotIndicatorDeathTest, IndexAccessDies) -{ - // given a default constructed ControlSlotIndicator - ControlSlotIndicator unit{}; - - // expect it to die, when accessing the index - EXPECT_DEATH(unit.GetIndex(), ".*"); -} - -} // namespace -} // namespace score::mw::com::impl::lola diff --git a/score/mw/com/impl/bindings/lola/event_data_control.cpp b/score/mw/com/impl/bindings/lola/event_data_control.cpp index adeb4bfce..680471c60 100644 --- a/score/mw/com/impl/bindings/lola/event_data_control.cpp +++ b/score/mw/com/impl/bindings/lola/event_data_control.cpp @@ -11,445 +11,3 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ #include "score/mw/com/impl/bindings/lola/event_data_control.h" - -#include "score/mw/com/impl/bindings/lola/event_slot_status.h" - -#include - -#include -#include -#include - -namespace score::mw::com::impl::lola::detail_event_data_control -{ - -namespace -{ - -constexpr auto MAX_ALLOCATE_RETRIES = 100U; -constexpr auto MAX_REFERENCE_RETRIES = 100U; - -} // namespace - -template