/src/connectedhomeip/src/app/clusters/access-control-server/CodegenIntegration.cpp
Line | Count | Source |
1 | | /** |
2 | | * |
3 | | * Copyright (c) 2025 Project CHIP Authors |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <app/clusters/access-control-server/access-control-cluster.h> |
19 | | #include <app/static-cluster-config/AccessControl.h> |
20 | | #include <app/util/config.h> |
21 | | #include <app/util/generic-callbacks.h> |
22 | | #include <data-model-providers/codegen/ClusterIntegration.h> |
23 | | |
24 | | namespace { |
25 | | using namespace chip; |
26 | | using namespace chip::app; |
27 | | using namespace chip::app::Clusters; |
28 | | using namespace chip::app::Clusters::AccessControl; |
29 | | |
30 | | static_assert((AccessControl::StaticApplicationConfig::kFixedClusterConfig.size() == 1 && |
31 | | AccessControl::StaticApplicationConfig::kFixedClusterConfig[0].endpointNumber == kRootEndpointId) || |
32 | | AccessControl::StaticApplicationConfig::kFixedClusterConfig.size() == 0); |
33 | | |
34 | | LazyRegisteredServerCluster<AccessControlCluster> gServer; |
35 | | |
36 | | class IntegrationDelegate : public CodegenClusterIntegration::Delegate |
37 | | { |
38 | | public: |
39 | | ServerClusterRegistration & CreateRegistration(EndpointId endpointId, unsigned clusterInstanceIndex, |
40 | | uint32_t optionalAttributeBits, uint32_t featureMap) override |
41 | 0 | { |
42 | 0 | gServer.Create(AccessControlCluster::Context{ |
43 | 0 | .persistentStorage = Server::GetInstance().GetPersistentStorage(), |
44 | 0 | .fabricTable = Server::GetInstance().GetFabricTable(), |
45 | 0 | .accessControl = Server::GetInstance().GetAccessControl(), |
46 | 0 | }); |
47 | 0 | return gServer.Registration(); |
48 | 0 | } |
49 | | |
50 | | ServerClusterInterface * FindRegistration(unsigned clusterInstanceIndex) override |
51 | 0 | { |
52 | 0 | VerifyOrReturnValue(gServer.IsConstructed(), nullptr); |
53 | 0 | return &gServer.Cluster(); |
54 | 0 | } |
55 | | |
56 | 0 | void ReleaseRegistration(unsigned clusterInstanceIndex) override { gServer.Destroy(); } |
57 | | }; |
58 | | |
59 | | } // namespace |
60 | | |
61 | | void MatterAccessControlClusterInitCallback(EndpointId endpointId) |
62 | 0 | { |
63 | 0 | IntegrationDelegate integrationDelegate; |
64 | |
|
65 | 0 | CodegenClusterIntegration::RegisterServer( |
66 | 0 | { |
67 | 0 | .endpointId = endpointId, |
68 | 0 | .clusterId = AccessControl::Id, |
69 | 0 | .fixedClusterInstanceCount = AccessControl::StaticApplicationConfig::kFixedClusterConfig.size(), |
70 | 0 | .maxClusterInstanceCount = 1, // Cluster is a singleton on the root node and this is the only thing supported |
71 | 0 | .fetchFeatureMap = false, |
72 | 0 | .fetchOptionalAttributes = false, |
73 | 0 | }, |
74 | 0 | integrationDelegate); |
75 | 0 | } |
76 | | |
77 | | void MatterAccessControlClusterShutdownCallback(EndpointId endpointId, MatterClusterShutdownType shutdownType) |
78 | 0 | { |
79 | 0 | IntegrationDelegate integrationDelegate; |
80 | |
|
81 | 0 | CodegenClusterIntegration::UnregisterServer( |
82 | 0 | { |
83 | 0 | .endpointId = endpointId, |
84 | 0 | .clusterId = AccessControl::Id, |
85 | 0 | .fixedClusterInstanceCount = AccessControl::StaticApplicationConfig::kFixedClusterConfig.size(), |
86 | 0 | .maxClusterInstanceCount = 1, // Cluster is a singleton on the root node and this is the only thing supported |
87 | 0 | }, |
88 | 0 | integrationDelegate, shutdownType); |
89 | 0 | } |
90 | | |
91 | 0 | void MatterAccessControlPluginServerInitCallback() {} |
92 | | |
93 | 0 | void MatterAccessControlPluginServerShutdownCallback() {} |