LCOV - code coverage report
Current view: top level - libs/bsw/cpp2someip/include/someip - Statistics.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 11 11
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 <cstdint>
      14              : 
      15              : namespace someip
      16              : {
      17              : class Statistics
      18              : {
      19              : public:
      20              :     enum class Counter : uint16_t
      21              :     {
      22              :         PDU_TX,
      23              :         PDU_RX,
      24              :         FRAME_RX,
      25              :         TRAIN_FULL,
      26              :         TRAIN_NOT_AVAILABLE,
      27              :         TRAIN_DUPLICATE_PDU,
      28              :         TRAIN_TIMEOUT,
      29              :         SD_FRAME_TX,
      30              :         SD_FRAME_RX,
      31              :         SD_MESSAGE_RX,
      32              :         SD_REBOOT,
      33              :         SD_FIND_RX,
      34              :         SD_OFFER_RX,
      35              :         SD_FIND_EVENTGROUP_RX,
      36              :         SD_PUBLISH_RX,
      37              :         SD_SUBSCRIBE_RX,
      38              :         SD_SUBSCRIBE_ACK_RX,
      39              :         SD_SUBSCRIBE_NACK_RX,
      40              :         SD_UNKNOWN_RX,
      41              :         SD_MALFORMED_MESSAGE_RX,
      42              :         RPC_WRONG_PROTOCOL_VERSION_RX,
      43              :         RPC_WRONG_INTERFACE_VERSION_RX,
      44              :         RPC_UNKNOWN_SERVICE_RX,
      45              :         RPC_UNKNOWN_METHOD_RX,
      46              :         RPC_MALFORMED_MESSAGE_RX,
      47              :         COUNTER_ARRAY_SIZE
      48              :     };
      49              : 
      50              :     static void reset();
      51              : 
      52              :     static void incCounter(Counter counter);
      53              :     static uint32_t getCounter(Counter counter);
      54              :     static void resetCounter(Counter counter);
      55              : 
      56              :     static uint32_t getNumSentTrains();
      57              : 
      58              :     static uint32_t numIncomingSubscriptions;
      59              :     static uint32_t maxNumIncomingSubscriptions;
      60              :     static uint32_t numRemoteServices;
      61              :     static uint32_t maxNumRemoteServices;
      62              :     static uint32_t numProvidedServices;
      63              :     static uint32_t maxNumProvidedServices;
      64              :     static uint32_t numQueries;
      65              :     static uint32_t maxNumQueries;
      66              : 
      67              : private:
      68              :     static uint32_t counters[static_cast<uint16_t>(Counter::COUNTER_ARRAY_SIZE)];
      69              : };
      70              : 
      71              : // static
      72          151 : inline void Statistics::incCounter(Counter const counter)
      73              : {
      74          151 :     if (static_cast<uint16_t>(counter) < static_cast<uint16_t>(Counter::COUNTER_ARRAY_SIZE) - 1U)
      75              :     {
      76          145 :         ++counters[static_cast<uint16_t>(counter)];
      77              :     }
      78          151 : }
      79              : 
      80              : // static
      81           48 : inline uint32_t Statistics::getCounter(Counter const counter)
      82              : {
      83           48 :     return counters[static_cast<uint16_t>(counter)];
      84              : }
      85              : 
      86              : inline void Statistics::resetCounter(Counter const counter)
      87              : {
      88              :     counters[static_cast<uint16_t>(counter)] = 0U;
      89              : }
      90              : 
      91              : // static
      92            7 : inline uint32_t Statistics::getNumSentTrains()
      93              : {
      94            7 :     return counters[static_cast<uint16_t>(Counter::TRAIN_FULL)]
      95            7 :            + counters[static_cast<uint16_t>(Counter::TRAIN_NOT_AVAILABLE)]
      96            7 :            + counters[static_cast<uint16_t>(Counter::TRAIN_DUPLICATE_PDU)]
      97            7 :            + counters[static_cast<uint16_t>(Counter::TRAIN_TIMEOUT)];
      98              : }
      99              : 
     100              : } // namespace someip
        

Generated by: LCOV version 2.0-1