Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metadata-tree from MetadaList Foo(path) to CHIP_ERROR Foo(path, ListBuilder &) #37127

Merged
merged 20 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
742dc89
Append-only API update: use CHIP_ERROR and builders for MetadataTree
andy31415 Jan 20, 2025
92e448d
Fix includes
andy31415 Jan 20, 2025
c19a4fd
Remove odd comment
andy31415 Jan 20, 2025
48dc77c
ScopedSpan == ReadOnlyBuffer and Build == TakeBuffer
andy31415 Jan 20, 2025
066d2ea
Update src/app/InteractionModelEngine.cpp
andy31415 Jan 20, 2025
e37165e
Update src/app/clusters/descriptor/descriptor.cpp
andy31415 Jan 20, 2025
ea07467
Update src/app/clusters/descriptor/descriptor.cpp
andy31415 Jan 20, 2025
28a8640
Update src/app/clusters/descriptor/descriptor.cpp
andy31415 Jan 20, 2025
63dc63f
Update src/app/clusters/descriptor/descriptor.cpp
andy31415 Jan 20, 2025
c11bf30
Update src/app/clusters/descriptor/descriptor.cpp
andy31415 Jan 20, 2025
94cdf80
Update src/app/data-model-provider/MetadataList.cpp
andy31415 Jan 20, 2025
b052497
Replaced a lot of auto with const auto for readability
andy31415 Jan 20, 2025
f902249
Update src/app/clusters/microwave-oven-control-server/microwave-oven-…
andy31415 Jan 20, 2025
9e8d062
Merge branch 'append_only_api' of github.com:andy31415/connectedhomei…
andy31415 Jan 20, 2025
f122b28
Remove old comment
andy31415 Jan 20, 2025
6ae480e
Fix some typos
andy31415 Jan 20, 2025
52fbc7f
Fix typo
andy31415 Jan 20, 2025
eaf9f0c
Merge branch 'master' into append_only_api
andy31415 Jan 20, 2025
493950d
Update src/app/data-model-provider/MetadataTypes.h
andy31415 Jan 23, 2025
ded4d53
Merge branch 'master' into append_only_api
andreilitvin Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,9 +1790,9 @@ Protocols::InteractionModel::Status InteractionModelEngine::CheckCommandExistenc
{
auto provider = GetDataModelProvider();

DataModel::ListBuilder<DataModel::AcceptedCommandEntry> builder;
(void) provider->AcceptedCommands(aCommandPath, builder);
for (auto & existing : builder.TakeBuffer())
DataModel::ListBuilder<DataModel::AcceptedCommandEntry> acceptedCommands;
(void) provider->AcceptedCommands(aCommandPath, acceptedCommands);
for (auto & existing : acceptedCommands.TakeBuffer())
{
if (existing.commandId == aCommandPath.mCommandId)
{
Expand Down
33 changes: 16 additions & 17 deletions src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ CHIP_ERROR DescriptorAttrAccess::ReadFeatureMap(EndpointId endpoint, AttributeVa

CHIP_ERROR DescriptorAttrAccess::ReadTagListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
DataModel::ListBuilder<DataModel::Provider::SemanticTag> builder;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->SemanticTags(endpoint, builder));
DataModel::ListBuilder<DataModel::Provider::SemanticTag> semanticTagsList;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->SemanticTags(endpoint, semanticTagsList));

return aEncoder.EncodeList([&builder](const auto & encoder) -> CHIP_ERROR {
for (const auto & tag : builder.TakeBuffer())
return aEncoder.EncodeList([&semanticTagsList](const auto & encoder) -> CHIP_ERROR {
for (const auto & tag : semanticTagsList.TakeBuffer())
{
ReturnErrorOnFailure(encoder.Encode(tag));
}
Expand All @@ -120,10 +120,9 @@ CHIP_ERROR DescriptorAttrAccess::ReadTagListAttribute(EndpointId endpoint, Attri

CHIP_ERROR DescriptorAttrAccess::ReadPartsAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
DataModel::ListBuilder<DataModel::EndpointEntry> builder;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(builder));

auto endpoints = builder.TakeBuffer();
DataModel::ListBuilder<DataModel::EndpointEntry> endpointsList;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList));
auto endpoints = endpointsList.TakeBuffer();
if (endpoint == 0x00)
{
return aEncoder.EncodeList([&endpoints](const auto & encoder) -> CHIP_ERROR {
Expand Down Expand Up @@ -192,14 +191,14 @@ CHIP_ERROR DescriptorAttrAccess::ReadPartsAttribute(EndpointId endpoint, Attribu

CHIP_ERROR DescriptorAttrAccess::ReadDeviceAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
DataModel::ListBuilder<DataModel::DeviceTypeEntry> builder;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, builder));
DataModel::ListBuilder<DataModel::DeviceTypeEntry> deviceTypesList;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList));

auto span = builder.TakeBuffer();
auto deviceTypes = deviceTypesList.TakeBuffer();

CHIP_ERROR err = aEncoder.EncodeList([&span](const auto & encoder) -> CHIP_ERROR {
CHIP_ERROR err = aEncoder.EncodeList([&deviceTypes](const auto & encoder) -> CHIP_ERROR {
Descriptor::Structs::DeviceTypeStruct::Type deviceStruct;
for (const auto & type : span)
for (const auto & type : deviceTypes)
{
deviceStruct.deviceType = type.deviceTypeId;
deviceStruct.revision = type.deviceTypeRevision;
Expand Down Expand Up @@ -227,10 +226,10 @@ CHIP_ERROR DescriptorAttrAccess::ReadServerClusters(EndpointId endpoint, Attribu

CHIP_ERROR DescriptorAttrAccess::ReadClientClusters(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
DataModel::ListBuilder<ClusterId> builder;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->ClientClusters(endpoint, builder));
return aEncoder.EncodeList([&builder](const auto & encoder) -> CHIP_ERROR {
for (const auto & id : builder.TakeBuffer())
DataModel::ListBuilder<ClusterId> clusterIdList;
ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->ClientClusters(endpoint, clusterIdList));
return aEncoder.EncodeList([&clusterIdList](const auto & encoder) -> CHIP_ERROR {
for (const auto & id : clusterIdList.TakeBuffer())
{
ReturnErrorOnFailure(encoder.Encode(id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::

InteractionModelEngine::GetInstance()->GetDataModelProvider()->AcceptedCommands(
ConcreteClusterPath(mEndpointId, OperationalState::Id), builder);
auto acceptedCommands = builder.Build();
auto acceptedCommands = acceptedCommandsList.TakeBuffer();

bool commandExists =
std::find_if(acceptedCommands.begin(), acceptedCommands.end(), [](const DataModel::AcceptedCommandEntry & entry) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model-provider/MetadataList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CHIP_ERROR GenericAppendOnlyBuffer::EnsureAppendCapacity(size_t numElements)

// we already have the data in buffer. we have two choices:
// - allocated buffer needs to be extended
// - re-used const buffer neext to be copied over
// - re-used const buffer needs to be copied over
if (mBufferIsAllocated)
{
auto new_buffer = static_cast<uint8_t *>(Platform::MemoryRealloc(mBuffer, (mElementCount + numElements) * mElementSize));
Expand Down
Loading