mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 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 |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 21 | * This file defines an interface that exposes all the public subscription information APIs. |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 22 | * The interface is implemented by the InteractionModelEngine to avoid creating unnecessary dependencies |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 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. |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 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 | |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 35 | class SubscriptionsInfoProvider |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 36 | { |
| 37 | public: |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 38 | virtual ~SubscriptionsInfoProvider(){}; |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 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 |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 44 | * @param[in] subjectID NodeId of the subject |
mkardous-silabs | 83e47bf | 2024-02-05 15:33:24 -0500 | [diff] [blame] | 45 | * subjectID may encode a CAT in the reserved section of the NodeID. |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 46 | * |
| 47 | * @return true subject has at least one active subscription with the device |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 48 | * false subject doesn't have any active subscription with the device |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 49 | */ |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 50 | virtual bool SubjectHasActiveSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0; |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @brief Check if a given subject (CAT or operational NodeId) has at least 1 persisted subscription. |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 54 | * See the CHIP_CONFIG_PERSIST_SUBSCRIPTIONS for more information on persisted subscriptions. |
| 55 | * |
| 56 | * @param[in] aFabricIndex fabric index of the subject |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 57 | * @param[in] subjectID NodeId of the subject |
mkardous-silabs | 83e47bf | 2024-02-05 15:33:24 -0500 | [diff] [blame] | 58 | * subjectID may encode a CAT in the reserved section of the NodeID |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 59 | * |
| 60 | * @return true subject has at least one persisted subscription with the device |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 61 | * false subject doesn't have any persisted subscription with the device |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 62 | */ |
mkardous-silabs | 9526318 | 2024-01-31 23:17:45 -0500 | [diff] [blame] | 63 | virtual bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0; |
mkardous-silabs | d61bfd6 | 2024-01-30 17:50:01 -0500 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace app |
| 67 | } // namespace chip |