From d27ac43e3a8fc0757a2da5e4a8cd9b6a9b9e80f9 Mon Sep 17 00:00:00 2001 From: Marc Lepage <67919234+mlepage-google@users.noreply.github.com> Date: Fri, 10 Dec 2021 10:12:02 -0500 Subject: [PATCH] Add path expanded flag (#12820) * 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. --- src/app/AttributePathExpandIterator.cpp | 2 ++ src/app/ConcreteAttributePath.h | 10 +++++++--- src/app/util/ember-compatibility-functions.cpp | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/AttributePathExpandIterator.cpp b/src/app/AttributePathExpandIterator.cpp index 505997e57d7133..02b09969a22f8a 100644 --- a/src/app/AttributePathExpandIterator.cpp +++ b/src/app/AttributePathExpandIterator.cpp @@ -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. diff --git a/src/app/ConcreteAttributePath.h b/src/app/ConcreteAttributePath.h index 4ade1b173fc012..d1f46914fe7491 100644 --- a/src/app/ConcreteAttributePath.h +++ b/src/app/ConcreteAttributePath.h @@ -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 { @@ -41,6 +44,7 @@ struct ConcreteAttributePath } EndpointId mEndpointId = 0; + bool mExpanded = false; // NOTE: in between larger members ClusterId mClusterId = 0; AttributeId mAttributeId = 0; }; @@ -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) @@ -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) {} diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index c32d439d5e9970..b178c78f081596 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -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) {