blob: 560eb46eb7cbbf8408d4cbc4edb697c5c1005115 [file]
/*
*
* Copyright (c) 2026 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <app/clusters/electrical-distribution-server/ElectricalDistributionCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
namespace chip {
namespace app {
namespace Clusters {
namespace ElectricalDistribution {
/// Owns an ElectricalDistributionCluster and its registration.
///
/// Electrical Distribution is a code-driven cluster, so the generated dispatch calls
/// MatterElectricalDistributionClusterInitCallback() for every endpoint that enables it. That
/// callback is intentionally a no-op: the application owns the cluster instead, because the
/// attribute values are application data (ratings, pole count, service-entrance status) that the
/// generated static configuration cannot supply.
///
/// Applications construct one Instance per endpoint hosting the cluster, call Init() during
/// application init, and let the destructor (or an explicit Shutdown()) unregister it.
class Instance
{
public:
Instance(EndpointId endpointId, const ElectricalDistributionCluster::StartupConfiguration & config) :
mCluster(endpointId, config)
{}
~Instance() { Shutdown(); }
Instance(const Instance &) = delete;
Instance(Instance &&) = delete;
Instance & operator=(const Instance &) = delete;
Instance & operator=(Instance &&) = delete;
CHIP_ERROR Init();
void Shutdown();
ElectricalDistributionCluster & Cluster() { return mCluster.Cluster(); }
private:
RegisteredServerCluster<ElectricalDistributionCluster> mCluster;
bool mRegistered = false;
};
} // namespace ElectricalDistribution
} // namespace Clusters
} // namespace app
} // namespace chip