Skip to content

Commit 56b1307

Browse files
committed
Remove extra argument for ReadHandler constructor
1 parent fef425f commit 56b1307

9 files changed

+58
-75
lines changed

src/app/BUILD.gn

+18-3
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static_library("interaction-model") {
207207
]
208208

209209
deps = [
210+
":path-expansion",
210211
"${chip_root}/src/app:events",
211212
"${chip_root}/src/app:global-attributes",
212213
]
@@ -406,6 +407,22 @@ source_set("storage-wrapper") {
406407
]
407408
}
408409

410+
source_set("path-expansion") {
411+
sources = [
412+
"AttributePathExpandIterator.cpp",
413+
"AttributePathExpandIterator.h",
414+
]
415+
416+
public_deps = [
417+
":global-attributes",
418+
":paths",
419+
"${chip_root}/src/lib/core:types",
420+
"${chip_root}/src/app/data-model-provider",
421+
"${chip_root}/src/lib/support",
422+
]
423+
}
424+
425+
409426
source_set("attribute-persistence") {
410427
sources = [
411428
"DefaultSafeAttributePersistenceProvider.h",
@@ -429,9 +446,6 @@ static_library("app") {
429446
output_name = "libCHIPDataModel"
430447

431448
sources = [
432-
"AttributePathExpandIterator.cpp",
433-
"AttributePathExpandIterator.h",
434-
"AttributePathExpandIterator.h",
435449
"ChunkedWriteCallback.cpp",
436450
"ChunkedWriteCallback.h",
437451
"CommandResponseHelper.h",
@@ -464,6 +478,7 @@ static_library("app") {
464478
":event-reporter",
465479
":global-attributes",
466480
":interaction-model",
481+
":path-expansion",
467482
"${chip_root}/src/app/data-model",
468483
"${chip_root}/src/app/data-model-provider",
469484
"${chip_root}/src/app/icd/server:icd-server-config",

src/app/InteractionModelEngine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest
849849
// We have already reserved enough resources for read requests, and have granted enough resources for current subscriptions, so
850850
// we should be able to allocate resources requested by this request.
851851
ReadHandler * handler =
852-
mReadHandlers.CreateObject(*this, apExchangeContext, aInteractionType, mReportScheduler, GetDataModelProvider());
852+
mReadHandlers.CreateObject(*this, apExchangeContext, aInteractionType, mReportScheduler);
853853
if (handler == nullptr)
854854
{
855855
ChipLogProgress(InteractionModel, "no resource for %s interaction",

src/app/ReadHandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ uint16_t ReadHandler::GetPublisherSelectedIntervalLimit()
4848
}
4949

5050
ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeContext * apExchangeContext,
51-
InteractionType aInteractionType, Observer * observer, DataModel::Provider * apDataModel) :
51+
InteractionType aInteractionType, Observer * observer) :
5252
mExchangeCtx(*this),
5353
mManagementCallback(apCallback)
5454
{
@@ -74,7 +74,7 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon
7474
}
7575

7676
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
77-
ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer, DataModel::Provider * apDataModel) :
77+
ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer) :
7878
mExchangeCtx(*this), mManagementCallback(apCallback)
7979
{
8080
mInteractionType = InteractionType::Subscribe;

src/app/ReadHandler.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
212212
*
213213
*/
214214
ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeContext * apExchangeContext, InteractionType aInteractionType,
215-
Observer * observer, DataModel::Provider * apDataModel);
215+
Observer * observer);
216216

217217
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
218218
/**
@@ -222,7 +222,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
222222
* The callback passed in has to outlive this handler object.
223223
*
224224
*/
225-
ReadHandler(ManagementCallback & apCallback, Observer * observer, DataModel::Provider * apDataModel);
225+
ReadHandler(ManagementCallback & apCallback, Observer * observer);
226226
#endif
227227

228228
const SingleLinkedListNode<AttributePathParams> * GetAttributePathList() const { return mpAttributePathList; }

src/app/SubscriptionResumptionSessionEstablisher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnected(void * cont
104104
return;
105105
}
106106
ReadHandler * readHandler =
107-
imEngine->mReadHandlers.CreateObject(*imEngine, imEngine->GetReportScheduler(), imEngine->GetDataModelProvider());
107+
imEngine->mReadHandlers.CreateObject(*imEngine, imEngine->GetReportScheduler());
108108
if (readHandler == nullptr)
109109
{
110110
// TODO - Should we keep the subscription here?

src/app/tests/TestInteractionModelEngine.cpp

+14-28
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription
271271

272272
// Create and setup readHandler 1
273273
ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(
274-
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
275-
CodegenDataModelProviderInstance(nullptr /* delegate */));
274+
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
276275

277276
// Verify that Bob still doesn't have an active subscription
278277
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId));
@@ -319,16 +318,14 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription
319318

320319
// Create readHandler 1
321320
engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe,
322-
reporting::GetDefaultReportScheduler(),
323-
CodegenDataModelProviderInstance(nullptr /* delegate */));
321+
reporting::GetDefaultReportScheduler());
324322

325323
// Verify that Bob still doesn't have an active subscription
326324
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId));
327325

328326
// Create and setup readHandler 2
329327
ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(
330-
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
331-
CodegenDataModelProviderInstance(nullptr /* delegate */));
328+
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
332329

333330
// Verify that Bob still doesn't have an active subscription
334331
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId));
@@ -380,13 +377,11 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription
380377

381378
// Create and setup readHandler 1
382379
ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(
383-
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
384-
CodegenDataModelProviderInstance(nullptr /* delegate */));
380+
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
385381

386382
// Create and setup readHandler 2
387383
ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(
388-
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
389-
CodegenDataModelProviderInstance(nullptr /* delegate */));
384+
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
390385

391386
// Verify that Bob still doesn't have an active subscription
392387
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId));
@@ -463,23 +458,19 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription
463458

464459
// Create and setup readHandler 1-1
465460
engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx11, ReadHandler::InteractionType::Subscribe,
466-
reporting::GetDefaultReportScheduler(),
467-
CodegenDataModelProviderInstance(nullptr /* delegate */));
461+
reporting::GetDefaultReportScheduler());
468462

469463
// Create and setup readHandler 1-2
470464
ReadHandler * readHandler12 = engine->GetReadHandlerPool().CreateObject(
471-
nullCallback, exchangeCtx12, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
472-
CodegenDataModelProviderInstance(nullptr /* delegate */));
465+
nullCallback, exchangeCtx12, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
473466

474467
// Create and setup readHandler 2-1
475468
engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx21, ReadHandler::InteractionType::Subscribe,
476-
reporting::GetDefaultReportScheduler(),
477-
CodegenDataModelProviderInstance(nullptr /* delegate */));
469+
reporting::GetDefaultReportScheduler());
478470

479471
// Create and setup readHandler 2-2
480472
ReadHandler * readHandler22 = engine->GetReadHandlerPool().CreateObject(
481-
nullCallback, exchangeCtx22, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
482-
CodegenDataModelProviderInstance(nullptr /* delegate */));
473+
nullCallback, exchangeCtx22, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
483474

484475
// Verify that both Alice and Bob have no active subscriptions
485476
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId));
@@ -551,8 +542,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription
551542

552543
// Create readHandler
553544
ReadHandler * readHandler = engine->GetReadHandlerPool().CreateObject(
554-
nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
555-
CodegenDataModelProviderInstance(nullptr /* delegate */));
545+
nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
556546

557547
// Verify there are not active subscriptions
558548
EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, valideSubjectId));
@@ -749,8 +739,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestFabricHasAtLeastOneActiveSub
749739

750740
// Create and setup readHandler 1
751741
ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(
752-
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
753-
CodegenDataModelProviderInstance(nullptr /* delegate */));
742+
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
754743

755744
// Verify that fabric 1 still doesn't have an active subscription
756745
EXPECT_FALSE(engine->FabricHasAtLeastOneActiveSubscription(fabricIndex1));
@@ -766,8 +755,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestFabricHasAtLeastOneActiveSub
766755

767756
// Create and setup readHandler 2
768757
ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(
769-
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
770-
CodegenDataModelProviderInstance(nullptr /* delegate */));
758+
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
771759

772760
// Set readHandler2 to active
773761
readHandler2->SetStateFlag(ReadHandler::ReadHandlerFlags::ActiveSubscription, true);
@@ -805,8 +793,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestFabricHasAtLeastOneActiveSub
805793

806794
// Create and setup readHandler 1
807795
ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(
808-
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
809-
CodegenDataModelProviderInstance(nullptr /* delegate */));
796+
nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
810797

811798
// Verify that the fabric still doesn't have an active subscription
812799
EXPECT_FALSE(engine->FabricHasAtLeastOneActiveSubscription(fabricIndex));
@@ -819,8 +806,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestFabricHasAtLeastOneActiveSub
819806

820807
// Create and setup readHandler 2
821808
ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(
822-
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler(),
823-
CodegenDataModelProviderInstance(nullptr /* delegate */));
809+
nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, reporting::GetDefaultReportScheduler());
824810

825811
// Verify that the fabric still has an active subscription
826812
EXPECT_TRUE(engine->FabricHasAtLeastOneActiveSubscription(fabricIndex));

src/app/tests/TestReadInteraction.cpp

+9-18
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,7 @@ void TestReadInteraction::TestReadHandler()
565565

566566
{
567567
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
568-
ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
569-
CodegenDataModelProviderInstance(nullptr /* delegate */));
568+
ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
570569

571570
GenerateReportData(reportDatabuf, ReportType::kValid, false /* aSuppressResponse*/);
572571
EXPECT_EQ(readHandler.SendReportData(std::move(reportDatabuf), false), CHIP_ERROR_INCORRECT_STATE);
@@ -624,8 +623,7 @@ void TestReadInteraction::TestReadHandlerSetMaxReportingInterval()
624623
uint16_t maxInterval;
625624

626625
// Configure ReadHandler
627-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
628-
CodegenDataModelProviderInstance(nullptr /* delegate */));
626+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
629627

630628
writer.Init(std::move(subscribeRequestbuf));
631629
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -842,8 +840,7 @@ void TestReadInteraction::TestReadHandlerInvalidAttributePath()
842840

843841
{
844842
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
845-
ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
846-
CodegenDataModelProviderInstance(nullptr /* delegate */));
843+
ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
847844

848845
GenerateReportData(reportDatabuf, ReportType::kValid, false /* aSuppressResponse*/);
849846
EXPECT_EQ(readHandler.SendReportData(std::move(reportDatabuf), false), CHIP_ERROR_INCORRECT_STATE);
@@ -1592,8 +1589,7 @@ void TestReadInteraction::TestProcessSubscribeRequest()
15921589
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
15931590

15941591
{
1595-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1596-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1592+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
15971593

15981594
writer.Init(std::move(subscribeRequestbuf));
15991595
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -1654,8 +1650,7 @@ void TestReadInteraction::TestICDProcessSubscribeRequestSupMaxIntervalCeiling()
16541650
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
16551651

16561652
{
1657-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1658-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1653+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
16591654

16601655
writer.Init(std::move(subscribeRequestbuf));
16611656
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -1724,8 +1719,7 @@ void TestReadInteraction::TestICDProcessSubscribeRequestInfMaxIntervalCeiling()
17241719
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
17251720

17261721
{
1727-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1728-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1722+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
17291723

17301724
writer.Init(std::move(subscribeRequestbuf));
17311725
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -1794,8 +1788,7 @@ void TestReadInteraction::TestICDProcessSubscribeRequestSupMinInterval()
17941788
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
17951789

17961790
{
1797-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1798-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1791+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
17991792

18001793
writer.Init(std::move(subscribeRequestbuf));
18011794
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -1864,8 +1857,7 @@ void TestReadInteraction::TestICDProcessSubscribeRequestMaxMinInterval()
18641857
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
18651858

18661859
{
1867-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1868-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1860+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
18691861

18701862
writer.Init(std::move(subscribeRequestbuf));
18711863
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);
@@ -1932,8 +1924,7 @@ void TestReadInteraction::TestICDProcessSubscribeRequestInvalidIdleModeDuration(
19321924
Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false);
19331925

19341926
{
1935-
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler,
1936-
CodegenDataModelProviderInstance(nullptr /* delegate */));
1927+
ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler);
19371928

19381929
writer.Init(std::move(subscribeRequestbuf));
19391930
EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR);

0 commit comments

Comments
 (0)