@@ -78,6 +78,8 @@ namespace score::mw::com::impl::lola
7878namespace
7979{
8080
81+ constexpr LolaMethodInstanceDeployment::QueueSize kFieldMethodQueueSize {1U };
82+
8183// Suppress "AUTOSAR C++14 A16-0-1" rule findings. This rule stated: "The pre-processor shall only be used for
8284// unconditional and conditional file inclusion and include guards, and using the following directives: (1) #ifndef,
8385// #ifdef, (3) #if, (4) #if defined, (5) #elif, (6) #else, (7) #define, (8) #endif, (9) #include.".
@@ -244,6 +246,68 @@ score::Result<void> ExecutePartialRestartLogic(const QualityType quality_type,
244246 return {};
245247}
246248
249+ void AppendEnabledMethodIdsAndQueueSizesImpl (
250+ std::vector<std::pair<UniqueMethodIdentifier, LolaMethodInstanceDeployment::QueueSize>>& result,
251+ const LolaFieldInstanceDeployment& lola_field_instance_deployment,
252+ LolaServiceElementId field_id)
253+ {
254+ for (const auto & [use_if_available, method_type] :
255+ {std::pair{lola_field_instance_deployment.use_get_if_available_ , MethodType::kGet },
256+ std::pair{lola_field_instance_deployment.use_set_if_available_ , MethodType::kSet }})
257+ {
258+ if (use_if_available)
259+ {
260+ result.emplace_back (UniqueMethodIdentifier{field_id, method_type}, kFieldMethodQueueSize );
261+ }
262+ }
263+ }
264+
265+ void AppendEnabledMethodIdsAndQueueSizesImpl (
266+ std::vector<std::pair<UniqueMethodIdentifier, LolaMethodInstanceDeployment::QueueSize>>& result,
267+ const LolaMethodInstanceDeployment& lola_method_instance_deployment,
268+ LolaServiceElementId method_id)
269+ {
270+ // At this point the enabled_ field must be set by the config parser.
271+ SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE (lola_method_instance_deployment.enabled_ .has_value (),
272+ " Method instance deployment must contain enabled on proxy side!" );
273+
274+ if (lola_method_instance_deployment.enabled_ .value ())
275+ {
276+ SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE (
277+ lola_method_instance_deployment.queue_size_ .has_value (),
278+ " Method instance deployment must contain queue_size on proxy side!" );
279+ result.emplace_back (UniqueMethodIdentifier{method_id, MethodType::kMethod },
280+ lola_method_instance_deployment.queue_size_ .value ());
281+ }
282+ }
283+
284+ template <ServiceElementType kElementType >
285+ void AppendEnabledMethodIdsAndQueueSizes (
286+ std::vector<std::pair<UniqueMethodIdentifier, LolaMethodInstanceDeployment::QueueSize>>& result,
287+ const LolaServiceInstanceDeployment& service_instance_deployment,
288+ const LolaServiceTypeDeployment& service_type_deployment)
289+ {
290+ auto & deployment_map = [&service_instance_deployment]() -> const auto & {
291+ if constexpr (kElementType == ServiceElementType::METHOD )
292+ {
293+ return service_instance_deployment.methods_ ;
294+ }
295+ else if constexpr (kElementType == ServiceElementType::FIELD )
296+ {
297+ return service_instance_deployment.fields_ ;
298+ }
299+ else
300+ {
301+ SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE (false , " Unsupported service element type" );
302+ }
303+ }();
304+ for (const auto & [name, deployment] : deployment_map)
305+ {
306+ const auto element_id = GetServiceElementId<kElementType >(service_type_deployment, name);
307+ AppendEnabledMethodIdsAndQueueSizesImpl (result, deployment, element_id);
308+ }
309+ }
310+
247311} // namespace
248312
249313namespace detail_proxy
@@ -604,38 +668,6 @@ score::Result<void> Proxy::SetupMethods(const std::size_t additional_shm_size_by
604668{
605669 auto enabled_method_data = GetMethodIdAndQueueSizeForEnabledMethods ();
606670
607- // Add field Get/Set methods to the enabled method data.
608- // TODO(Ticket-250429): Replace these constants with actual per-field configuration flags
609- // once the field get/set availability is added to the deployment configuration.
610- constexpr bool kUseGetIfAvailable = true ;
611- constexpr bool kUseSetIfAvailable = true ;
612-
613- // TODO : This would also be replaced with the actual queue size configuration from the config files once we support
614- // queue size > 1.
615- constexpr LolaMethodInstanceDeployment::QueueSize kFieldMethodQueueSize {1U };
616-
617- const auto & lola_service_type_deployment = GetLoLaServiceTypeDeployment (handle_);
618- const auto & lola_service_instance_deployment = GetLoLaInstanceDeployment (handle_);
619- {
620- std::lock_guard lock{proxy_method_registration_mutex_};
621- for (const auto & [field_name, field_instance_deployment] : lola_service_instance_deployment.fields_ )
622- {
623- const auto field_id =
624- GetServiceElementId<ServiceElementType::FIELD >(lola_service_type_deployment, field_name);
625-
626- if ((kUseGetIfAvailable ) && (proxy_methods_.count ({field_id, MethodType::kGet }) != 0U ))
627- {
628- enabled_method_data.push_back ({{field_id, MethodType::kGet }, kFieldMethodQueueSize });
629- }
630- if ((kUseSetIfAvailable ) && (proxy_methods_.count ({field_id, MethodType::kSet }) != 0U ))
631- {
632- enabled_method_data.push_back ({{field_id, MethodType::kSet }, kFieldMethodQueueSize });
633- }
634- }
635- }
636- // This check has be done after looping over the fields to add the field methods to the enabled method data because,
637- // if we did this before then even when the fields are configured and when the enabled_method_names are empty we
638- // would do an early return and miss setting up the fields shm.
639671 if (enabled_method_data.empty ())
640672 {
641673 score::mw::log::LogDebug (" lola" )
@@ -764,23 +796,11 @@ Proxy::GetMethodIdAndQueueSizeForEnabledMethods() const
764796 const auto & lola_service_instance_deployment = GetLoLaInstanceDeployment (handle_);
765797 const auto & lola_service_type_deployment = GetLoLaServiceTypeDeployment (handle_);
766798
767- // Get enabled methods from config and build method data
768- for (const auto & [method_name, method_deployment] : lola_service_instance_deployment.methods_ )
769- {
770- if (method_deployment.enabled_ .has_value () && method_deployment.enabled_ .value ())
771- {
772- const auto method_id =
773- GetServiceElementId<ServiceElementType::METHOD >(lola_service_type_deployment, method_name);
774-
775- SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE (
776- method_deployment.queue_size_ .has_value (),
777- " Method instance deployment must contain queue_size on proxy side!" );
778- const auto queue_size = method_deployment.queue_size_ .value ();
799+ AppendEnabledMethodIdsAndQueueSizes<ServiceElementType::METHOD >(
800+ enabled_method_ids_and_queue_sizes, lola_service_instance_deployment, lola_service_type_deployment);
779801
780- std::ignore = enabled_method_ids_and_queue_sizes.emplace_back (
781- UniqueMethodIdentifier{method_id, MethodType::kMethod }, queue_size);
782- }
783- }
802+ AppendEnabledMethodIdsAndQueueSizes<ServiceElementType::FIELD >(
803+ enabled_method_ids_and_queue_sizes, lola_service_instance_deployment, lola_service_type_deployment);
784804
785805 return enabled_method_ids_and_queue_sizes;
786806}
0 commit comments