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 0 : void ServerClusterExtension::Shutdown(ClusterShutdownType shutdownType)
33 : {
34 0 : mUnderlying.Shutdown(shutdownType);
35 0 : mContext = nullptr;
36 0 : }
37 :
38 5 : void ServerClusterExtension::NotifyAttributeChanged(AttributeId id)
39 : {
40 5 : VerifyOrReturn(mContext != nullptr);
41 2 : mVersionDelta++;
42 2 : mContext->interactionContext.dataModelChangeListener.MarkDirty({ mClusterPath.mEndpointId, mClusterPath.mClusterId, id });
43 : }
44 :
45 19 : Span<const ConcreteClusterPath> ServerClusterExtension::GetPaths() const
46 : {
47 19 : return mUnderlying.GetPaths();
48 : }
49 :
50 7 : DataVersion ServerClusterExtension::GetDataVersion(const ConcreteClusterPath & path) const
51 : {
52 7 : DataVersion underlying_version = mUnderlying.GetDataVersion(path);
53 7 : return underlying_version + (path == mClusterPath ? mVersionDelta : 0);
54 : }
55 :
56 0 : BitFlags<DataModel::ClusterQualityFlags> ServerClusterExtension::GetClusterFlags(const ConcreteClusterPath & path) const
57 : {
58 0 : return mUnderlying.GetClusterFlags(path);
59 : }
60 :
61 0 : DataModel::ActionReturnStatus ServerClusterExtension::WriteAttribute(const DataModel::WriteAttributeRequest & request,
62 : AttributeValueDecoder & decoder)
63 : {
64 0 : return mUnderlying.WriteAttribute(request, decoder);
65 : }
66 :
67 0 : void ServerClusterExtension::ListAttributeWriteNotification(const ConcreteAttributePath & path,
68 : DataModel::ListWriteOperation opType, FabricIndex accessingFabric)
69 : {
70 0 : mUnderlying.ListAttributeWriteNotification(path, opType, accessingFabric);
71 0 : }
72 :
73 0 : DataModel::ActionReturnStatus ServerClusterExtension::ReadAttribute(const DataModel::ReadAttributeRequest & request,
74 : AttributeValueEncoder & encoder)
75 : {
76 0 : return mUnderlying.ReadAttribute(request, encoder);
77 : }
78 :
79 0 : CHIP_ERROR ServerClusterExtension::Attributes(const ConcreteClusterPath & path,
80 : ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder)
81 : {
82 0 : return mUnderlying.Attributes(path, builder);
83 : }
84 :
85 0 : CHIP_ERROR ServerClusterExtension::EventInfo(const ConcreteEventPath & path, DataModel::EventEntry & eventInfo)
86 : {
87 0 : return mUnderlying.EventInfo(path, eventInfo);
88 : }
89 :
90 0 : std::optional<DataModel::ActionReturnStatus> ServerClusterExtension::InvokeCommand(const DataModel::InvokeRequest & request,
91 : chip::TLV::TLVReader & input_arguments,
92 : CommandHandler * handler)
93 : {
94 0 : return mUnderlying.InvokeCommand(request, input_arguments, handler);
95 : }
96 :
97 0 : CHIP_ERROR ServerClusterExtension::AcceptedCommands(const ConcreteClusterPath & path,
98 : ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> & builder)
99 : {
100 0 : return mUnderlying.AcceptedCommands(path, builder);
101 : }
102 :
103 0 : CHIP_ERROR ServerClusterExtension::GeneratedCommands(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<CommandId> & builder)
104 : {
105 0 : return mUnderlying.GeneratedCommands(path, builder);
106 : }
107 :
108 : } // namespace app
109 : } // namespace chip
|