| /* | |
| * Copyright (c) 2026 Project CHIP Authors | |
| * All rights reserved. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| #pragma once | |
| #include <access/AccessControl.h> | |
| #include <app/clusters/groups-server/GroupsClusterContext.h> | |
| #include <app/clusters/scenes-server/ScenesIntegrationDelegate.h> | |
| #include <app/server-cluster/DefaultServerCluster.h> | |
| #include <clusters/Groups/Commands.h> | |
| #include <clusters/Groups/Ids.h> | |
| #include <credentials/GroupDataProvider.h> | |
| #include <optional> | |
| namespace chip::app::Clusters { | |
| /// Full Groups cluster implementation: group membership can be managed through the cluster | |
| /// commands. Applications should use the `GroupsCluster` alias from GroupsCluster.h rather than | |
| /// naming this class directly. | |
| class GroupsClusterImpl : public DefaultServerCluster | |
| { | |
| public: | |
| using Context = GroupsClusterContext; | |
| GroupsClusterImpl(EndpointId endpointId, const Context & context) : | |
| DefaultServerCluster({ endpointId, Groups::Id }), mGroupDataProvider(context.groupDataProvider), | |
| mScenesIntegration(context.scenesIntegration), mIdentifyIntegration(context.identifyIntegration) | |
| {} | |
| // ServerClusterInterface | |
| CHIP_ERROR Attributes(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) override; | |
| CHIP_ERROR AcceptedCommands(const ConcreteClusterPath & path, | |
| ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> & builder) override; | |
| CHIP_ERROR GeneratedCommands(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<CommandId> & builder) override; | |
| DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest & request, | |
| AttributeValueEncoder & encoder) override; | |
| std::optional<DataModel::ActionReturnStatus> InvokeCommand(const DataModel::InvokeRequest & request, | |
| TLV::TLVReader & input_arguments, CommandHandler * handler) override; | |
| private: | |
| Credentials::GroupDataProvider & mGroupDataProvider; | |
| scenes::ScenesIntegrationDelegate * mScenesIntegration; | |
| IdentifyIntegrationDelegate * mIdentifyIntegration; | |
| Protocols::InteractionModel::Status AddGroup(GroupId groupID, CharSpan groupName, | |
| const chip::Access::SubjectDescriptor & subjectDescriptor); | |
| }; | |
| } // namespace chip::app::Clusters |