Skip to content

Commit

Permalink
Fix includes
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Dec 18, 2024
1 parent f56a010 commit a3edec0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
4 changes: 0 additions & 4 deletions src/access/ProviderDeviceTypeResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class DynamicProviderDeviceTypeResolver : public chip::Access::AccessControl::De
bool IsDeviceTypeOnEndpoint(chip::DeviceTypeId deviceType, chip::EndpointId endpoint) override
{
auto it = mModelGetter()->GetDeviceTypes(endpoint);
if (!it)
{
return false;
}
for (auto type = it->Next(); type.has_value(); type = it->Next())
{
if (type->deviceTypeId == deviceType)
Expand Down
5 changes: 0 additions & 5 deletions src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ CHIP_ERROR DescriptorAttrAccess::ReadDeviceAttribute(EndpointId endpoint, Attrib
{
CHIP_ERROR err = aEncoder.EncodeList([&endpoint](const auto & encoder) -> CHIP_ERROR {
auto it = InteractionModelEngine::GetInstance()->GetDataModelProvider()->GetDeviceTypes(endpoint);
if (!it)
{
return CHIP_NO_ERROR;
}

for (auto deviceType = it->Next(); deviceType.has_value(); deviceType = it->Next())
{
Descriptor::Structs::DeviceTypeStruct::Type deviceStruct;
Expand Down
2 changes: 2 additions & 0 deletions src/app/clusters/descriptor/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include <cstdint>

namespace chip {
namespace app {
namespace Clusters {
Expand Down
7 changes: 4 additions & 3 deletions src/app/data-model-provider/Iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@ class MetaDataIterator : public FastForwardIterator<T>
};

template <typename T>
class NullFastForwardIterator : public FastForwardIterator<T>
class NullElementIterator : public ElementIterator<T>
{
public:
std::optional<T> Next() override { return std::nullopt; }
bool SeekTo(const T & value) override { return false; }
};

/// Null iterator, generally just used for tests
template <typename T, typename Meta>
class NullMetadataIterator : public NullFastForwardIterator<T>
class NullMetadataIterator : public MetaDataIterator<T, Meta>
{
public:
std::optional<T> Next() override { return std::nullopt; }
bool SeekTo(const T & value) override { return false; }
std::optional<Meta> GetMetadata() override { return std::nullopt; }
};

Expand Down
41 changes: 33 additions & 8 deletions src/app/data-model-provider/MetadataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <cstdint>
#include <memory>
#include <optional>

#include <access/Privilege.h>
Expand Down Expand Up @@ -192,27 +193,51 @@ class ProviderMetadataTree
// tight loop/operation within event loop processing and SHOULD NOT be
// stored for use across execution boundaries
//
// RETURN VALUES
//
// - These MUST NOT return null pointer. Use NullIterators if empty data sets
// are to be returned.
//
// PERFORMANCE
//
// - Lookups should be performed using `Get...` and `SeekTo`.
//
/////////////////////////////////////////////////////////////////////////
virtual std::unique_ptr<MetaDataIterator<EndpointId, EndpointInfo>> GetEndpoints() { return nullptr; }
virtual std::unique_ptr<ElementIterator<DeviceTypeEntry>> GetDeviceTypes(EndpointId endpointId) { return nullptr; }
virtual std::unique_ptr<ElementIterator<SemanticTag>> GetSemanticTags(EndpointId endpointId) { return nullptr; }
virtual std::unique_ptr<MetaDataIterator<EndpointId, EndpointInfo>> GetEndpoints()
{
return std::make_unique<NullMetadataIterator<EndpointId, EndpointInfo>>();
}
virtual std::unique_ptr<ElementIterator<DeviceTypeEntry>> GetDeviceTypes(EndpointId endpointId)
{
return std::make_unique<NullElementIterator<DeviceTypeEntry>>();
}
virtual std::unique_ptr<ElementIterator<SemanticTag>> GetSemanticTags(EndpointId endpointId)
{
return std::make_unique<NullElementIterator<SemanticTag>>();
}

virtual std::unique_ptr<MetaDataIterator<ClusterId, ClusterInfo>> GetServerClusters(EndpointId endpointId) { return nullptr; }
virtual std::unique_ptr<ElementIterator<ClusterId>> GetClientClusters(EndpointId endpointId) { return nullptr; }
virtual std::unique_ptr<MetaDataIterator<ClusterId, ClusterInfo>> GetServerClusters(EndpointId endpointId)
{
return std::make_unique<NullMetadataIterator<ClusterId, ClusterInfo>>();
}

virtual std::unique_ptr<ElementIterator<ClusterId>> GetClientClusters(EndpointId endpointId)
{
return std::make_unique<NullElementIterator<ClusterId>>();
}

virtual std::unique_ptr<MetaDataIterator<AttributeId, AttributeInfo>> GetAttributes(ConcreteClusterPath clusterPath)
{
return nullptr;
return std::make_unique<NullMetadataIterator<AttributeId, AttributeInfo>>();
}
virtual std::unique_ptr<MetaDataIterator<CommandId, CommandInfo>> GetAcceptedCommands(ConcreteClusterPath clusterPath)
{
return nullptr;
return std::make_unique<NullMetadataIterator<CommandId, CommandInfo>>();
}
virtual std::unique_ptr<ElementIterator<CommandId>> GetGeneratedCommands(ConcreteClusterPath clusterPath)
{
return std::make_unique<NullElementIterator<CommandId>>();
}
virtual std::unique_ptr<ElementIterator<CommandId>> GetGeneratedCommands(ConcreteClusterPath clusterPath) { return nullptr; }

// This iteration will list all the endpoints in the data model
virtual EndpointEntry FirstEndpoint() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ CodegenDataModelProvider::GetDeviceTypes(EndpointId endpointId)
std::optional<unsigned> endpoint_index = TryFindEndpointIndex(endpointId);
if (!endpoint_index.has_value())
{
return nullptr;
return std::make_unique<DataModel::NullElementIterator<DataModel::DeviceTypeEntry>>();
}

CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down

0 comments on commit a3edec0

Please sign in to comment.