blob: a7ab5dc9306871c95d64de16c747340886163612 [file] [log] [blame]
/**
*
* Copyright (c) 2025-2026 Project CHIP Authors
*
* 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-common/zap-generated/cluster-objects.h>
#include <string>
#include <vector>
namespace chip {
namespace app {
namespace Clusters {
namespace ZoneManagement {
using TwoDCartesianZoneDecodableStruct = Structs::TwoDCartesianZoneStruct::DecodableType;
using TwoDCartesianZoneStruct = Structs::TwoDCartesianZoneStruct::Type;
using TwoDCartesianVertexStruct = Structs::TwoDCartesianVertexStruct::Type;
struct TwoDCartesianZoneStorage : TwoDCartesianZoneStruct
{
TwoDCartesianZoneStorage(){};
TwoDCartesianZoneStorage(const CharSpan & aName, ZoneUseEnum aUse, const std::vector<TwoDCartesianVertexStruct> & aVertices,
Optional<CharSpan> aColor)
{
Set(aName, aUse, aVertices, aColor);
}
TwoDCartesianZoneStorage(const TwoDCartesianZoneStorage & aTwoDCartZone) { *this = aTwoDCartZone; }
TwoDCartesianZoneStorage & operator=(const TwoDCartesianZoneStorage & aTwoDCartZone)
{
Set(aTwoDCartZone.name, aTwoDCartZone.use, aTwoDCartZone.verticesVector, aTwoDCartZone.color);
return *this;
}
void Set(const CharSpan & aName, ZoneUseEnum aUse, const std::vector<TwoDCartesianVertexStruct> & aVertices,
Optional<CharSpan> aColor)
{
nameString = std::string(aName.begin(), aName.end());
name = CharSpan(nameString.c_str(), nameString.size());
use = aUse;
verticesVector = aVertices;
vertices = DataModel::List<TwoDCartesianVertexStruct>(verticesVector.data(), verticesVector.size());
if (aColor.HasValue())
{
colorString = std::string(aColor.Value().begin(), aColor.Value().end());
color = MakeOptional(CharSpan(colorString.c_str(), colorString.size()));
}
else
{
colorString.clear();
color = NullOptional;
}
}
std::string nameString;
std::string colorString;
std::vector<TwoDCartesianVertexStruct> verticesVector;
};
} // namespace ZoneManagement
} // namespace Clusters
} // namespace app
} // namespace chip