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/SomeIpConstants.h"
14 : #include "someip/SubscribedEventGroup.h"
15 : #include "someip/SubscriptionEndpoint.h"
16 :
17 : #include <ip/IPAddress.h>
18 :
19 : namespace someip
20 : {
21 : class ISubscriptionManager
22 : {
23 : public:
24 : enum class InternalSubscribeResult : uint8_t
25 : {
26 : INTERNAL_SUBSCRIBE_OK,
27 : INTERNAL_SUBSCRIBE_ERROR,
28 : INTERNAL_ALREADY_SUBSCRIBED
29 : };
30 :
31 47 : virtual ~ISubscriptionManager() = default;
32 :
33 : /**
34 : * Pure virtual function that adds a subscription associated with:
35 : * - ip and port
36 : *
37 : * for an eventgroup identified by:
38 : *
39 : * - serviceId
40 : * - majorVersion
41 : * - instanceId
42 : * - eventgroupId
43 : *
44 : * \return result of subscription
45 : */
46 : virtual InternalSubscribeResult addSubscription(
47 : service_id::type serviceId,
48 : major_version::type majorVersion,
49 : instance_id::type instanceId,
50 : eventgroup_id::type eventgroupId,
51 : ttl::type ttl,
52 : ::ip::IPAddress const& ipAddress,
53 : uint16_t port)
54 : = 0;
55 :
56 : /**
57 : * Pure virtual function that remove a subscription associated with:
58 : * - ip and port
59 : *
60 : * for an eventgroup identified by:
61 : *
62 : * - serviceId
63 : * - majorVersion
64 : * - instanceId
65 : * - eventgroupId
66 : */
67 : virtual void removeSubscription(
68 : service_id::type serviceId,
69 : major_version::type majorVersion,
70 : instance_id::type instanceId,
71 : eventgroup_id::type eventgroupId,
72 : ::ip::IPAddress const& ipAddress,
73 : uint16_t port)
74 : = 0;
75 :
76 : /**
77 : * Overloaded pure virtual function that remove all subscriptions
78 : * for an eventgroup identified by:
79 : *
80 : * - serviceId
81 : * - majorVersion
82 : * - instanceId
83 : * - eventgroup
84 : */
85 : virtual void removeSubscriptions(
86 : service_id::type serviceId,
87 : major_version::type majorVersion,
88 : instance_id::type instanceId,
89 : eventgroup_id::type eventgroupId)
90 : = 0;
91 :
92 : /**
93 : * Overloaded pure virtual function that removes all subscriptions for
94 : * all subscriptions associated with given ip.
95 : */
96 : virtual void removeSubscriptions(::ip::IPAddress const& ipAddress) = 0;
97 :
98 : /**
99 : * Pure virtual function that is responsible for updating **TTL** of all subscriptions.
100 : *
101 : * \post subscriptions with ttl == 0 will be removed
102 : */
103 : virtual void updateTTLs(uint32_t expiredSeconds) = 0;
104 :
105 : /**
106 : * Pure virtual function that returns subscriptions of an eventgroup.
107 : *
108 : * \return subscriptions or 0L if none found.
109 : */
110 : virtual SubscriptionEndpointList* getSubscriptions(SubscribedEventGroup const& eventgroup) const
111 : = 0;
112 :
113 : /**
114 : * Pure virtual function that returns current number of subscriptions.
115 : */
116 : virtual uint16_t getCurrentNumberOfSubscriptions() const = 0;
117 :
118 : /**
119 : * Pure virtual function that returns maximum number of subscriptions.
120 : */
121 : virtual uint16_t getMaximumNumberOfSubscriptions() const = 0;
122 : };
123 : } // namespace someip
|