Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2024 Project CHIP Authors
4 : * All rights reserved.
5 : *
6 : * Licensed under the Apache License, Version 2.0 (the "License");
7 : * you may not use this file except in compliance with the License.
8 : * You may obtain a copy of the License at
9 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
11 : *
12 : * Unless required by applicable law or agreed to in writing, software
13 : * distributed under the License is distributed on an "AS IS" BASIS,
14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : * See the License for the specific language governing permissions and
16 : * limitations under the License.
17 : */
18 :
19 : /**
20 : * @file
21 : * This file defines an interface that exposes all the public subscription information APIs.
22 : * The interface is implemented by the InteractionModelEngine to avoid creating unnecessary dependencies
23 : * since the IMEngine has more dependency than its consummers need.
24 : * By leveraging the SubscriptionInfoProvider APIs, a consumer avoids depending on the global data model functions.
25 : */
26 :
27 : #pragma once
28 :
29 : #include <lib/core/DataModelTypes.h>
30 : #include <lib/core/NodeId.h>
31 :
32 : namespace chip {
33 : namespace app {
34 :
35 : class SubscriptionsInfoProvider
36 : {
37 : public:
38 61 : virtual ~SubscriptionsInfoProvider(){};
39 :
40 : /**
41 : * @brief Check if a given subject (CAT or operational NodeId) has at least 1 active subscription.
42 : *
43 : * @param[in] aFabricIndex fabric index of the subject
44 : * @param[in] subjectID NodeId of the subject
45 : * subjectID may encode a CAT in the reserved section of the NodeID.
46 : *
47 : * @return true subject has at least one active subscription with the device
48 : * false subject doesn't have any active subscription with the device
49 : */
50 : virtual bool SubjectHasActiveSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0;
51 :
52 : /**
53 : * @brief Check if a given subject (CAT or operational NodeId) has at least 1 persisted subscription.
54 : * See the CHIP_CONFIG_PERSIST_SUBSCRIPTIONS for more information on persisted subscriptions.
55 : *
56 : * @param[in] aFabricIndex fabric index of the subject
57 : * @param[in] subjectID NodeId of the subject
58 : * subjectID may encode a CAT in the reserved section of the NodeID
59 : *
60 : * @return true subject has at least one persisted subscription with the device
61 : * false subject doesn't have any persisted subscription with the device
62 : */
63 : virtual bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0;
64 :
65 : /**
66 : * @brief Check if a given fabric has at least 1 active subscription.
67 : *
68 : * @param aFabricIndex fabric index for which we want to validate is has at least one active subscription
69 : *
70 : * @return true fabric has at least one active subscription
71 : * false fabric doesn't have any active subscription or failed to validate
72 : */
73 : virtual bool FabricHasAtLeastOneActiveSubscription(FabricIndex aFabricIndex) = 0;
74 : };
75 :
76 : } // namespace app
77 : } // namespace chip
|