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

            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/RebootTrackerEndpoint.h"
      14              : 
      15              : #include <ip/IPAddress.h>
      16              : 
      17              : #include <etl/flat_map.h>
      18              : #include <cstdint>
      19              : 
      20              : namespace someip
      21              : {
      22              : /**
      23              :  * Information about last SD message
      24              :  */
      25              : struct SessionInfo
      26              : {
      27           63 :     SessionInfo(
      28              :         ::ip::IPAddress const& remoteIp,
      29              :         bool const isMulticast,
      30              :         uint16_t const sessionId,
      31              :         bool const rebootFlag)
      32           63 :     : remoteIp(remoteIp), isMulticast(isMulticast), sessionId(sessionId), rebootFlag(rebootFlag)
      33           63 :     {}
      34              : 
      35              :     ::ip::IPAddress const& remoteIp;
      36              :     bool isMulticast;
      37              :     uint16_t sessionId;
      38              :     bool rebootFlag;
      39              : };
      40              : 
      41              : /**
      42              :  * Responsible to detect reboot of remote systems.
      43              :  */
      44              : class RebootTracker
      45              : {
      46              : public:
      47              :     /**
      48              :      * Lifecycle method that clears EndpointMap of RebootTracker.
      49              :      */
      50              :     void init();
      51              : 
      52              :     /**
      53              :      * Checks whether a reboot has occured based on information about
      54              :      * the latest SD message.
      55              :      *
      56              :      * \param sessionInfo information about the last SD message
      57              :      *
      58              :      * \return true if a reboot was detected.
      59              :      */
      60              :     bool evaluate(SessionInfo const& session) const;
      61              : 
      62              :     /**
      63              :      * Applies changes based on information about the latest
      64              :      * SD message.
      65              :      *
      66              :      * \param sessionInfo information about the last SD message
      67              :      *
      68              :      */
      69              :     void apply(SessionInfo const& session);
      70              : 
      71              : protected:
      72              :     using EndpointMap
      73              :         = ::etl::iflat_map<::ip::IPAddress, RebootTrackerEndpoint, ::ip::IPAddressCompareLess>;
      74              : 
      75              :     explicit RebootTracker(EndpointMap& endpointMap);
      76              : 
      77              : private:
      78              :     EndpointMap::iterator addEndpoint(::ip::IPAddress const& remoteIp);
      79              : 
      80              :     EndpointMap& _endpoints;
      81              : };
      82              : 
      83              : namespace declare
      84              : {
      85              : template<uint16_t NUM_ENDPOINTS>
      86              : class RebootTracker : public ::someip::RebootTracker
      87              : {
      88              : public:
      89           33 :     RebootTracker() : ::someip::RebootTracker(_endpointMap) {}
      90              : 
      91              : private:
      92              :     ::etl::
      93              :         flat_map<::ip::IPAddress, RebootTrackerEndpoint, NUM_ENDPOINTS, ::ip::IPAddressCompareLess>
      94              :             _endpointMap;
      95              : };
      96              : } // namespace declare
      97              : } // namespace someip
        

Generated by: LCOV version 2.0-1