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

            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/BufferedEventSender.h"
      14              : #include "someip/IEventListener.h"
      15              : #include "someip/IEventReceiver.h"
      16              : #include "someip/IEventSender.h"
      17              : #include "someip/SubscriptionEndpoint.h"
      18              : 
      19              : #include <etl/intrusive_forward_list.h>
      20              : #include <etl/intrusive_links.h>
      21              : #include <etl/span.h>
      22              : #include <etl/vector.h>
      23              : #include <cstdint>
      24              : 
      25              : namespace someip
      26              : {
      27              : class ISubscriptionManager;
      28              : 
      29              : class EventTransceiver
      30              : : public IEventSender
      31              : , public IEventReceiver
      32              : {
      33              : public:
      34              :     EventTransceiver(
      35              :         BufferedEventSender& eventSender,
      36              :         ISubscriptionManager& subscriptionManager,
      37              :         ::etl::ivector<SubscriptionEndpoint>& subscriptionEndpoints);
      38              : 
      39              :     /* Clears event listeners list. */
      40              :     void shutdown();
      41              : 
      42              :     /* Sends event to the given unicast destinationEndpoint. */
      43              :     IEventSender::ErrorCode sendEvent(
      44              :         service_id::type,
      45              :         major_version::type,
      46              :         uint16_t eventId,
      47              :         uint16_t maximumDelayTime,
      48              :         ISomeIpSerializable const* payload,
      49              :         port::type, // source port
      50              :         proto::type,
      51              :         ::ip::IPEndpoint const& destinationEndpoint,
      52              :         uint16_t sessionId = 0U) override;
      53              : 
      54              :     /**
      55              :      * Sends event to all remote endpoints that are subscribed to an eventgroup
      56              :      * containing the event
      57              :      */
      58              :     IEventSender::ErrorCode sendEvent(
      59              :         service_id::type,
      60              :         major_version::type,
      61              :         instance_id::type,
      62              :         uint16_t eventId,
      63              :         ::etl::span<eventgroup_id::type const>,
      64              :         uint16_t maximumDelayTime,
      65              :         ISomeIpSerializable const* payload,
      66              :         port::type, // source port
      67              :         proto::type,
      68              :         uint16_t sessionId = 0U) override;
      69              : 
      70              :     /**
      71              :      * Sends event to given multicast destinationEndpoint if a subscription to
      72              :      * an eventgroup is present that contains the event.
      73              :      */
      74              :     IEventSender::ErrorCode sendMulticastEvent(
      75              :         service_id::type,
      76              :         major_version::type,
      77              :         instance_id::type,
      78              :         uint16_t eventId,
      79              :         ::etl::span<eventgroup_id::type const>,
      80              :         uint16_t maximumDelayTime,
      81              :         ISomeIpSerializable const* payload,
      82              :         port::type, // source port
      83              :         proto::type,
      84              :         ::ip::IPEndpoint const& destinationEndpoint,
      85              :         uint16_t sessionId = 0U) override;
      86              : 
      87              :     /**
      88              :      *  Forwards information of received event to all entries of event listener
      89              :      *  list.
      90              :      */
      91              :     void eventReceived(
      92              :         service_id::type,
      93              :         uint16_t eventId,
      94              :         instance_id::type,
      95              :         major_version::type,
      96              :         SomeIpParser& parser) override;
      97              : 
      98              :     /* Adds entry to the event listener list. */
      99              :     void addEventListener(IEventListener& listener) override;
     100              :     /* Removes entry from the event listener list. */
     101              :     void removeEventListener(IEventListener& listener) override;
     102              : 
     103              : private:
     104              :     BufferedEventSender& _eventSender;
     105              :     ISubscriptionManager& _subscriptionManager;
     106              : 
     107              :     using EventListenerList = ::etl::intrusive_forward_list<IEventListener, ::etl::forward_link<0>>;
     108              :     EventListenerList _eventListeners;
     109              : 
     110              :     ::etl::ivector<SubscriptionEndpoint>& _subscriptionEndpoints;
     111              : };
     112              : 
     113              : namespace declare
     114              : {
     115              : 
     116              : template<uint8_t NUM_SUBSCRIPTION_ENDPOINTS>
     117              : class EventTransceiver : public ::someip::EventTransceiver
     118              : {
     119              : public:
     120              :     EventTransceiver(
     121              :         ::someip::BufferedEventSender& eventSender, ISubscriptionManager& subscriptionManager);
     122              : 
     123              : private:
     124              :     ::etl::vector<SubscriptionEndpoint, NUM_SUBSCRIPTION_ENDPOINTS> _subscriptionEndpoints;
     125              : };
     126              : 
     127              : template<uint8_t NUM_SUBSCRIPTION_ENDPOINTS>
     128            6 : inline EventTransceiver<NUM_SUBSCRIPTION_ENDPOINTS>::EventTransceiver(
     129              :     ::someip::BufferedEventSender& eventSender, ISubscriptionManager& subscriptionManager)
     130              : : ::someip::EventTransceiver(eventSender, subscriptionManager, _subscriptionEndpoints)
     131            6 : , _subscriptionEndpoints()
     132            6 : {}
     133              : 
     134              : } // namespace declare
     135              : 
     136              : } // namespace someip
        

Generated by: LCOV version 2.0-1