Skip to content

Commit

Permalink
Add path expanded flag (#12820)
Browse files Browse the repository at this point in the history
* Add expanded flag to ConcreteAttributePath

And set it from the AttributePathExpandIterator.

* Ensure expanded flag is not sliced

Derived "copy" constructors that take the base can slice it. Fix that.

* Remove expanded flag from equality test

It's more of a metadata thing anyways.
  • Loading branch information
mlepage-google authored Dec 10, 2021
1 parent c454363 commit d27ac43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/app/AttributePathExpandIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ bool AttributePathExpandIterator::Next()
{
for (; mpClusterInfo != nullptr; (mpClusterInfo = mpClusterInfo->mpNext, mEndpointIndex = UINT16_MAX))
{
mOutputPath.mExpanded = mpClusterInfo->HasAttributeWildcard();

if (mEndpointIndex == UINT16_MAX)
{
// Special case: If this is a concrete path, we just return its value as-is.
Expand Down
10 changes: 7 additions & 3 deletions src/app/ConcreteAttributePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace app {

/**
* A representation of a concrete attribute path. This does not convey any list index specifiers.
*
* The expanded flag can be set to indicate that a concrete path was expanded from a wildcard
* or group path.
*/
struct ConcreteAttributePath
{
Expand All @@ -41,6 +44,7 @@ struct ConcreteAttributePath
}

EndpointId mEndpointId = 0;
bool mExpanded = false; // NOTE: in between larger members
ClusterId mClusterId = 0;
AttributeId mAttributeId = 0;
};
Expand All @@ -54,9 +58,7 @@ struct ConcreteReadAttributePath : public ConcreteAttributePath
{
ConcreteReadAttributePath() {}

ConcreteReadAttributePath(const ConcreteAttributePath & path) :
ConcreteReadAttributePath(path.mEndpointId, path.mClusterId, path.mAttributeId)
{}
ConcreteReadAttributePath(const ConcreteAttributePath & path) : ConcreteAttributePath(path) {}

ConcreteReadAttributePath(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId) :
ConcreteAttributePath(aEndpointId, aClusterId, aAttributeId)
Expand Down Expand Up @@ -90,6 +92,8 @@ struct ConcreteDataAttributePath : public ConcreteAttributePath

ConcreteDataAttributePath() {}

ConcreteDataAttributePath(const ConcreteAttributePath & path) : ConcreteAttributePath(path) {}

ConcreteDataAttributePath(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId) :
ConcreteAttributePath(aEndpointId, aClusterId, aAttributeId)
{}
Expand Down
5 changes: 3 additions & 2 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, c
AttributeValueEncoder::AttributeEncodeState * apEncoderState)
{
ChipLogDetail(DataManagement,
"Reading attribute: Cluster=" ChipLogFormatMEI " Endpoint=%" PRIx16 " AttributeId=" ChipLogFormatMEI,
ChipLogValueMEI(aPath.mClusterId), aPath.mEndpointId, ChipLogValueMEI(aPath.mAttributeId));
"Reading attribute: Cluster=" ChipLogFormatMEI " Endpoint=%" PRIx16 " AttributeId=" ChipLogFormatMEI
" (expanded=%d)",
ChipLogValueMEI(aPath.mClusterId), aPath.mEndpointId, ChipLogValueMEI(aPath.mAttributeId), aPath.mExpanded);

if (aPath.mAttributeId == Clusters::Globals::Attributes::AttributeList::Id)
{
Expand Down

0 comments on commit d27ac43

Please sign in to comment.