Skip to content

Commit 0bbdee6

Browse files
committed
Merge branch 'attribute-path-expand-state' of github.com:andy31415/connectedhomeip into attribute-path-expand-state
2 parents 75173d3 + 57198a6 commit 0bbdee6

4 files changed

+21
-20
lines changed

src/app/AttributePathExpandIterator.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ bool AttributePathExpandIterator::AdvanceOutputPath()
3131
/// Output path invariants
3232
/// - kInvalid* constants are used to define "no value available (yet)" and
3333
/// iteration loop will fill the first value when such a value is seen (fixed for non-wildcard
34-
/// or iteration-based in case of wildcadrs)
35-
/// - Fill of the output path is done in order: first endpoint, then cluster, then attribute.
34+
/// or iteration-based in case of wildcards).
35+
/// - Iteration of the output path is done in breadth-first order: first endpoint, then cluster, then attribute.
3636
/// Processing works like:
37-
/// - First state will start of as kInvalidEndpointId/kInvalidClusterId/kInvalidAttributeId
38-
/// - First loop pass fills in endointID, followed by clusterId, followed by attributeID
39-
/// - whenever one item fails to continue iterating (there is no "next") the following
37+
/// - Initial state is kInvalidEndpointId/kInvalidClusterId/kInvalidAttributeId
38+
/// - First loop pass fills-in endointID, followed by clusterID, followed by attributeID
39+
/// - Whenever one level is done iterating (there is no "next") the following
4040
/// "higher path component" is updated:
4141
/// - once a valid path exists, try to advance attributeID
4242
/// - if attributeID fails to advance, try to advance clusterID (and restart attributeID)
4343
/// - if clusterID fails to advance, try to advance endpointID (and restart clusterID)
44-
/// - if endpointID fails to advance, assume iteration done
44+
/// - if endpointID fails to advance, iteration is done
4545
while (true)
4646
{
4747
if (mPosition.mOutputPath.mClusterId != kInvalidClusterId)

src/app/AttributePathExpandIterator.h

+13-12
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,30 @@ namespace app {
3131
///
3232
/// - Start iterating by creating an iteration state
3333
///
34-
/// mPosition = AttributePathExpandIterator::Position::StartIterating(path);
34+
/// AttributePathExpandIterator::Position position = AttributePathExpandIterator::Position::StartIterating(path);
3535
///
3636
/// - Use the iteration state in a for loop:
3737
///
3838
/// ConcreteAttributePath path;
39-
/// for (AttributePathExpandIterator iterator(mPosition); iterator->Next(path);) {
39+
/// for (AttributePathExpandIterator iterator(position); iterator->Next(path);) {
4040
/// // use `path` here`
4141
/// }
4242
///
4343
/// OR:
4444
///
4545
/// ConcreteAttributePath path;
46-
/// AttributePathExpandIterator iterator(mPosition);
46+
/// AttributePathExpandIterator iterator(position);
4747
///
4848
/// while (iterator.Next(path)) {
4949
/// // use `path` here`
5050
/// }
5151
///
52-
/// USAGE requirements and assumptions:
52+
/// Usage requirements and assumptions:
5353
///
54-
/// - There should be only one single AttributePathExpandIterator for a state at a time.
55-
///
56-
/// - `Position` is automatically updated by the AttributePathExpandIterator, so
57-
/// calling `Next` on the iterator will update the state variable.
54+
/// - An ` AttributePathExpandIterator::Position` can only be used by a single AttributePathExpandIterator at a time.
5855
///
56+
/// - `position` is automatically updated by the AttributePathExpandIterator, so
57+
/// calling `Next` on the iterator will update the position cursor variable.
5958
///
6059
class AttributePathExpandIterator
6160
{
@@ -65,7 +64,7 @@ class AttributePathExpandIterator
6564
public:
6665
// Position is treated as a direct member access by the AttributePathExpandIterator, however it is opaque (except copying)
6766
// for external code. We allow friendship here to not have specific get/set for methods (clearer interface and less
68-
// likelyhood of extra code usage).
67+
// likelihood of extra code usage).
6968
friend class AttributePathExpandIterator;
7069

7170
/// External callers can only ever start iterating on a new path from the beginning
@@ -100,7 +99,7 @@ class AttributePathExpandIterator
10099
ConcreteAttributePath mOutputPath;
101100
};
102101

103-
AttributePathExpandIterator(DataModel::Provider * dataModel, Position & state) : mDataModelProvider(dataModel), mPosition(state)
102+
AttributePathExpandIterator(DataModel::Provider * dataModel, Position & position) : mDataModelProvider(dataModel), mPosition(position)
104103
{}
105104

106105
// This class may not be copied. A new one should be created when needed and they
@@ -151,8 +150,10 @@ class AttributePathExpandIterator
151150
bool IsValidAttributeId(AttributeId attributeId);
152151
};
153152

154-
/// Wraps around an AttributePathExpandIterator however it rolls back Next() to one
155-
/// step back whenever Next() is not run to completion (until it returns false)
153+
/// PeekAttributePathExpandIterator is an AttributePathExpandIterator wrapper that rolls back the Next()
154+
/// call whenever a new `MarkCompleted()` method is not called (until Next() returns false). This is useful
155+
/// to allow pausing iteration in cases the next path was not ready to be used yet and iteration needs to
156+
/// continue later.
156157
///
157158
/// Example use cases:
158159
///

src/app/ReadHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ void ReadHandler::AttributePathIsDirty(DataModel::Provider * apDataModel, const
857857
{
858858
mDirtyGeneration = mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().GetDirtySetGeneration();
859859

860-
// we want to get the value, but not advance the state
860+
// We want to get the value, but not advance the iterator position.
861861
AttributePathExpandIterator::Position tempPosition = mAttributePathExpandPosition;
862862
ConcreteAttributePath path;
863863

src/app/ReadHandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
566566
// The last schedule event number snapshoted in the beginning when preparing to fill new events to reports
567567
EventNumber mLastScheduledEventNumber = 0;
568568

569-
/// State for any on-going path expansion for handling wildcard reads/subscriptions
569+
/// Iterator position state for any on-going path expansion for handling wildcard reads/subscriptions.
570570
AttributePathExpandIterator::Position mAttributePathExpandPosition;
571571

572572
Messaging::ExchangeHolder mExchangeCtx;

0 commit comments

Comments
 (0)