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 : #include "SpanEndpoint.h"
18 :
19 : #include <app/ConcreteClusterPath.h>
20 : #include <app/server-cluster/ServerClusterContext.h>
21 : #include <clusters/Descriptor/ClusterId.h>
22 : #include <lib/core/CHIPError.h>
23 : #include <lib/support/Span.h>
24 : #include <lib/support/logging/CHIPLogging.h>
25 :
26 : namespace chip {
27 : namespace app {
28 :
29 : // Builder implementation
30 6 : SpanEndpoint::Builder & SpanEndpoint::Builder::SetClientClusters(Span<const ClusterId> clientClusters)
31 : {
32 6 : mClientClusters = clientClusters;
33 6 : return *this;
34 : }
35 :
36 6 : SpanEndpoint::Builder & SpanEndpoint::Builder::SetSemanticTags(Span<const SemanticTag> semanticTags)
37 : {
38 6 : mSemanticTags = semanticTags;
39 6 : return *this;
40 : }
41 :
42 6 : SpanEndpoint::Builder & SpanEndpoint::Builder::SetDeviceTypes(Span<const DataModel::DeviceTypeEntry> deviceTypes)
43 : {
44 6 : mDeviceTypes = deviceTypes;
45 6 : return *this;
46 : }
47 :
48 159 : SpanEndpoint SpanEndpoint::Builder::Build()
49 : {
50 159 : return SpanEndpoint(mClientClusters, mSemanticTags, mDeviceTypes);
51 : }
52 :
53 : CHIP_ERROR
54 4 : SpanEndpoint::SemanticTags(ReadOnlyBufferBuilder<Clusters::Descriptor::Structs::SemanticTagStruct::Type> & out) const
55 : {
56 4 : return out.ReferenceExisting(mSemanticTags);
57 : }
58 :
59 4 : CHIP_ERROR SpanEndpoint::DeviceTypes(ReadOnlyBufferBuilder<DataModel::DeviceTypeEntry> & out) const
60 : {
61 4 : return out.ReferenceExisting(mDeviceTypes);
62 : }
63 :
64 4 : CHIP_ERROR SpanEndpoint::ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const
65 : {
66 4 : return out.ReferenceExisting(mClientClusters);
67 : }
68 :
69 : // Private constructor for Builder
70 159 : SpanEndpoint::SpanEndpoint(const Span<const ClusterId> & clientClusters, const Span<const SemanticTag> & semanticTags,
71 159 : const Span<const DataModel::DeviceTypeEntry> & deviceTypes) :
72 159 : mDeviceTypes(deviceTypes),
73 159 : mSemanticTags(semanticTags), mClientClusters(clientClusters)
74 159 : {}
75 :
76 : } // namespace app
77 : } // namespace chip
|