Skip to content

Commit ff74084

Browse files
malbert-silabsrestyled-commitsCopilot
authored
[Power Topology] Code driven PR#2 (project-chip#42073)
* Move delegate * Restyled by clang-format * Move to ...Delegate * Update src/app/clusters/power-topology-server/PowerTopologyDelegate.h Co-authored-by: Copilot <[email protected]> * Restyled by clang-format * Add to cmake and gn --------- Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 12db354 commit ff74084

File tree

4 files changed

+64
-32
lines changed

4 files changed

+64
-32
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
#pragma once
19+
20+
#include <app-common/zap-generated/cluster-objects.h>
21+
#include <lib/core/Optional.h>
22+
23+
namespace chip {
24+
namespace app {
25+
namespace Clusters {
26+
namespace PowerTopology {
27+
28+
class Delegate
29+
{
30+
public:
31+
virtual ~Delegate() = default;
32+
33+
/**
34+
* Get the Nth EndpointId in the list of available endpoints.
35+
* @param index The index of the EndpointId to be returned.
36+
* @param endpointId A reference to the EndpointId.
37+
* @return Returns a CHIP_NO_ERROR if there was no error and the EndpointId was returned successfully.
38+
* CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is greater than or equal to the length of the list of available endpoints.
39+
*/
40+
virtual CHIP_ERROR GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) = 0;
41+
42+
/**
43+
* Get the Nth EndpointId in the list of active endpoints.
44+
* @param index The index of the EndpointId to be returned.
45+
* @param endpointId A reference to the EndpointId.
46+
* @return Returns a CHIP_NO_ERROR if there was no error and the EndpointId was returned successfully.
47+
* CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is greater than or equal to the length of the list of active endpoints.
48+
*/
49+
virtual CHIP_ERROR GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) = 0;
50+
};
51+
52+
enum class OptionalAttributes : uint32_t
53+
{
54+
kOptionalAttributeAvailableEndpoints = 0x1,
55+
kOptionalAttributeActiveEndpoints = 0x2,
56+
};
57+
58+
} // namespace PowerTopology
59+
} // namespace Clusters
60+
} // namespace app
61+
} // namespace chip

src/app/clusters/power-topology-server/app_config_dependent_sources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ TARGET_SOURCES(
1818
PRIVATE
1919
"${CLUSTER_DIR}/PowerTopologyCluster.cpp"
2020
"${CLUSTER_DIR}/power-topology-server.h"
21+
"${CLUSTER_DIR}/PowerTopologyDelegate.h"
2122
)

src/app/clusters/power-topology-server/app_config_dependent_sources.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
# limitations under the License.
1414
app_config_dependent_sources = [
1515
"PowerTopologyCluster.cpp",
16+
"PowerTopologyDelegate.h",
1617
"power-topology-server.h",
1718
]

src/app/clusters/power-topology-server/power-topology-server.h

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,14 @@
1919

2020
#include <lib/core/Optional.h>
2121

22-
#include <app-common/zap-generated/cluster-objects.h>
22+
#include "PowerTopologyDelegate.h"
2323
#include <app/AttributeAccessInterface.h>
24-
#include <lib/support/CommonIterator.h>
2524

2625
namespace chip {
2726
namespace app {
2827
namespace Clusters {
2928
namespace PowerTopology {
3029

31-
class Delegate
32-
{
33-
public:
34-
virtual ~Delegate() = default;
35-
36-
/**
37-
* Get the Nth EndpointId in the list of available endpoints.
38-
* @param index The index of the EndpointId to be returned.
39-
* @param endpointId A reference to the EndpointId.
40-
* @return Returns a CHIP_NO_ERROR if there was no error and the EndpointId was returned successfully.
41-
* CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is greater than or equal to the length of the list of available endpoints.
42-
*/
43-
virtual CHIP_ERROR GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) = 0;
44-
45-
/**
46-
* Get the Nth EndpointId in the list of active endpoints.
47-
* @param index The index of the EndpointId to be returned.
48-
* @param endpointId A reference to the EndpointId.
49-
* @return Returns a CHIP_NO_ERROR if there was no error and the EndpointId was returned successfully.
50-
* CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is greater than or equal to the length of the list of active endpoints.
51-
*/
52-
virtual CHIP_ERROR GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) = 0;
53-
};
54-
55-
enum class OptionalAttributes : uint32_t
56-
{
57-
kOptionalAttributeAvailableEndpoints = 0x1,
58-
kOptionalAttributeActiveEndpoints = 0x2,
59-
};
60-
6130
class Instance : public AttributeAccessInterface
6231
{
6332
public:

0 commit comments

Comments
 (0)