Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions score/mw/com/impl/methods/skeleton_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace score::mw::com::impl
{

template <typename, bool, bool>
template <typename, bool, bool, bool>
class SkeletonField;

template <typename Signature>
Expand All @@ -53,7 +53,7 @@ class SkeletonMethod<ReturnType(ArgTypes...)> final : public SkeletonMethodBase
static_assert(return_value_is_not_a_pointer,
"Return value can not be a pointer, since we can not put them in shared memory.");

template <typename, bool, bool>
template <typename, bool, bool, bool>
// coverity[autosar_cpp14_a11_3_1_violation]
friend class SkeletonField;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "score/mw/com/impl/skeleton_base.h"
#include "score/mw/com/impl/skeleton_event_binding.h"

#include <cstddef>
#include <memory>
#include <string_view>

Expand All @@ -44,11 +45,13 @@ class ISkeletonFieldBindingFactory
/// \param identifier The instance identifier containing the binding information.
/// \param parent A reference to the Skeleton which owns this event.
/// \param field_name The binding unspecific name of the field inside the skeleton denoted by instance identifier.
/// \param additional_slots_for_field_get_set Additional slots to reserve on top of configured sample slots.
/// \return An instance of SkeletonEventBinding or nullptr in case of an error.
virtual auto CreateEventBinding(const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view field_name) noexcept
-> std::unique_ptr<SkeletonEventBinding<SampleType>> = 0;
SkeletonBase& parent,
const std::string_view field_name,
std::size_t additional_slots_for_field_get_set = 0U) noexcept
-> std::unique_ptr<SkeletonEventBinding<SampleType>> = 0;
};

} // namespace score::mw::com::impl
Expand Down
6 changes: 4 additions & 2 deletions score/mw/com/impl/plumbing/skeleton_field_binding_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "score/mw/com/impl/skeleton_event_binding.h"

#include <functional>
#include <cstddef>
#include <memory>
#include <string_view>
#include <utility>
Expand All @@ -39,9 +40,10 @@ class SkeletonFieldBindingFactory final
/// \brief See documentation in ISkeletonFieldBindingFactory.
static std::unique_ptr<SkeletonEventBinding<SampleType>> CreateEventBinding(const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view field_name)
const std::string_view field_name,
std::size_t additional_slots_for_field_get_set = 0U)
{
return instance().CreateEventBinding(identifier, parent, field_name);
return instance().CreateEventBinding(identifier, parent, field_name, additional_slots_for_field_get_set);
}

/// \brief Inject a mock ISkeletonFieldBindingFactory. If a mock is injected, then all calls on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "score/mw/com/impl/skeleton_base.h"
#include "score/mw/com/impl/skeleton_event_binding.h"

#include <cstddef>
#include <memory>
#include <string_view>

Expand All @@ -36,7 +37,8 @@ class SkeletonFieldBindingFactoryImpl : public ISkeletonFieldBindingFactory<Samp
std::unique_ptr<SkeletonEventBinding<SampleType>> CreateEventBinding(
const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view field_name) noexcept override;
const std::string_view field_name,
std::size_t additional_slots_for_field_get_set = 0U) noexcept override;
};

template <typename SampleType>
Expand All @@ -49,13 +51,17 @@ template <typename SampleType>
// This suppression should be removed after fixing [Ticket-173043](broken_link_j/Ticket-173043)
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
auto SkeletonFieldBindingFactoryImpl<SampleType>::CreateEventBinding(const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view field_name) noexcept
-> std::unique_ptr<SkeletonEventBinding<SampleType>>
SkeletonBase& parent,
const std::string_view field_name,
std::size_t additional_slots_for_field_get_set) noexcept
-> std::unique_ptr<SkeletonEventBinding<SampleType>>
{
return CreateSkeletonServiceElement<SkeletonEventBinding<SampleType>,
lola::SkeletonEvent<SampleType>,
ServiceElementType::FIELD>(identifier, parent, field_name);
return CreateSkeletonServiceElement<SkeletonEventBinding<SampleType>,
lola::SkeletonEvent<SampleType>,
ServiceElementType::FIELD>(identifier,
parent,
field_name,
additional_slots_for_field_get_set);
}

} // namespace score::mw::com::impl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <gmock/gmock.h>

#include <cstddef>

namespace score::mw::com::impl
{

Expand All @@ -27,7 +29,17 @@ class SkeletonFieldBindingFactoryMock : public ISkeletonFieldBindingFactory<Samp
MOCK_METHOD(std::unique_ptr<SkeletonEventBinding<SampleType>>,
CreateEventBinding,
(const InstanceIdentifier&, SkeletonBase&, const std::string_view),
(noexcept, override));
(noexcept));

auto CreateEventBinding(const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view field_name,
std::size_t additional_slots_for_field_get_set) noexcept
-> std::unique_ptr<SkeletonEventBinding<SampleType>> override
{
static_cast<void>(additional_slots_for_field_get_set);
return CreateEventBinding(identifier, parent, field_name);
}
};

} // namespace score::mw::com::impl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <score/overload.hpp>

#include <chrono>
#include <cstddef>
#include <exception>
#include <memory>
#include <string>
Expand All @@ -46,7 +47,8 @@ namespace detail

template <typename LolaServiceElementInstanceDeployment>
lola::SkeletonEventProperties GetSkeletonEventProperties(
const LolaServiceElementInstanceDeployment& lola_service_element_instance_deployment)
const LolaServiceElementInstanceDeployment& lola_service_element_instance_deployment,
std::size_t additional_slots_for_field_get_set = 0U)
{
if (!lola_service_element_instance_deployment.GetNumberOfSampleSlots().has_value())
{
Expand All @@ -63,7 +65,11 @@ lola::SkeletonEventProperties GetSkeletonEventProperties(
"not specified in the configuration. Terminating.";
std::terminate();
}
return lola::SkeletonEventProperties{lola_service_element_instance_deployment.GetNumberOfSampleSlots().value(),
const auto number_of_slots = static_cast<std::size_t>(
lola_service_element_instance_deployment.GetNumberOfSampleSlots().value()) +
additional_slots_for_field_get_set;

return lola::SkeletonEventProperties{number_of_slots,
lola_service_element_instance_deployment.max_subscribers_.value(),
lola_service_element_instance_deployment.enforce_max_samples_};
}
Expand All @@ -81,7 +87,8 @@ template <typename SkeletonServiceElementBinding, typename SkeletonServiceElemen
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
auto CreateSkeletonServiceElement(const InstanceIdentifier& identifier,
SkeletonBase& parent,
const std::string_view service_element_name) noexcept
const std::string_view service_element_name,
std::size_t additional_slots_for_field_get_set = 0U) noexcept
-> std::unique_ptr<SkeletonServiceElementBinding>
{
static_assert(element_type != ServiceElementType::INVALID);
Expand All @@ -90,7 +97,7 @@ auto CreateSkeletonServiceElement(const InstanceIdentifier& identifier,

using ReturnType = std::unique_ptr<SkeletonServiceElementBinding>;
auto visitor = score::cpp::overload(
[identifier_view, &parent, &service_element_name](
[identifier_view, &parent, &service_element_name, additional_slots_for_field_get_set](
const LolaServiceTypeDeployment& lola_service_type_deployment) -> ReturnType {
auto* const lola_parent = dynamic_cast<lola::Skeleton*>(SkeletonBaseView{parent}.GetBinding());
if (lola_parent == nullptr)
Expand All @@ -108,7 +115,8 @@ auto CreateSkeletonServiceElement(const InstanceIdentifier& identifier,
const auto& lola_service_element_instance_deployment = GetServiceElementInstanceDeployment<element_type>(
lola_service_instance_deployment, service_element_name_str);
const auto skeleton_event_properties =
detail::GetSkeletonEventProperties(lola_service_element_instance_deployment);
detail::GetSkeletonEventProperties(lola_service_element_instance_deployment,
additional_slots_for_field_get_set);

const auto lola_service_element_id =
GetServiceElementId<element_type>(lola_service_type_deployment, service_element_name_str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,31 @@ INSTANTIATE_TEST_CASE_P(SkeletonServiceElementBindingFactoryParamaterisedDeathTe

TEST_P(SkeletonServiceElementBindingFactoryParamaterisedFixture, CanConstructFixture) {}

class SkeletonServiceElementBindingFactoryFixture : public ::testing::Test
{
protected:
const LolaFieldInstanceDeployment field_deployment_{{2U}, {3U}, 1U, true, 0U};

auto GetSkeletonEventProperties(const std::size_t additional_slots_for_field_get_set = 0U) const
{
return detail::GetSkeletonEventProperties(field_deployment_, additional_slots_for_field_get_set);
}
};

TEST_F(SkeletonServiceElementBindingFactoryFixture, AdditionalSlotsAreAddedToConfiguredNumberOfSlots)
{
const auto skeleton_event_properties = GetSkeletonEventProperties(1U);

EXPECT_EQ(skeleton_event_properties.number_of_slots, 3U);
}

TEST_F(SkeletonServiceElementBindingFactoryFixture, DefaultAdditionalSlotsKeepsConfiguredNumberOfSlots)
{
const auto skeleton_event_properties = GetSkeletonEventProperties();

EXPECT_EQ(skeleton_event_properties.number_of_slots, 2U);
}

TEST_P(SkeletonServiceElementBindingFactoryParamaterisedFixture, CanConstructServiceElement)
{
RecordProperty("Verifies", "SCR-21803701, SCR-21803702, SCR-5898925");
Expand Down
4 changes: 2 additions & 2 deletions score/mw/com/impl/skeleton_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace score::mw::com::impl

// False Positive: this is a normal forward declaration.
// coverity[autosar_cpp14_m3_2_3_violation]
template <typename SampleDataType, const bool EnableSet, const bool EnableNotifier>
template <typename SampleDataType, const bool EnableSet, const bool EnableNotifier, const bool EnableGet>
class SkeletonField;

template <typename SampleDataType>
Expand All @@ -51,7 +51,7 @@ class SkeletonEvent : public SkeletonEventBase
// SkeletonField uses composition pattern to reuse code from SkeletonEvent. These two classes also have shared
// private APIs which necessitates the use of the friend keyword.
// coverity[autosar_cpp14_a11_3_1_violation]
template <typename T, bool ES, bool EN>
template <typename T, bool ES, bool EN, bool EG>
friend class SkeletonField;

// Empty struct that is used to make the second constructor only accessible to SkeletonEvent and SkeletonField (as
Expand Down
Loading
Loading