Skip to content

Commit 4a09a47

Browse files
committed
lola: Remove EventDataControlCompositeImpl
These Impl classes were previously added to avoid having to change calling code to explicitly use the default template argument (i.e. EventDataControl<>). Using the explicit template argument makes the code more explicit and also removes the additional code complexity of having the alias and Impl class.
1 parent 6cd5691 commit 4a09a47

19 files changed

+83
-97
lines changed

score/mw/com/design/events_fields/event_lola_model.puml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract class SkeletonBinding {
3939
' Concrete classes
4040
class lola::SkeletonEvent<SampleType> {
4141
-event_data_storage: EventDataStorage<SampleType>*
42-
-event_data_control: score::cpp::optional<EventDataControlComposite>
42+
-event_data_control: score::cpp::optional<EventDataControlComposite<>>
4343
+SkeletonEvent(parent: Skeleton&, event_fqn: const ElementFqId, max_number_of_slots: const std::size_t, enforce_max_samples: const bool)
4444
+Send(SampleType const&): void
4545
+Send(SampleAllocateePtr<SampleType>): void
@@ -71,7 +71,7 @@ class lola::Skeleton {
7171
+Skeleton(const InstanceIdentifier&, SkeletonEvents&)
7272
+PrepareOffer(): ResultBlank
7373
+PrepareStopOffer(): ResultBlank
74-
+Register(ElementFqId, size_t numberOfSlots): std::pair<EventDataStorage*, EventDataControlComposite>
74+
+Register(ElementFqId, size_t numberOfSlots): std::pair<EventDataStorage*, EventDataControlComposite<>>
7575
+GetInstanceQualityType() const: QualityType
7676
}
7777

@@ -136,7 +136,7 @@ class lola::SampleAllocateePtr<SampleType> {
136136
-event_data_control_: EventDataControlComposite
137137
+SampleAllocateePtr()
138138
+SampleAllocateePtr(std::nullptr_t)
139-
+SampleAllocateePtr(ptr: pointer, const EventDataControlComposite&, const EventDataControl::SlotIndexType)
139+
+SampleAllocateePtr(ptr: pointer, const EventDataControlComposite<>&, const EventDataControl::SlotIndexType)
140140
+GetReferencedSlot() const: EventDataControl::SlotIndexType
141141
+get() const: SampleType*
142142
+reset(std::nullptr_t): void
@@ -159,7 +159,7 @@ class lola::SamplePtr<SampleType> {
159159
-event_data_control_: EventDataControl*
160160
+SamplePtr()
161161
+SamplePtr(std::nullptr_t)
162-
+SamplePtr(pointer ptr, const EventDataControlComposite&, const EventDataControl::SlotIndexType)
162+
+SamplePtr(pointer ptr, const EventDataControlComposite<>&, const EventDataControl::SlotIndexType)
163163
+get() const: pointer
164164
+swap(): void
165165
}
@@ -213,11 +213,11 @@ class "<<SharedMemory>>\nlola::EventSlotStatus" {
213213
+IsTimeStampBetween(EventTimeStamp min, EventTimeStamp max): bool
214214
}
215215

216-
class EventDataControlCompositeImpl<memory::shared::AtomicIndirectorType> {
216+
class EventDataControlComposite<memory::shared::AtomicIndirectorType> {
217217
-asil_qm_control_: EventDataControl*
218218
-asil_b_control_: EventDataControl*
219-
+EventDataControlCompositeImpl(asil_qm_control: EventDataControl* const)
220-
+EventDataControlCompositeImpl(asil_qm_control: EventDataControl* const, asil_b_control: EventDataControl* const)
219+
+EventDataControlComposite(asil_qm_control: EventDataControl* const)
220+
+EventDataControlComposite(asil_qm_control: EventDataControl* const, asil_b_control: EventDataControl* const)
221221
+AllocateNextSlot(): std::optional<EventDataControl::SlotIndexType>
222222
+EventReady(EventDataControl::SlotIndexType, EventSlotStatus::EventTimeStamp): void
223223
+Discard(EventDataControl::SlotIndexType): void
@@ -238,18 +238,18 @@ lola::Skeleton *-- SkeletonDataStorage : "1..1"
238238
lola::Skeleton *-- "<<SharedMemory>>\nlola::SkeletonDataControl" : "1..2"
239239
"<<SharedMemory>>\nlola::SkeletonDataControl" *-- "<<SharedMemory>>\nlola::EventDataControlImpl" : "0..n"
240240
lola::SkeletonEvent o-- "EventDataStorage"
241-
lola::SkeletonEvent *-- EventDataControlCompositeImpl
241+
lola::SkeletonEvent *-- EventDataControlComposite
242242
"<<SharedMemory>>\nlola::EventDataControlImpl" ..> "<<SharedMemory>>\nlola::EventSlotStatus"
243243
SampleAllocateePtr o-- lola::SampleAllocateePtr
244244
SamplePtr o-- lola::SamplePtr
245245
lola::ProxyEvent *-- lola::ProxyEventCommon
246246
lola::ProxyEventCommon *-- lola::SubscriptionStateMachine
247247
lola::ProxyEventCommon --* lola::SlotCollector
248248
ProxyEventBindingBase o-- SubscriptionState
249-
lola::SampleAllocateePtr *-- EventDataControlCompositeImpl
250-
EventDataControlCompositeImpl o-- "<<SharedMemory>>\nlola::EventDataControlImpl" : "2"
249+
lola::SampleAllocateePtr *-- EventDataControlComposite
250+
EventDataControlComposite o-- "<<SharedMemory>>\nlola::EventDataControlImpl" : "2"
251251
lola::Skeleton ..> lola::ShmPathBuilder : uses
252-
lola::Skeleton ..> EventDataControlCompositeImpl
252+
lola::Skeleton ..> EventDataControlComposite
253253
lola::SubscriptionStateMachine ..> lola::SlotCollector : <<creates>>
254254
SkeletonEventBinding ..> SampleAllocateePtr
255255
lola::ProxyEvent ..> lola::SamplePtr

score/mw/com/design/skeleton_proxy/generic_proxy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The map containing the meta-information gets initialized by the skeleton instanc
8787
the vectors containing the sample slots in
8888
```
8989
template <typename SampleType>
90-
std::pair<EventDataStorage<SampleType>*, EventDataControlComposite> lola::Skeleton::Register(ElementFqId event_fqn,
90+
std::pair<EventDataStorage<SampleType>*, EventDataControlComposite<>> lola::Skeleton::Register(ElementFqId event_fqn,
9191
std::size_t number_of_slots)
9292
```
9393

score/mw/com/design/skeleton_proxy/skeleton_binding_model.puml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class "lola::Skeleton" as lola_Skeleton {
150150
+PrepareStopOffer(): void
151151

152152
template <typename SampleType>
153-
+Register(ElementFqId, size_t num_slots): std::pair<EventDataStorage<SampleType>*,EventDataControlComposite>
153+
+Register(ElementFqId, size_t num_slots): std::pair<EventDataStorage<SampleType>*,EventDataControlComposite<>>
154154
}
155155

156156
class "lola::SkeletonEvent<SampleType>" as lola_SkeletonEvent {

score/mw/com/design/skeleton_proxy/skeleton_proxy_binding_model.puml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class "lola::Skeleton" as LolaSkeleton {
3535
+PrepareOffer(SkeletonBinding::SkeletonEventBindings&, SkeletonBinding::SkeletonFieldBindings&): ResultBlank
3636
+PrepareStopOffer(): void
3737

38-
+template <typename SampleType>\n Register(ElementFqId, size_t num_slots): std::pair<EventDataStorage<SampleType>*, EventDataControlComposite>
38+
+template <typename SampleType>\n Register(ElementFqId, size_t num_slots): std::pair<EventDataStorage<SampleType>*, EventDataControlComposite<>>
3939
}
4040

4141
class "SkeletonBindingFactory" {

score/mw/com/impl/bindings/lola/event_data_control.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ class EventDataControlAttorney;
4646
// coverity[autosar_cpp14_m3_2_3_violation]
4747
class EventDataControlCompositeAttorney;
4848

49-
namespace detail_event_data_control_composite
50-
{
5149
// Suppress The rule AUTOSAR C++14 M3-2-3: "A type, object or function that is used in multiple translation units shall
5250
// be declared in one and only one file."
5351
// This is a forward declaration that does not vioalate this rule.
5452
// coverity[autosar_cpp14_m3_2_3_violation]
5553
template <template <class> class T>
56-
class EventDataControlCompositeImpl;
57-
} // namespace detail_event_data_control_composite
54+
class EventDataControlComposite;
5855

5956
namespace detail_event_data_control
6057
{
@@ -82,6 +79,14 @@ class EventDataControlImpl final
8279
// coverity[autosar_cpp14_a11_3_1_violation]
8380
friend class lola::EventDataControlCompositeAttorney;
8481

82+
template <template <typename> class T>
83+
// Suppress "AUTOSAR C++14 A11-3-1", The rule declares: "Friend declarations shall not be used".
84+
// In order that users do not depend on implementation details, we only expose on user facing classes the bare
85+
// necessary. Thus, we have friend classes that expose internals for our implementation. Design decision for better
86+
// encapsulation.
87+
// coverity[autosar_cpp14_a11_3_1_violation]
88+
friend class lola::EventDataControlComposite;
89+
8590
public:
8691
using EventControlSlots =
8792
score::containers::DynamicArray<ControlSlotType,
@@ -232,14 +237,6 @@ class EventDataControlImpl final
232237
static inline std::atomic_uint_fast64_t num_ref_misses{0U};
233238
static inline std::atomic_uint_fast64_t num_alloc_retries{0U};
234239
static inline std::atomic_uint_fast64_t num_ref_retries{0U};
235-
236-
template <template <typename> class T>
237-
// Suppress "AUTOSAR C++14 A11-3-1", The rule declares: "Friend declarations shall not be used".
238-
// In order that users do not depend on implementation details, we only expose on user facing classes the bare
239-
// necessary. Thus, we have friend classes that expose internals for our implementation. Design decision for better
240-
// encapsulation.
241-
// coverity[autosar_cpp14_a11_3_1_violation]
242-
friend class detail_event_data_control_composite::EventDataControlCompositeImpl;
243240
};
244241

245242
} // namespace detail_event_data_control

score/mw/com/impl/bindings/lola/event_data_control_composite.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,29 @@
1111
* SPDX-License-Identifier: Apache-2.0
1212
********************************************************************************/
1313
#include "score/mw/com/impl/bindings/lola/event_data_control_composite.h"
14+
1415
#include <utility>
1516

16-
namespace score::mw::com::impl::lola::detail_event_data_control_composite
17+
namespace score::mw::com::impl::lola
1718
{
1819

1920
namespace
2021
{
22+
2123
constexpr std::size_t MAX_MULTI_ALLOCATE_RETRY_COUNT{100U};
24+
2225
}
2326

2427
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init): all members are initialized in the delegated constructor
2528
template <template <class> class AtomicIndirectorType>
26-
EventDataControlCompositeImpl<AtomicIndirectorType>::EventDataControlCompositeImpl(
27-
EventDataControl* const asil_qm_control)
28-
: EventDataControlCompositeImpl{asil_qm_control, nullptr}
29+
EventDataControlComposite<AtomicIndirectorType>::EventDataControlComposite(EventDataControl* const asil_qm_control)
30+
: EventDataControlComposite{asil_qm_control, nullptr}
2931
{
3032
}
3133

3234
template <template <class> class AtomicIndirectorType>
33-
EventDataControlCompositeImpl<AtomicIndirectorType>::EventDataControlCompositeImpl(
34-
EventDataControl* const asil_qm_control,
35-
EventDataControl* const asil_b_control)
35+
EventDataControlComposite<AtomicIndirectorType>::EventDataControlComposite(EventDataControl* const asil_qm_control,
36+
EventDataControl* const asil_b_control)
3637
: asil_qm_control_{asil_qm_control}, asil_b_control_{asil_b_control}, ignore_qm_control_{false}
3738
{
3839
CheckForValidDataControls();
@@ -45,7 +46,7 @@ template <template <class> class AtomicIndirectorType>
4546
// throwing std::bad_optional_access which leds to std::terminate(). This suppression should be removed after fixing
4647
// [Ticket-173043](broken_link_j/Ticket-173043)
4748
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
48-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::GetNextFreeMultiSlot() const noexcept
49+
auto EventDataControlComposite<AtomicIndirectorType>::GetNextFreeMultiSlot() const noexcept
4950
-> ControlSlotCompositeIndicator
5051
{
5152
EventSlotStatus::EventTimeStamp oldest_time_stamp{EventSlotStatus::TIMESTAMP_MAX};
@@ -120,8 +121,8 @@ template <template <class> class AtomicIndirectorType>
120121
// in case the index goes outside the range. As we already do an index check before accessing, so no way for
121122
// segmentation fault which leds to calling std::terminate().
122123
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
123-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::TryLockSlot(
124-
ControlSlotCompositeIndicator slot_indicator) noexcept -> bool
124+
auto EventDataControlComposite<AtomicIndirectorType>::TryLockSlot(ControlSlotCompositeIndicator slot_indicator) noexcept
125+
-> bool
125126
{
126127
auto& slot_value_qm = slot_indicator.GetSlotQM();
127128
auto& slot_value_asil_b = slot_indicator.GetSlotAsilB();
@@ -163,8 +164,7 @@ template <template <class> class AtomicIndirectorType>
163164
// have a value but as we check before with 'has_value()' so no way for throwing std::bad_optional_access which leds
164165
// to std::terminate().
165166
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
166-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::AllocateNextMultiSlot() noexcept
167-
-> ControlSlotCompositeIndicator
167+
auto EventDataControlComposite<AtomicIndirectorType>::AllocateNextMultiSlot() noexcept -> ControlSlotCompositeIndicator
168168
{
169169
// \todo we should also monitor retry counts in the multi-slot/EventDataControlComposite case, like we are doing in
170170
// EventDataControl! Currently we are "blind", if we have retries, because ASIL-QM/ASIL-B consumers do influence
@@ -185,7 +185,7 @@ auto EventDataControlCompositeImpl<AtomicIndirectorType>::AllocateNextMultiSlot(
185185
}
186186

187187
template <template <class> class AtomicIndirectorType>
188-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::AllocateNextSlot() noexcept -> ControlSlotCompositeIndicator
188+
auto EventDataControlComposite<AtomicIndirectorType>::AllocateNextSlot() noexcept -> ControlSlotCompositeIndicator
189189
{
190190
if (asil_b_control_ == nullptr)
191191
{
@@ -233,9 +233,9 @@ auto EventDataControlCompositeImpl<AtomicIndirectorType>::AllocateNextSlot() noe
233233
}
234234

235235
template <template <class> class AtomicIndirectorType>
236-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::EventReady(
237-
ControlSlotCompositeIndicator slot_indicator,
238-
EventSlotStatus::EventTimeStamp time_stamp) noexcept -> void
236+
auto EventDataControlComposite<AtomicIndirectorType>::EventReady(ControlSlotCompositeIndicator slot_indicator,
237+
EventSlotStatus::EventTimeStamp time_stamp) noexcept
238+
-> void
239239
{
240240
if (asil_b_control_ != nullptr)
241241
{
@@ -249,7 +249,7 @@ auto EventDataControlCompositeImpl<AtomicIndirectorType>::EventReady(
249249
}
250250

251251
template <template <class> class AtomicIndirectorType>
252-
auto EventDataControlCompositeImpl<AtomicIndirectorType>::Discard(ControlSlotCompositeIndicator slot_indicator) -> void
252+
auto EventDataControlComposite<AtomicIndirectorType>::Discard(ControlSlotCompositeIndicator slot_indicator) -> void
253253
{
254254
if (asil_b_control_ != nullptr)
255255
{
@@ -263,20 +263,19 @@ auto EventDataControlCompositeImpl<AtomicIndirectorType>::Discard(ControlSlotCom
263263
}
264264

265265
template <template <class> class AtomicIndirectorType>
266-
bool EventDataControlCompositeImpl<AtomicIndirectorType>::IsQmControlDisconnected() const noexcept
266+
bool EventDataControlComposite<AtomicIndirectorType>::IsQmControlDisconnected() const noexcept
267267
{
268268
return ignore_qm_control_;
269269
}
270270

271271
template <template <class> class AtomicIndirectorType>
272-
EventDataControl& EventDataControlCompositeImpl<AtomicIndirectorType>::GetQmEventDataControl() const noexcept
272+
EventDataControl& EventDataControlComposite<AtomicIndirectorType>::GetQmEventDataControl() const noexcept
273273
{
274274
return *asil_qm_control_;
275275
}
276276

277277
template <template <class> class AtomicIndirectorType>
278-
std::optional<EventDataControl*>
279-
EventDataControlCompositeImpl<AtomicIndirectorType>::GetAsilBEventDataControl() noexcept
278+
std::optional<EventDataControl*> EventDataControlComposite<AtomicIndirectorType>::GetAsilBEventDataControl() noexcept
280279
{
281280
if (asil_b_control_ != nullptr)
282281
{
@@ -286,7 +285,7 @@ EventDataControlCompositeImpl<AtomicIndirectorType>::GetAsilBEventDataControl()
286285
}
287286

288287
template <template <class> class AtomicIndirectorType>
289-
EventSlotStatus::EventTimeStamp EventDataControlCompositeImpl<AtomicIndirectorType>::GetEventSlotTimestamp(
288+
EventSlotStatus::EventTimeStamp EventDataControlComposite<AtomicIndirectorType>::GetEventSlotTimestamp(
290289
const SlotIndexType slot) const noexcept
291290
{
292291
if (asil_b_control_ != nullptr)
@@ -304,7 +303,7 @@ EventSlotStatus::EventTimeStamp EventDataControlCompositeImpl<AtomicIndirectorTy
304303
}
305304

306305
template <template <class> class AtomicIndirectorType>
307-
void EventDataControlCompositeImpl<AtomicIndirectorType>::CheckForValidDataControls() const noexcept
306+
void EventDataControlComposite<AtomicIndirectorType>::CheckForValidDataControls() const noexcept
308307
{
309308
if (asil_qm_control_ == nullptr)
310309
{
@@ -318,7 +317,7 @@ template <template <class> class AtomicIndirectorType>
318317
// in case the index goes outside the range. As we already do an index check before accessing, so no way for
319318
// segmentation fault which leds to calling std::terminate().
320319
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
321-
EventSlotStatus::EventTimeStamp EventDataControlCompositeImpl<AtomicIndirectorType>::GetLatestTimestamp() const noexcept
320+
EventSlotStatus::EventTimeStamp EventDataControlComposite<AtomicIndirectorType>::GetLatestTimestamp() const noexcept
322321
{
323322
EventSlotStatus::EventTimeStamp latest_time_stamp{1U};
324323
EventDataControl* control = (asil_b_control_ != nullptr) ? asil_b_control_ : asil_qm_control_;
@@ -343,7 +342,7 @@ EventSlotStatus::EventTimeStamp EventDataControlCompositeImpl<AtomicIndirectorTy
343342
return latest_time_stamp;
344343
}
345344

346-
template class EventDataControlCompositeImpl<memory::shared::AtomicIndirectorReal>;
347-
template class EventDataControlCompositeImpl<memory::shared::AtomicIndirectorMock>;
345+
template class EventDataControlComposite<memory::shared::AtomicIndirectorReal>;
346+
template class EventDataControlComposite<memory::shared::AtomicIndirectorMock>;
348347

349-
} // namespace score::mw::com::impl::lola::detail_event_data_control_composite
348+
} // namespace score::mw::com::impl::lola

score/mw/com/impl/bindings/lola/event_data_control_composite.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*
1111
* SPDX-License-Identifier: Apache-2.0
1212
********************************************************************************/
13-
#ifndef DDAD_SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_
14-
#define DDAD_SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_
13+
#ifndef SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_
14+
#define SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_
1515

1616
#include "score/mw/com/impl/bindings/lola/control_slot_composite_indicator.h"
1717
#include "score/mw/com/impl/bindings/lola/control_slot_types.h"
@@ -29,9 +29,6 @@ namespace score::mw::com::impl::lola
2929

3030
class EventDataControlCompositeAttorney;
3131

32-
namespace detail_event_data_control_composite
33-
{
34-
3532
/// \brief Encapsulates multiple EventDataControl instances
3633
///
3734
/// \details Due to the fact that we have multiple EventDataControl instances (one for ASIL, one for QM) we need to
@@ -40,21 +37,20 @@ namespace detail_event_data_control_composite
4037
/// control structures. Please be aware that the control structures will live in different shared memory segments, thus
4138
/// it is not possible to store them by value, but rather as pointer.
4239
template <template <class> class AtomicIndirectorType = memory::shared::AtomicIndirectorReal>
43-
class EventDataControlCompositeImpl
40+
class EventDataControlComposite
4441
{
4542
// Suppress "AUTOSAR C++14 A11-3-1", The rule declares: "Friend declarations shall not be used".
4643
// The "EventDataControlCompositeAttorney" class is a helper, which sets the internal state of
47-
// "EventDataControlCompositeImpl" accessing private members and used for testing purposes only.
44+
// "EventDataControlComposite" accessing private members and used for testing purposes only.
4845
// coverity[autosar_cpp14_a11_3_1_violation]
4946
friend class lola::EventDataControlCompositeAttorney;
5047

5148
public:
5249
/// \brief Constructs a composite which will only manage a single QM control (no ASIL use-case)
53-
explicit EventDataControlCompositeImpl(EventDataControl* const asil_qm_control);
50+
explicit EventDataControlComposite(EventDataControl* const asil_qm_control);
5451

5552
/// \brief Constructs a composite which will manage QM and ASIL control at the same time
56-
explicit EventDataControlCompositeImpl(EventDataControl* const asil_qm_control,
57-
EventDataControl* const asil_b_control);
53+
explicit EventDataControlComposite(EventDataControl* const asil_qm_control, EventDataControl* const asil_b_control);
5854

5955
/// \brief Checks for the oldest unused slot and acquires for writing (thread-safe, wait-free)
6056
///
@@ -116,9 +112,6 @@ class EventDataControlCompositeImpl
116112
void CheckForValidDataControls() const noexcept;
117113
};
118114

119-
} // namespace detail_event_data_control_composite
120-
121-
using EventDataControlComposite = detail_event_data_control_composite::EventDataControlCompositeImpl<>;
122-
123115
} // namespace score::mw::com::impl::lola
124-
#endif // DDAD_SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_
116+
117+
#endif // SCORE_MW_COM_IMPL_BINDINGS_LOLA_EVENT_DATA_CONTROL_COMPOSITE_H_

0 commit comments

Comments
 (0)