LCOV - code coverage report
Current view: top level - libs/bsw/cpp2someip/include/someip - ProvidedService.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 37 37
Test Date: 2026-09-11 12:05:06 Functions: 100.0 % 13 13

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2026 Accenture
       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 "someip/IProvidedServiceListener.h"
      14              : #include "someip/SdConfig.h"
      15              : #include "someip/ServiceDescription.h"
      16              : #include "someip/init.h"
      17              : 
      18              : #include <cstdint>
      19              : 
      20              : namespace someip
      21              : {
      22              : class ServiceHandler;
      23              : 
      24              : class ProvidedService
      25              : {
      26              : public:
      27              :     enum class ProvidedServiceState : uint8_t
      28              :     {
      29              :         IDLE_PHASE,
      30              :         INITIAL_WAIT_PHASE,
      31              :         REPETITION_PHASE,
      32              :         MAIN_PHASE,
      33              :         DENOUNCEMENT_PHASE,
      34              :         REMOVAL_PHASE
      35              :     };
      36              : 
      37              :     explicit ProvidedService(IProvidedServiceListener* listener = nullptr);
      38              : 
      39              :     explicit ProvidedService(ServiceHandler& handler, IProvidedServiceListener* listener = nullptr);
      40              : 
      41              :     void init();
      42              : 
      43              :     ServiceHandler* getHandler() const;
      44              :     void setHandler(ServiceHandler& implementation);
      45              : 
      46              :     uint64_t getTimestamp() const;
      47              :     void setTimestamp(uint64_t timestamp);
      48              : 
      49              :     uint32_t getRepetitionCount() const;
      50              :     void setRepetitionCount(uint32_t count);
      51              : 
      52              :     ProvidedServiceState getState() const;
      53              :     void setState(ProvidedServiceState state);
      54              : 
      55              :     SdOfferConfig const& getSdConfig() const;
      56              :     void setSdConfig(SdOfferConfig const& config);
      57              : 
      58              :     void unregisterDone() const;
      59              : 
      60              :     ServiceDescription description;
      61              : 
      62              : private:
      63              :     ServiceHandler* _pHandler;
      64              :     IProvidedServiceListener* _pListener;
      65              :     uint64_t _timestamp;
      66              :     uint32_t _repetitionCount;
      67              :     ProvidedServiceState _state;
      68              :     SdOfferConfig _sdConfig;
      69              : };
      70              : 
      71              : /*
      72              :  * inline implementation
      73              :  */
      74           15 : inline ProvidedService::ProvidedService(IProvidedServiceListener* const listener)
      75           15 : : description()
      76           15 : , _pHandler(nullptr)
      77           15 : , _pListener(listener)
      78           15 : , _timestamp(0U)
      79           15 : , _repetitionCount(0U)
      80           15 : , _state(ProvidedServiceState::IDLE_PHASE)
      81           15 : , _sdConfig()
      82           15 : {}
      83              : 
      84           47 : inline ProvidedService::ProvidedService(
      85           47 :     ServiceHandler& handler, IProvidedServiceListener* const listener)
      86           47 : : description(make<ServiceDescription>())
      87           47 : , _pHandler(&handler)
      88           47 : , _pListener(listener)
      89           47 : , _timestamp(0U)
      90           47 : , _repetitionCount(0U)
      91           47 : , _state(ProvidedServiceState::IDLE_PHASE)
      92           47 : , _sdConfig()
      93           47 : {}
      94              : 
      95           48 : inline void ProvidedService::init()
      96              : {
      97           48 :     _timestamp       = 0U;
      98           48 :     _repetitionCount = 0U;
      99           48 :     _state           = ProvidedService::ProvidedServiceState::INITIAL_WAIT_PHASE;
     100           48 : }
     101              : 
     102           59 : inline ServiceHandler* ProvidedService::getHandler() const { return _pHandler; }
     103              : 
     104              : inline void ProvidedService::setHandler(ServiceHandler& implementation)
     105              : {
     106              :     _pHandler = &implementation;
     107              : }
     108              : 
     109           44 : inline uint64_t ProvidedService::getTimestamp() const { return _timestamp; }
     110              : 
     111           27 : inline void ProvidedService::setTimestamp(uint64_t const timestamp) { _timestamp = timestamp; }
     112              : 
     113           42 : inline uint32_t ProvidedService::getRepetitionCount() const { return _repetitionCount; }
     114              : 
     115           12 : inline void ProvidedService::setRepetitionCount(uint32_t const count) { _repetitionCount = count; }
     116              : 
     117           26 : inline SdOfferConfig const& ProvidedService::getSdConfig() const { return _sdConfig; }
     118              : 
     119            2 : inline void ProvidedService::setSdConfig(SdOfferConfig const& config) { _sdConfig = config; }
     120              : 
     121          173 : inline ProvidedService::ProvidedServiceState ProvidedService::getState() const { return _state; }
     122              : 
     123           51 : inline void ProvidedService::setState(ProvidedServiceState const state) { _state = state; }
     124              : 
     125           30 : inline void ProvidedService::unregisterDone() const
     126              : {
     127           30 :     if (_pListener != nullptr)
     128              :     {
     129            9 :         _pListener->unregisterDone(*this);
     130              :     }
     131           30 : }
     132              : 
     133              : } // namespace someip
        

Generated by: LCOV version 2.0-1