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 : #pragma once
18 :
19 : #include <app/data-model-provider/MetadataTypes.h>
20 : #include <app/server-cluster/ServerClusterInterface.h>
21 : #include <clusters/Descriptor/Structs.h>
22 : #include <lib/core/DataModelTypes.h>
23 : #include <lib/support/ReadOnlyBuffer.h>
24 :
25 : namespace chip {
26 : namespace app {
27 :
28 : /**
29 : * @brief Defines the interface for an object that can provide information about a Matter endpoint.
30 : *
31 : * This interface is used describe the structure and capabilities of an endpoint, including its device
32 : * types, client clusters, server clusters, and semantic tags.
33 : *
34 : * Implementations of this interface are responsible for providing instances of ServerClusterInterface
35 : * for each server cluster they expose.
36 : */
37 : class EndpointProviderInterface
38 : {
39 : public:
40 354 : virtual ~EndpointProviderInterface() = default;
41 :
42 : using SemanticTag = chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type;
43 :
44 : virtual const DataModel::EndpointEntry & GetEndpointEntry() const = 0;
45 :
46 : virtual CHIP_ERROR SemanticTags(ReadOnlyBufferBuilder<SemanticTag> & out) const = 0;
47 :
48 : virtual CHIP_ERROR DeviceTypes(ReadOnlyBufferBuilder<DataModel::DeviceTypeEntry> & out) const = 0;
49 :
50 : virtual CHIP_ERROR ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const = 0;
51 :
52 : /**
53 : * @brief Retrieves a pointer to the ServerClusterInterface for the given cluster ID.
54 : * The returned pointer shall be valid as long as the EndpointProviderInterface instance is valid.
55 : *
56 : * @param clusterId The ID of the server cluster to retrieve.
57 : * @return A pointer to the ServerClusterInterface if found, otherwise nullptr.
58 : */
59 : virtual ServerClusterInterface * GetServerCluster(ClusterId clusterId) const = 0;
60 :
61 : /**
62 : * @brief Populates the provided buffer with pointers to all ServerClusterInterface instances
63 : * hosted on this endpoint. The returned pointers shall be valid as long as the
64 : * EndpointProviderInterface instance is valid.
65 : *
66 : * @param[out] out The buffer to fill with ServerClusterInterface pointers.
67 : * @return CHIP_NO_ERROR on success or CHIP_ERROR_NO_MEMORY if the buffer is too small.
68 : */
69 : virtual CHIP_ERROR ServerClusterInterfaces(ReadOnlyBufferBuilder<ServerClusterInterface *> & out) const = 0;
70 : };
71 :
72 : } // namespace app
73 : } // namespace chip
|