Skip to content

Commit 73ccd7c

Browse files
committed
[*ChangeListener] replace AttributesChangedListener with ProviderChangeListener
AttributesChangedListener is a duplicate of ProviderChangeListener and there is no need to keep both. Since AttributesChangedListener is for ember and ProviderChangeListener is from DataModel, it makes more sense to keep ProviderChangeListener.
1 parent c87ece5 commit 73ccd7c

File tree

8 files changed

+16
-65
lines changed

8 files changed

+16
-65
lines changed

src/app/util/AttributesChangedListener.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/app/util/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ source_set("types") {
5555
# This source set also depends on data-model
5656
source_set("af-types") {
5757
sources = [
58-
"AttributesChangedListener.h",
5958
"MarkAttributeDirty.h",
6059
"af-types.h",
6160
]

src/app/util/af-types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <stdbool.h> // For bool
2727
#include <stdint.h> // For various uint*_t types
2828

29-
#include <app/util/AttributesChangedListener.h>
3029
#include <app/util/MarkAttributeDirty.h>
3130
#include <app/util/basic-types.h>
3231
#include <app/util/types_stub.h> // For various types.

src/app/util/attribute-storage.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <app/AttributeAccessInterfaceRegistry.h>
2121
#include <app/CommandHandlerInterfaceRegistry.h>
2222
#include <app/InteractionModelEngine.h>
23+
#include <app/data-model-provider/ProviderChangeListener.h>
2324
#include <app/persistence/AttributePersistenceProvider.h>
2425
#include <app/persistence/AttributePersistenceProviderInstance.h>
2526
#include <app/persistence/PascalString.h>
@@ -1576,28 +1577,13 @@ DataVersion * emberAfDataVersionStorage(const ConcreteClusterPath & aConcreteClu
15761577
return ep.dataVersions + clusterIndex;
15771578
}
15781579

1579-
namespace {
1580-
class GlobalInteractionModelEngineChangedpathListener : public AttributesChangedListener
1581-
{
1582-
public:
1583-
~GlobalInteractionModelEngineChangedpathListener() = default;
1584-
1585-
void MarkDirty(const AttributePathParams & path) override
1586-
{
1587-
InteractionModelEngine::GetInstance()->GetReportingEngine().SetDirty(path);
1588-
}
1589-
};
1590-
1591-
} // namespace
1592-
1593-
AttributesChangedListener * emberAfGlobalInteractionModelAttributesChangedListener()
1580+
DataModel::ProviderChangeListener * emberAfGlobalInteractionModelAttributesChangedListener()
15941581
{
1595-
static GlobalInteractionModelEngineChangedpathListener listener;
1596-
return &listener;
1582+
return &InteractionModelEngine::GetInstance()->GetReportingEngine();
15971583
}
15981584

15991585
void emberAfAttributeChanged(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId,
1600-
AttributesChangedListener * listener)
1586+
DataModel::ProviderChangeListener * listener)
16011587
{
16021588
// Increase cluster data path
16031589
DataVersion * version = emberAfDataVersionStorage(ConcreteClusterPath(endpoint, clusterId));
@@ -1616,7 +1602,7 @@ void emberAfAttributeChanged(EndpointId endpoint, ClusterId clusterId, Attribute
16161602
listener->MarkDirty(AttributePathParams(endpoint, clusterId, attributeId));
16171603
}
16181604

1619-
void emberAfEndpointChanged(EndpointId endpoint, AttributesChangedListener * listener)
1605+
void emberAfEndpointChanged(EndpointId endpoint, DataModel::ProviderChangeListener * listener)
16201606
{
16211607
listener->MarkDirty(AttributePathParams(endpoint));
16221608
}

src/app/util/attribute-storage.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#pragma once
1919

20+
#include <app/data-model-provider/ProviderChangeListener.h>
2021
#include <app/util/af-types.h>
2122
#include <app/util/attribute-metadata.h>
2223
#include <app/util/config.h>
@@ -336,7 +337,7 @@ CHIP_ERROR emberAfSetDeviceTypeList(chip::EndpointId endpoint, chip::Span<const
336337

337338
/// Returns a change listener that uses the global InteractionModelEngine
338339
/// instance to report dirty paths
339-
chip::app::AttributesChangedListener * emberAfGlobalInteractionModelAttributesChangedListener();
340+
chip::app::DataModel::ProviderChangeListener * emberAfGlobalInteractionModelAttributesChangedListener();
340341

341342
/// Mark the given attribute as having changed:
342343
/// - increases the cluster data version for the given cluster
@@ -347,13 +348,13 @@ chip::app::AttributesChangedListener * emberAfGlobalInteractionModelAttributesCh
347348
/// This is a convenience function to make it clear when a `emberAfDataVersionStorage` increase
348349
/// and a `AttributesChangeListener::MarkDirty` always occur in lock-step.
349350
void emberAfAttributeChanged(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
350-
chip::app::AttributesChangedListener * listener);
351+
chip::app::DataModel::ProviderChangeListener * listener);
351352

352353
/// Mark attributes on the given endpoint as having changed.
353354
///
354355
/// Schedules reporting engine to consider the endpoint dirty, however does NOT increase/alter
355356
/// any cluster data versions.
356-
void emberAfEndpointChanged(chip::EndpointId endpoint, chip::app::AttributesChangedListener * listener);
357+
void emberAfEndpointChanged(chip::EndpointId endpoint, chip::app::DataModel::ProviderChangeListener * listener);
357358

358359
/// Maintains a increasing index of structural changes within ember
359360
/// that determine if existing "indexes" and metadata pointers within ember

src/app/util/attribute-table.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#pragma once
1919

2020
#include <app/ConcreteAttributePath.h>
21-
#include <app/util/AttributesChangedListener.h>
21+
#include <app/data-model-provider/ProviderChangeListener.h>
2222
#include <app/util/MarkAttributeDirty.h>
2323
#include <app/util/attribute-metadata.h>
2424
#include <lib/core/DataModelTypes.h>
@@ -50,7 +50,7 @@ struct EmberAfWriteDataInput
5050
// Listener called when when the written data is consided changed/dirty.
5151
// This being called depends on settings of `markDirty` combined with the actual contents of dataPtr
5252
// vs the contents of the current attribute storage.
53-
chip::app::AttributesChangedListener * changeListener = nullptr;
53+
chip::app::DataModel::ProviderChangeListener * changeListener = nullptr;
5454

5555
EmberAfWriteDataInput(uint8_t * data, EmberAfAttributeType type) : dataPtr(data), dataType(type) {}
5656

@@ -60,7 +60,7 @@ struct EmberAfWriteDataInput
6060
return *this;
6161
}
6262

63-
EmberAfWriteDataInput & SetChangeListener(chip::app::AttributesChangedListener * listener)
63+
EmberAfWriteDataInput & SetChangeListener(chip::app::DataModel::ProviderChangeListener * listener)
6464
{
6565
changeListener = listener;
6666
return *this;

src/app/util/mock/attribute-storage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <app-common/zap-generated/attribute-type.h>
3232
#include <app-common/zap-generated/ids/Attributes.h>
33+
#include <app/data-model-provider/ProviderChangeListener.h>
3334
#include <app/MessageDef/AttributeDataIB.h>
3435
#include <app/MessageDef/AttributeReportIB.h>
3536
#include <app/MessageDef/AttributeStatusIB.h>
@@ -391,13 +392,13 @@ chip::Span<const EmberAfDeviceType> emberAfDeviceTypeListFromEndpointIndex(unsig
391392
}
392393

393394
void emberAfAttributeChanged(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId,
394-
AttributesChangedListener * listener)
395+
DataModel::ProviderChangeListener * listener)
395396
{
396397
dataVersion++;
397398
listener->MarkDirty(AttributePathParams(endpoint, clusterId, attributeId));
398399
}
399400

400-
void emberAfEndpointChanged(EndpointId endpoint, AttributesChangedListener * listener)
401+
void emberAfEndpointChanged(EndpointId endpoint, DataModel::ProviderChangeListener * listener)
401402
{
402403
listener->MarkDirty(AttributePathParams(endpoint));
403404
}

src/data-model-providers/codegen/CodegenDataModelProvider_Write.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace {
4848
using namespace chip::app::Compatibility::Internal;
4949
using Protocols::InteractionModel::Status;
5050

51-
class ContextAttributesChangeListener : public AttributesChangedListener
51+
class ContextAttributesChangeListener : public DataModel::ProviderChangeListener
5252
{
5353
public:
5454
ContextAttributesChangeListener(DataModel::ProviderChangeListener & listener) : mListener(listener) {}

0 commit comments

Comments
 (0)