Line data Source code
1 : /*
2 : * Copyright (c) 2025 Project CHIP Authors
3 : * All rights reserved.
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 "ServerClusterInterface.h"
19 : #include <app/server-cluster/ServerClusterExtension.h>
20 : #include <lib/core/DataModelTypes.h>
21 :
22 : namespace chip {
23 : namespace app {
24 :
25 2 : CHIP_ERROR ServerClusterExtension::Startup(ServerClusterContext & context)
26 : {
27 2 : mContext = &context;
28 2 : mVersionDelta = 0;
29 2 : return mUnderlying.Startup(context);
30 : }
31 :
32 1 : void ServerClusterExtension::Shutdown(ClusterShutdownType shutdownType)
33 : {
34 1 : mUnderlying.Shutdown(shutdownType);
35 1 : mContext = nullptr;
36 1 : }
37 :
38 4 : void ServerClusterExtension::NotifyAttributeChanged(AttributeId id)
39 : {
40 4 : VerifyOrReturn(mContext != nullptr);
41 2 : mVersionDelta++;
42 2 : mContext->provider.NotifyAttributeChanged({ mClusterPath.mEndpointId, mClusterPath.mClusterId, id },
43 : DataModel::AttributeChangeType::kReportable);
44 : }
45 :
46 19 : Span<const ConcreteClusterPath> ServerClusterExtension::GetPaths() const
47 : {
48 19 : return mUnderlying.GetPaths();
49 : }
50 :
51 6 : DataVersion ServerClusterExtension::GetDataVersion(const ConcreteClusterPath & path) const
52 : {
53 6 : DataVersion underlying_version = mUnderlying.GetDataVersion(path);
54 6 : return underlying_version + (path == mClusterPath ? mVersionDelta : 0);
55 : }
56 :
57 0 : BitFlags<DataModel::ClusterQualityFlags> ServerClusterExtension::GetClusterFlags(const ConcreteClusterPath & path) const
58 : {
59 0 : return mUnderlying.GetClusterFlags(path);
60 : }
61 :
62 0 : DataModel::ActionReturnStatus ServerClusterExtension::WriteAttribute(const DataModel::WriteAttributeRequest & request,
63 : AttributeValueDecoder & decoder)
64 : {
65 0 : return mUnderlying.WriteAttribute(request, decoder);
66 : }
67 :
68 0 : void ServerClusterExtension::ListAttributeWriteNotification(const ConcreteAttributePath & path,
69 : DataModel::ListWriteOperation opType, FabricIndex accessingFabric)
70 : {
71 0 : mUnderlying.ListAttributeWriteNotification(path, opType, accessingFabric);
72 0 : }
73 :
74 0 : DataModel::ActionReturnStatus ServerClusterExtension::ReadAttribute(const DataModel::ReadAttributeRequest & request,
75 : AttributeValueEncoder & encoder)
76 : {
77 0 : return mUnderlying.ReadAttribute(request, encoder);
78 : }
79 :
80 0 : CHIP_ERROR ServerClusterExtension::Attributes(const ConcreteClusterPath & path,
81 : ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder)
82 : {
83 0 : return mUnderlying.Attributes(path, builder);
84 : }
85 :
86 0 : CHIP_ERROR ServerClusterExtension::EventInfo(const ConcreteEventPath & path, DataModel::EventEntry & eventInfo)
87 : {
88 0 : return mUnderlying.EventInfo(path, eventInfo);
89 : }
90 :
91 0 : std::optional<DataModel::ActionReturnStatus> ServerClusterExtension::InvokeCommand(const DataModel::InvokeRequest & request,
92 : chip::TLV::TLVReader & input_arguments,
93 : CommandHandler * handler)
94 : {
95 0 : return mUnderlying.InvokeCommand(request, input_arguments, handler);
96 : }
97 :
98 0 : CHIP_ERROR ServerClusterExtension::AcceptedCommands(const ConcreteClusterPath & path,
99 : ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> & builder)
100 : {
101 0 : return mUnderlying.AcceptedCommands(path, builder);
102 : }
103 :
104 0 : CHIP_ERROR ServerClusterExtension::GeneratedCommands(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<CommandId> & builder)
105 : {
106 0 : return mUnderlying.GeneratedCommands(path, builder);
107 : }
108 :
109 : } // namespace app
110 : } // namespace chip
|