LCOV - code coverage report
Current view: top level - libs/bsw/middleware/doc/examples/release - skeleton_app.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 21 21
Test Date: 2026-10-23 12:52:11 Functions: 100.0 % 6 6

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2026 BMW AG
       3              :  *
       4              :  * This program and the accompanying materials are made available under the
       5              :  * terms of the Apache License Version 2.0 which is available at
       6              :  * https://www.apache.org/licenses/LICENSE-2.0
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  ********************************************************************************/
      10              : 
      11              : #pragma once
      12              : 
      13              : #include <features/communication/dummy_serviceCommon.h>
      14              : #include <features/communication/dummy_serviceSkeleton.h>
      15              : 
      16              : #include <middleware/core/ResponseBufferBase.h>
      17              : 
      18              : #include <cstdint>
      19              : 
      20              : namespace application
      21              : {
      22              : 
      23              : namespace
      24              : {
      25              : constexpr uint32_t BROADCAST_VALUE = 0x00FF00FFU;
      26              : } // namespace
      27              : 
      28              : // [service-skeleton-wrapper-start]
      29              : class SkeletonApp : public features::communication::DummyService::skeleton::DummyServiceSkeleton
      30              : {
      31              : public:
      32              :     using Base = features::communication::DummyService::skeleton::DummyServiceSkeleton;
      33              :     using Foo  = features::communication::DummyService::Foo;
      34              :     using Baz  = features::communication::DummyService::Baz;
      35              :     using FireAndForgetPayload = features::communication::DummyService::FireAndForgetPayload;
      36              :     using MwInstanceId         = features::communication::DummyService::internal::InstanceId;
      37              :     using SkeletonResponseInfo = ::middleware::core::ResponseBufferBase::SkeletonResponseInfo;
      38              : 
      39            6 :     bool init()
      40              :     {
      41            6 :         return Base::init(MwInstanceId::InstanceId_1) == ::middleware::core::HRESULT::Ok;
      42              :     }
      43              : 
      44              :     void shutdown() { Base::deInit(); }
      45              : 
      46              :     // [service-skeleton-method-start]
      47            1 :     void asyncMethod([[maybe_unused]] Foo const& input, SkeletonResponseInfo& response) override
      48              :     {
      49            1 :         Base::asyncMethod(input, response);
      50            1 :         pendingAsyncResponse_ = &response;
      51            1 :     }
      52              : 
      53              :     // [service-skeleton-method-end]
      54              : 
      55              :     // [service-skeleton-fire-and-forget-method-start]
      56            1 :     void fireAndForgetMethod(FireAndForgetPayload const& payload) override
      57              :     {
      58            1 :         Base::fireAndForgetMethod(payload);
      59            1 :     }
      60              : 
      61              :     // [service-skeleton-fire-and-forget-method-end]
      62              : 
      63              :     // [service-skeleton-execute-start]
      64            1 :     void execute()
      65              :     {
      66              :         /* Disabled for the mock unit test: init() is mocked, so isInitialized() stays false. */
      67            1 :         if (/* Base::isInitialized() && */ pendingAsyncResponse_ != nullptr)
      68              :         {
      69            2 :             [[maybe_unused]] ::middleware::core::HRESULT const result = Base::respondAsyncMethod(
      70            1 :                 *pendingAsyncResponse_, features::communication::DummyService::Baz{9U, 8U, 7U, 6U});
      71            1 :             pendingAsyncResponse_ = nullptr;
      72              :         }
      73            1 :     }
      74              : 
      75              :     // [service-skeleton-execute-end]
      76              : 
      77              :     // [service-skeleton-broadcast-start]
      78              :     void publishBroadcast()
      79              :     {
      80              :         if (Base::isInitialized())
      81              :         {
      82              :             [[maybe_unused]] ::middleware::core::HRESULT const result
      83              :                 = this->simpleBroadcast.send(BROADCAST_VALUE);
      84              :         }
      85              :     }
      86              : 
      87              :     // [service-skeleton-broadcast-end]
      88              : 
      89              :     // [service-skeleton-attribute-broadcast-start]
      90              :     void publishAttribute(uint32_t const value)
      91              :     {
      92              :         if (Base::isInitialized())
      93              :         {
      94              :             this->simpleField.set(value);
      95              :             [[maybe_unused]] ::middleware::core::HRESULT const result = this->simpleField.send();
      96              :         }
      97              :     }
      98              : 
      99              :     // [service-skeleton-attribute-broadcast-end]
     100              : 
     101              :     // [service-skeleton-attribute-get-start]
     102            1 :     void getSimpleFieldAttribute(SkeletonResponseInfo& response) override
     103              :     {
     104            1 :         Base::getSimpleFieldAttribute(response);
     105            1 :     }
     106              : 
     107              :     // [service-skeleton-attribute-get-end]
     108              : 
     109              :     // [service-skeleton-attribute-set-start]
     110            1 :     void setSimpleFieldAttribute(uint32_t const& value) override
     111              :     {
     112            1 :         Base::setSimpleFieldAttribute(value);
     113            1 :     }
     114              : 
     115              :     // [service-skeleton-attribute-set-end]
     116              : 
     117              : private:
     118              :     SkeletonResponseInfo* pendingAsyncResponse_{};
     119              : };
     120              : 
     121              : // [service-skeleton-wrapper-end]
     122              : 
     123              : } // namespace application
        

Generated by: LCOV version 2.0-1