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/ISomeIpSerializable.h"
14 : #include "someip/SomeIpConstants.h"
15 : #include <ip/IPEndpoint.h>
16 :
17 : #include <etl/span.h>
18 : #include <cstdint>
19 :
20 : namespace someip
21 : {
22 : /**
23 : * Interface for an event-sender.
24 : *
25 : * Note: For an event without payload the corresponding ISomeIpSerializable pointer should be 0L.
26 : */
27 : class IEventSender
28 : {
29 : public:
30 17 : IEventSender() = default;
31 : IEventSender(IEventSender const&) = delete;
32 : IEventSender& operator=(IEventSender const&) = delete;
33 :
34 17 : virtual ~IEventSender() = default;
35 :
36 : enum class ErrorCode : uint8_t
37 : {
38 : /** event was sent */
39 : EVENT_SEND_OK,
40 : /** error happened during sending */
41 : EVENT_SEND_ERROR,
42 : /** not enough memory to send the event */
43 : EVENT_SEND_OUT_OF_MEMORY,
44 :
45 : /** internal codes **/
46 : EVENT_SEND_PENDING
47 : };
48 :
49 : /** send unicast to specific address */
50 : virtual ErrorCode sendEvent(
51 : service_id::type serviceId,
52 : major_version::type majorVersion,
53 : uint16_t eventId,
54 : uint16_t maximumDelayTime,
55 : ISomeIpSerializable const* payload,
56 : uint16_t sourcePort,
57 : uint8_t proto,
58 : ::ip::IPEndpoint const& destinationEndpoint,
59 : uint16_t sessionId = 0U)
60 : = 0;
61 :
62 : /** send unicast to subscribers */
63 : virtual ErrorCode sendEvent(
64 : service_id::type serviceId,
65 : major_version::type majorVersion,
66 : instance_id::type instanceId,
67 : uint16_t eventId,
68 : ::etl::span<uint16_t const> eventGroupIds,
69 : uint16_t maximumDelayTime,
70 : ISomeIpSerializable const* payload,
71 : uint16_t sourcePort,
72 : uint8_t proto,
73 : uint16_t sessionId = 0U)
74 : = 0;
75 :
76 : /** send multicast to subscribers */
77 : virtual ErrorCode sendMulticastEvent(
78 : service_id::type serviceId,
79 : major_version::type majorVersion,
80 : instance_id::type instanceId,
81 : uint16_t eventId,
82 : ::etl::span<uint16_t const> eventGroupIds,
83 : uint16_t maximumDelayTime,
84 : ISomeIpSerializable const* payload,
85 : uint16_t sourcePort,
86 : uint8_t proto,
87 : ::ip::IPEndpoint const& destinationEndpoint,
88 : uint16_t sessionId = 0U)
89 : = 0;
90 : };
91 :
92 : } // namespace someip
|