Coverage Report

Created: 2026-06-30 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/connectedhomeip/src/app/clusters/actions-server/CodegenIntegration.h
Line
Count
Source
1
/*
2
 *
3
 *    Copyright (c) 2024-2026 Project CHIP Authors
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/clusters/actions-server/ActionsCluster.h>
20
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
21
namespace chip::app::Clusters::Actions {
22
23
/**
24
 * Legacy wrapper around ActionsCluster for backwards compatibility with existing applications.
25
 *
26
 * LIMITATIONS:
27
 *   - Each instance manages a single aggregator endpoint. While the spec permits multiple
28
 *     aggregator endpoints on a device (each with its own Actions cluster), this implementation
29
 *     supports one instance per aggregator endpoint — create one ActionsServer per aggregator.
30
 *   - The Delegate interface has no EndpointId parameters; it is scoped to a single endpoint
31
 *     instance.
32
 *
33
 * NEW CODE should use ActionsCluster directly (see ActionsCluster.h), which integrates cleanly
34
 * with the code-driven data model and does not carry the Ember/ZAP compatibility overhead.
35
 */
36
class ActionsServer
37
{
38
public:
39
    /**
40
     * Creates an ActionsServer for the given aggregator endpoint. Only one instance should
41
     * exist per node. The constructor logs an error if this constraint is violated.
42
     *
43
     * @param endpointId The aggregator endpoint on which the Actions cluster resides.
44
     * @param delegate   Application-supplied delegate providing action/endpoint-list data
45
     *                   and command handling.
46
     */
47
    ActionsServer(EndpointId endpointId, Delegate & delegate);
48
    ~ActionsServer();
49
50
    /**
51
     * Register the actions cluster instance with the codegen data model provider.
52
     * @return Returns an error if registration fails.
53
     */
54
    CHIP_ERROR Init();
55
56
    /**
57
     * Unregister the actions cluster instance from the data model provider.
58
     */
59
    void Shutdown();
60
61
    // Legacy Notifiers - these proxy directly to the new cluster
62
    void ActionListModified(EndpointId aEndpoint);
63
    void EndpointListModified(EndpointId aEndpoint);
64
65
    CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder);
66
67
0
    EndpointId GetEndpointId() { return mCluster.Cluster().GetPaths()[0].mEndpointId; }
68
69
private:
70
    CHIP_ERROR ReadActionListAttribute(const ConcreteReadAttributePath & aPath,
71
                                       const AttributeValueEncoder::ListEncodeHelper & aEncoder);
72
73
    CHIP_ERROR ReadEndpointListAttribute(const ConcreteReadAttributePath & aPath,
74
                                         const AttributeValueEncoder::ListEncodeHelper & aEncoder);
75
76
    bool mRegistered = false;
77
    std::string mSetupURL;
78
    RegisteredServerCluster<ActionsCluster> mCluster;
79
80
    // Counts active instances for diagnostic logging. Multiple instances are valid when
81
    // the device has multiple aggregator endpoints (e.g. separate Zigbee and Z-Wave bridges).
82
    static uint8_t sInstanceCount;
83
};
84
85
} // namespace chip::app::Clusters::Actions