From 7b2adc68c9daae4541d06c16f4d3213b3bbc2bbe Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 31 Jul 2024 09:59:43 -0400 Subject: [PATCH] API renames: `chip::app::InteractionModel::*` becomes `chip::app::DataModel` and renamed `DataModel` to `Provider` (#34520) * Massive file name renames. No namespace renames yet * Restyle * Fix missed rename * more renames * Set of renames * Some final renames. Unit tests compile and pass * Restyle * Also rename the IME data model setter/getter * member renames * Slight rename * Restyle * Fix lint --------- Co-authored-by: Andrei Litvin --- .github/workflows/lint.yml | 4 +- src/BUILD.gn | 6 +- .../AttributePathExpandIterator-Checked.cpp | 2 +- src/app/AttributePathExpandIterator-Checked.h | 3 +- .../AttributePathExpandIterator-DataModel.cpp | 22 +-- .../AttributePathExpandIterator-DataModel.h | 9 +- src/app/AttributePathExpandIterator-Ember.cpp | 2 +- src/app/AttributePathExpandIterator-Ember.h | 4 +- src/app/BUILD.gn | 12 +- src/app/InteractionModelEngine.cpp | 18 +-- src/app/InteractionModelEngine.h | 10 +- src/app/ReadHandler.cpp | 6 +- src/app/ReadHandler.h | 4 +- ...bscriptionResumptionSessionEstablisher.cpp | 4 +- src/app/chip_data_model.cmake | 2 +- src/app/chip_data_model.gni | 2 +- .../BUILD.gn | 8 +- .../CodegenDataModelProvider.cpp} | 134 +++++++++--------- .../CodegenDataModelProvider.h} | 30 ++-- .../CodegenDataModelProvider_Read.cpp} | 8 +- .../CodegenDataModelProvider_Write.cpp} | 19 ++- .../EmberMetadata.cpp | 2 +- .../EmberMetadata.h | 0 .../Instance.cpp | 8 +- .../Instance.h | 4 +- .../model.cmake | 8 +- .../model.gni | 18 +-- .../tests/AttributeReportIBEncodeDecode.cpp | 0 .../tests/AttributeReportIBEncodeDecode.h | 0 .../tests/BUILD.gn | 4 +- .../tests/EmberInvokeOverride.cpp | 0 .../tests/EmberInvokeOverride.h | 0 .../tests/EmberReadWriteOverride.cpp | 0 .../tests/EmberReadWriteOverride.h | 0 .../InteractionModelTemporaryOverrides.cpp | 0 .../tests/TestCodegenModelViaMocks.cpp | 134 +++++++++--------- .../ActionContext.h | 4 +- .../BUILD.gn | 6 +- .../Context.h | 12 +- .../EventsGenerator.h | 4 +- .../MetadataTypes.cpp | 6 +- .../MetadataTypes.h | 8 +- .../OperationTypes.h | 4 +- .../Provider.h} | 14 +- .../ProviderChangeListener.h} | 8 +- .../tests/BUILD.gn | 2 +- .../tests/TestEventEmitting.cpp | 4 +- src/app/reporting/Engine.cpp | 2 +- src/app/reporting/Read-Checked.cpp | 2 +- src/app/reporting/Read-Checked.h | 4 +- src/app/reporting/Read-DataModel.cpp | 10 +- src/app/reporting/Read-DataModel.h | 4 +- src/app/reporting/Read-Ember.cpp | 2 +- src/app/reporting/Read-Ember.h | 4 +- src/app/tests/BUILD.gn | 2 +- src/app/tests/TestAclAttribute.cpp | 6 +- .../tests/TestAttributePathExpandIterator.cpp | 16 +-- src/app/tests/TestInteractionModelEngine.cpp | 22 +-- src/app/tests/TestReadInteraction.cpp | 24 ++-- src/app/tests/TestReportScheduler.cpp | 20 +-- src/app/tests/TestReportingEngine.cpp | 10 +- src/app/tests/test-interaction-model-api.cpp | 30 ++-- src/app/tests/test-interaction-model-api.h | 28 ++-- src/app/util/mock/BUILD.gn | 2 +- src/controller/tests/data_model/BUILD.gn | 2 +- .../tests/data_model/DataModelFixtures.cpp | 30 ++-- .../tests/data_model/DataModelFixtures.h | 28 ++-- src/controller/tests/data_model/TestRead.cpp | 12 +- 68 files changed, 407 insertions(+), 412 deletions(-) rename src/app/{codegen-data-model => codegen-data-model-provider}/BUILD.gn (92%) rename src/app/{codegen-data-model/CodegenDataModel.cpp => codegen-data-model-provider/CodegenDataModelProvider.cpp} (70%) rename src/app/{codegen-data-model/CodegenDataModel.h => codegen-data-model-provider/CodegenDataModelProvider.h} (75%) rename src/app/{codegen-data-model/CodegenDataModel_Read.cpp => codegen-data-model-provider/CodegenDataModelProvider_Read.cpp} (97%) rename src/app/{codegen-data-model/CodegenDataModel_Write.cpp => codegen-data-model-provider/CodegenDataModelProvider_Write.cpp} (96%) rename src/app/{codegen-data-model => codegen-data-model-provider}/EmberMetadata.cpp (98%) rename src/app/{codegen-data-model => codegen-data-model-provider}/EmberMetadata.h (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/Instance.cpp (76%) rename src/app/{codegen-data-model => codegen-data-model-provider}/Instance.h (87%) rename src/app/{codegen-data-model => codegen-data-model-provider}/model.cmake (81%) rename src/app/{codegen-data-model => codegen-data-model-provider}/model.gni (66%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/AttributeReportIBEncodeDecode.cpp (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/AttributeReportIBEncodeDecode.h (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/BUILD.gn (94%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/EmberInvokeOverride.cpp (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/EmberInvokeOverride.h (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/EmberReadWriteOverride.cpp (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/EmberReadWriteOverride.h (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/InteractionModelTemporaryOverrides.cpp (100%) rename src/app/{codegen-data-model => codegen-data-model-provider}/tests/TestCodegenModelViaMocks.cpp (96%) rename src/app/{data-model-interface => data-model-provider}/ActionContext.h (95%) rename src/app/{data-model-interface => data-model-provider}/BUILD.gn (93%) rename src/app/{data-model-interface => data-model-provider}/Context.h (80%) rename src/app/{data-model-interface => data-model-provider}/EventsGenerator.h (98%) rename src/app/{data-model-interface => data-model-provider}/MetadataTypes.cpp (92%) rename src/app/{data-model-interface => data-model-provider}/MetadataTypes.h (97%) rename src/app/{data-model-interface => data-model-provider}/OperationTypes.h (98%) rename src/app/{data-model-interface/DataModel.h => data-model-provider/Provider.h} (94%) rename src/app/{data-model-interface/DataModelChangeListener.h => data-model-provider/ProviderChangeListener.h} (90%) rename src/app/{data-model-interface => data-model-provider}/tests/BUILD.gn (94%) rename src/app/{data-model-interface => data-model-provider}/tests/TestEventEmitting.cpp (98%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 98dd81edceca88..6694decc421372 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -290,8 +290,8 @@ jobs: git grep -I -n 'emberAfWriteAttribute' -- './*' \ ':(exclude).github/workflows/lint.yml' \ ':(exclude)examples/common/pigweed/rpc_services/Attributes.h' \ - ':(exclude)src/app/codegen-data-model/CodegenDataModel_Write.cpp' \ - ':(exclude)src/app/codegen-data-model/tests/EmberReadWriteOverride.cpp' \ + ':(exclude)src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp' \ + ':(exclude)src/app/codegen-data-model-provider/tests/EmberReadWriteOverride.cpp' \ ':(exclude)src/app/util/attribute-table.cpp' \ ':(exclude)src/app/util/attribute-table.h' \ ':(exclude)src/app/util/ember-compatibility-functions.cpp' \ diff --git a/src/BUILD.gn b/src/BUILD.gn index c162a61f0620fa..e70025151c852b 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -52,7 +52,7 @@ if (chip_build_tests) { tests = [ "${chip_root}/src/app/data-model/tests", "${chip_root}/src/app/cluster-building-blocks/tests", - "${chip_root}/src/app/data-model-interface/tests", + "${chip_root}/src/app/data-model-provider/tests", "${chip_root}/src/access/tests", "${chip_root}/src/crypto/tests", "${chip_root}/src/inet/tests", @@ -87,11 +87,11 @@ if (chip_build_tests) { # are split, we can re-visit this (and likely many others) # # In particular: - # "app/codegen-data-model/tests" contains symbols for ember mocks which + # "app/codegen-data-model-provider/tests" contains symbols for ember mocks which # are used by other tests tests += [ - "${chip_root}/src/app/codegen-data-model/tests", + "${chip_root}/src/app/codegen-data-model-provider/tests", "${chip_root}/src/setup_payload/tests", "${chip_root}/src/transport/raw/tests", ] diff --git a/src/app/AttributePathExpandIterator-Checked.cpp b/src/app/AttributePathExpandIterator-Checked.cpp index 3d0d660edcf1eb..119eb29d5b22f4 100644 --- a/src/app/AttributePathExpandIterator-Checked.cpp +++ b/src/app/AttributePathExpandIterator-Checked.cpp @@ -20,7 +20,7 @@ namespace chip { namespace app { -AttributePathExpandIteratorChecked::AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel, +AttributePathExpandIteratorChecked::AttributePathExpandIteratorChecked(DataModel::Provider * dataModel, SingleLinkedListNode * attributePath) : mDataModelIterator(dataModel, attributePath), mEmberIterator(dataModel, attributePath) diff --git a/src/app/AttributePathExpandIterator-Checked.h b/src/app/AttributePathExpandIterator-Checked.h index e1611b3288ee18..efbe99ef6faade 100644 --- a/src/app/AttributePathExpandIterator-Checked.h +++ b/src/app/AttributePathExpandIterator-Checked.h @@ -26,8 +26,7 @@ namespace app { class AttributePathExpandIteratorChecked { public: - AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel, - SingleLinkedListNode * attributePath); + AttributePathExpandIteratorChecked(DataModel::Provider * dataModel, SingleLinkedListNode * attributePath); bool Next(); bool Get(ConcreteAttributePath & aPath); diff --git a/src/app/AttributePathExpandIterator-DataModel.cpp b/src/app/AttributePathExpandIterator-DataModel.cpp index 92af8b50ca6730..01facee22ebe43 100644 --- a/src/app/AttributePathExpandIterator-DataModel.cpp +++ b/src/app/AttributePathExpandIterator-DataModel.cpp @@ -18,14 +18,14 @@ #include #include -using namespace chip::app::InteractionModel; +using namespace chip::app::DataModel; namespace chip { namespace app { AttributePathExpandIteratorDataModel::AttributePathExpandIteratorDataModel( - InteractionModel::DataModel * dataModel, SingleLinkedListNode * attributePath) : - mDataModel(dataModel), + DataModel::Provider * provider, SingleLinkedListNode * attributePath) : + mDataModelProvider(provider), mpAttributePath(attributePath), mOutputPath(kInvalidEndpointId, kInvalidClusterId, kInvalidAttributeId) { @@ -52,7 +52,7 @@ bool AttributePathExpandIteratorDataModel::IsValidAttributeId(AttributeId attrib } const ConcreteAttributePath attributePath(mOutputPath.mEndpointId, mOutputPath.mClusterId, attributeId); - return mDataModel->GetAttributeInfo(attributePath).has_value(); + return mDataModelProvider->GetAttributeInfo(attributePath).has_value(); } std::optional AttributePathExpandIteratorDataModel::NextAttributeId() @@ -61,7 +61,7 @@ std::optional AttributePathExpandIteratorDataModel::NextAttributeId { if (mpAttributePath->mValue.HasWildcardAttributeId()) { - AttributeEntry entry = mDataModel->FirstAttribute(mOutputPath); + AttributeEntry entry = mDataModelProvider->FirstAttribute(mOutputPath); return entry.IsValid() // ? entry.path.mAttributeId // : Clusters::Globals::Attributes::GeneratedCommandList::Id; // @@ -99,7 +99,7 @@ std::optional AttributePathExpandIteratorDataModel::NextAttributeId return std::nullopt; } - AttributeEntry entry = mDataModel->NextAttribute(mOutputPath); + AttributeEntry entry = mDataModelProvider->NextAttribute(mOutputPath); if (entry.IsValid()) { return entry.path.mAttributeId; @@ -117,13 +117,13 @@ std::optional AttributePathExpandIteratorDataModel::NextClusterId() { if (mpAttributePath->mValue.HasWildcardClusterId()) { - ClusterEntry entry = mDataModel->FirstCluster(mOutputPath.mEndpointId); + ClusterEntry entry = mDataModelProvider->FirstCluster(mOutputPath.mEndpointId); return entry.IsValid() ? std::make_optional(entry.path.mClusterId) : std::nullopt; } // only return a cluster if it is valid const ConcreteClusterPath clusterPath(mOutputPath.mEndpointId, mpAttributePath->mValue.mClusterId); - if (!mDataModel->GetClusterInfo(clusterPath).has_value()) + if (!mDataModelProvider->GetClusterInfo(clusterPath).has_value()) { return std::nullopt; } @@ -133,7 +133,7 @@ std::optional AttributePathExpandIteratorDataModel::NextClusterId() VerifyOrReturnValue(mpAttributePath->mValue.HasWildcardClusterId(), std::nullopt); - ClusterEntry entry = mDataModel->NextCluster(mOutputPath); + ClusterEntry entry = mDataModelProvider->NextCluster(mOutputPath); return entry.IsValid() ? std::make_optional(entry.path.mClusterId) : std::nullopt; } @@ -143,7 +143,7 @@ std::optional AttributePathExpandIteratorDataModel::NextEndpointId() { if (mpAttributePath->mValue.HasWildcardEndpointId()) { - EndpointId id = mDataModel->FirstEndpoint(); + EndpointId id = mDataModelProvider->FirstEndpoint(); return (id != kInvalidEndpointId) ? std::make_optional(id) : std::nullopt; } @@ -152,7 +152,7 @@ std::optional AttributePathExpandIteratorDataModel::NextEndpointId() VerifyOrReturnValue(mpAttributePath->mValue.HasWildcardEndpointId(), std::nullopt); - EndpointId id = mDataModel->NextEndpoint(mOutputPath.mEndpointId); + EndpointId id = mDataModelProvider->NextEndpoint(mOutputPath.mEndpointId); return (id != kInvalidEndpointId) ? std::make_optional(id) : std::nullopt; } diff --git a/src/app/AttributePathExpandIterator-DataModel.h b/src/app/AttributePathExpandIterator-DataModel.h index 546151c7dd2806..c8baca768b4602 100644 --- a/src/app/AttributePathExpandIterator-DataModel.h +++ b/src/app/AttributePathExpandIterator-DataModel.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include namespace chip { @@ -53,8 +53,7 @@ namespace app { class AttributePathExpandIteratorDataModel { public: - AttributePathExpandIteratorDataModel(InteractionModel::DataModel * dataModel, - SingleLinkedListNode * attributePath); + AttributePathExpandIteratorDataModel(DataModel::Provider * provider, SingleLinkedListNode * attributePath); /** * Proceed the iterator to the next attribute path in the given cluster info. @@ -85,11 +84,11 @@ class AttributePathExpandIteratorDataModel /** Start iterating over the given `paths` */ inline void ResetTo(SingleLinkedListNode * paths) { - *this = AttributePathExpandIteratorDataModel(mDataModel, paths); + *this = AttributePathExpandIteratorDataModel(mDataModelProvider, paths); } private: - InteractionModel::DataModel * mDataModel; + DataModel::Provider * mDataModelProvider; SingleLinkedListNode * mpAttributePath; ConcreteAttributePath mOutputPath; diff --git a/src/app/AttributePathExpandIterator-Ember.cpp b/src/app/AttributePathExpandIterator-Ember.cpp index abaa621cb736ca..1149f0c7026918 100644 --- a/src/app/AttributePathExpandIterator-Ember.cpp +++ b/src/app/AttributePathExpandIterator-Ember.cpp @@ -53,7 +53,7 @@ extern bool emberAfEndpointIndexIsEnabled(uint16_t index); namespace chip { namespace app { -AttributePathExpandIteratorEmber::AttributePathExpandIteratorEmber(InteractionModel::DataModel *, +AttributePathExpandIteratorEmber::AttributePathExpandIteratorEmber(DataModel::Provider *, SingleLinkedListNode * aAttributePath) : mpAttributePath(aAttributePath) { diff --git a/src/app/AttributePathExpandIterator-Ember.h b/src/app/AttributePathExpandIterator-Ember.h index ef359fc21b60fa..c7c112d689064b 100644 --- a/src/app/AttributePathExpandIterator-Ember.h +++ b/src/app/AttributePathExpandIterator-Ember.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -70,7 +70,7 @@ namespace app { class AttributePathExpandIteratorEmber { public: - AttributePathExpandIteratorEmber(InteractionModel::DataModel *, // datamodel is NOT used by this class + AttributePathExpandIteratorEmber(DataModel::Provider *, // datamodel is NOT used by this class SingleLinkedListNode * aAttributePath); /** diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 8e6ca6dadc569b..53dd3876c12410 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -234,8 +234,8 @@ static_library("interaction-model") { ":paths", ":subscription-info-provider", "${chip_root}/src/app/MessageDef", - "${chip_root}/src/app/codegen-data-model:instance-header", - "${chip_root}/src/app/data-model-interface", + "${chip_root}/src/app/codegen-data-model-provider:instance-header", + "${chip_root}/src/app/data-model-provider", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/app/icd/server:manager", "${chip_root}/src/app/icd/server:observer", @@ -265,13 +265,13 @@ static_library("interaction-model") { "reporting/Read-Ember.cpp", "reporting/Read-Ember.h", ] - public_deps += [ "${chip_root}/src/app/data-model-interface" ] + public_deps += [ "${chip_root}/src/app/data-model-provider" ] } else { # enabled sources += [ "reporting/Read-DataModel.cpp", "reporting/Read-DataModel.h", ] - public_deps += [ "${chip_root}/src/app/data-model-interface" ] + public_deps += [ "${chip_root}/src/app/data-model-provider" ] } if (chip_enable_read_client) { @@ -491,14 +491,14 @@ static_library("app") { "AttributePathExpandIterator-Ember.h", "AttributePathExpandIterator.h", ] - public_deps += [ "${chip_root}/src/app/data-model-interface" ] + public_deps += [ "${chip_root}/src/app/data-model-provider" ] } else { # enabled sources += [ "AttributePathExpandIterator-DataModel.cpp", "AttributePathExpandIterator-DataModel.h", "AttributePathExpandIterator.h", ] - public_deps += [ "${chip_root}/src/app/data-model-interface" ] + public_deps += [ "${chip_root}/src/app/data-model-provider" ] } if (chip_enable_read_client) { diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index dcdbd3f10d2f85..639b590a16b345 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -43,7 +43,7 @@ #include #if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE -#include +#include #endif namespace chip { @@ -485,7 +485,7 @@ CHIP_ERROR InteractionModelEngine::ParseAttributePaths(const Access::SubjectDesc if (paramsList.mValue.IsWildcardPath()) { - AttributePathExpandIterator pathIterator(GetDataModel(), ¶msList); + AttributePathExpandIterator pathIterator(GetDataModelProvider(), ¶msList); ConcreteAttributePath readPath; // The definition of "valid path" is "path exists and ACL allows access". The "path exists" part is handled by @@ -849,7 +849,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest // We have already reserved enough resources for read requests, and have granted enough resources for current subscriptions, so // we should be able to allocate resources requested by this request. ReadHandler * handler = - mReadHandlers.CreateObject(*this, apExchangeContext, aInteractionType, mReportScheduler, GetDataModel()); + mReadHandlers.CreateObject(*this, apExchangeContext, aInteractionType, mReportScheduler, GetDataModelProvider()); if (handler == nullptr) { ChipLogProgress(InteractionModel, "no resource for %s interaction", @@ -1706,23 +1706,23 @@ Protocols::InteractionModel::Status InteractionModelEngine::CommandExists(const return ServerClusterCommandExists(aCommandPath); } -InteractionModel::DataModel * InteractionModelEngine::SetDataModel(InteractionModel::DataModel * model) +DataModel::Provider * InteractionModelEngine::SetDataModelProvider(DataModel::Provider * model) { // Alternting data model should not be done while IM is actively handling requests. VerifyOrDie(mReadHandlers.begin() == mReadHandlers.end()); - InteractionModel::DataModel * oldModel = GetDataModel(); - mDataModel = model; + DataModel::Provider * oldModel = GetDataModelProvider(); + mDataModelProvider = model; return oldModel; } -InteractionModel::DataModel * InteractionModelEngine::GetDataModel() const +DataModel::Provider * InteractionModelEngine::GetDataModelProvider() const { #if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE // TODO: this should be temporary, we should fully inject the data model - VerifyOrReturnValue(mDataModel != nullptr, CodegenDataModelInstance()); + VerifyOrReturnValue(mDataModelProvider != nullptr, CodegenDataModelProviderInstance()); #endif - return mDataModel; + return mDataModelProvider; } void InteractionModelEngine::OnTimedInteractionFailed(TimedHandler * apTimedHandler) diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 9d420f7f654176..c371bad23b2d2c 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -402,14 +402,14 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, } #endif - InteractionModel::DataModel * GetDataModel() const; + DataModel::Provider * GetDataModelProvider() const; // MUST NOT be used while the interaction model engine is running as interaction // model functionality (e.g. active reads/writes/subscriptions) rely on data model // state // - // Returns the old data model value. - InteractionModel::DataModel * SetDataModel(InteractionModel::DataModel * model); + // Returns the old data model provider value. + DataModel::Provider * SetDataModelProvider(DataModel::Provider * model); private: friend class reporting::Engine; @@ -698,7 +698,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, SubscriptionResumptionStorage * mpSubscriptionResumptionStorage = nullptr; - InteractionModel::DataModel * mDataModel = nullptr; + DataModel::Provider * mDataModelProvider = nullptr; }; } // namespace app diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 3e182bb9428a5f..43dae0a99f9c64 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -22,13 +22,13 @@ * */ -#include "data-model-interface/DataModel.h" #include #include #include #include #include #include +#include #include #include #include @@ -54,7 +54,7 @@ uint16_t ReadHandler::GetPublisherSelectedIntervalLimit() } ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeContext * apExchangeContext, - InteractionType aInteractionType, Observer * observer, InteractionModel::DataModel * apDataModel) : + InteractionType aInteractionType, Observer * observer, DataModel::Provider * apDataModel) : mAttributePathExpandIterator(apDataModel, nullptr), mExchangeCtx(*this), mManagementCallback(apCallback) { @@ -80,7 +80,7 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon } #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS -ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer, InteractionModel::DataModel * apDataModel) : +ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer, DataModel::Provider * apDataModel) : mAttributePathExpandIterator(apDataModel, nullptr), mExchangeCtx(*this), mManagementCallback(apCallback) { mInteractionType = InteractionType::Subscribe; diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 0f6b3fada87572..1ddcb4ebf0abb1 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -212,7 +212,7 @@ class ReadHandler : public Messaging::ExchangeDelegate * */ ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeContext * apExchangeContext, InteractionType aInteractionType, - Observer * observer, InteractionModel::DataModel * apDataModel); + Observer * observer, DataModel::Provider * apDataModel); #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS /** @@ -222,7 +222,7 @@ class ReadHandler : public Messaging::ExchangeDelegate * The callback passed in has to outlive this handler object. * */ - ReadHandler(ManagementCallback & apCallback, Observer * observer, InteractionModel::DataModel * apDataModel); + ReadHandler(ManagementCallback & apCallback, Observer * observer, DataModel::Provider * apDataModel); #endif const SingleLinkedListNode * GetAttributePathList() const { return mpAttributePathList; } diff --git a/src/app/SubscriptionResumptionSessionEstablisher.cpp b/src/app/SubscriptionResumptionSessionEstablisher.cpp index 11da3c3d496f92..e6f1ba02172631 100644 --- a/src/app/SubscriptionResumptionSessionEstablisher.cpp +++ b/src/app/SubscriptionResumptionSessionEstablisher.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include namespace chip { namespace app { @@ -105,7 +105,7 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnected(void * cont return; } ReadHandler * readHandler = - imEngine->mReadHandlers.CreateObject(*imEngine, imEngine->GetReportScheduler(), imEngine->GetDataModel()); + imEngine->mReadHandlers.CreateObject(*imEngine, imEngine->GetReportScheduler(), imEngine->GetDataModelProvider()); if (readHandler == nullptr) { // TODO - Should we keep the subscription here? diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index eac3b492c0eeff..499bf100256546 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -17,7 +17,7 @@ set(CHIP_APP_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) include("${CHIP_ROOT}/build/chip/chip_codegen.cmake") -include("${CHIP_ROOT}/src/app/codegen-data-model/model.cmake") +include("${CHIP_ROOT}/src/app/codegen-data-model-provider/model.cmake") # Configure ${APP_TARGET} with source files associated with ${CLUSTER} cluster # diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index ce65fe42331acb..3e4448a3bee467 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -15,7 +15,7 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") import("${chip_root}/build/chip/chip_codegen.gni") -import("${chip_root}/src/app/codegen-data-model/model.gni") +import("${chip_root}/src/app/codegen-data-model-provider/model.gni") import("${chip_root}/src/app/common_flags.gni") import("${chip_root}/src/platform/python.gni") diff --git a/src/app/codegen-data-model/BUILD.gn b/src/app/codegen-data-model-provider/BUILD.gn similarity index 92% rename from src/app/codegen-data-model/BUILD.gn rename to src/app/codegen-data-model-provider/BUILD.gn index 955f76c091c0bd..e88335b31044c5 100644 --- a/src/app/codegen-data-model/BUILD.gn +++ b/src/app/codegen-data-model-provider/BUILD.gn @@ -20,10 +20,10 @@ import("//build_overrides/chip.gni") # be available at link time for this model to use # # Use `model.gni` to get access to: -# CodegenDataModel.cpp -# CodegenDataModel.h -# CodegenDataModel_Read.cpp -# CodegenDataModel_Write.cpp +# CodegenDataModelProvider.cpp +# CodegenDataModelProvider.h +# CodegenDataModelProvider_Read.cpp +# CodegenDataModelProvider_Write.cpp # EmberMetadata.cpp # EmberMetadata.h # Instance.cpp diff --git a/src/app/codegen-data-model/CodegenDataModel.cpp b/src/app/codegen-data-model-provider/CodegenDataModelProvider.cpp similarity index 70% rename from src/app/codegen-data-model/CodegenDataModel.cpp rename to src/app/codegen-data-model-provider/CodegenDataModelProvider.cpp index 851f7c341ab127..e3b9823efeef9a 100644 --- a/src/app/codegen-data-model/CodegenDataModel.cpp +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include @@ -31,8 +31,7 @@ namespace app { namespace { /// Load the cluster information into the specified destination -std::variant LoadClusterInfo(const ConcreteClusterPath & path, - const EmberAfCluster & cluster) +std::variant LoadClusterInfo(const ConcreteClusterPath & path, const EmberAfCluster & cluster) { DataVersion * versionPtr = emberAfDataVersionStorage(path); if (versionPtr == nullptr) @@ -42,7 +41,7 @@ std::variant LoadClusterInfo(const Co return CHIP_ERROR_NOT_FOUND; } - InteractionModel::ClusterInfo info(*versionPtr); + DataModel::ClusterInfo info(*versionPtr); // TODO: set entry flags: // info->flags.Set(ClusterQualityFlags::kDiagnosticsData) @@ -51,7 +50,7 @@ std::variant LoadClusterInfo(const Co } /// Converts a EmberAfCluster into a ClusterEntry -std::variant ClusterEntryFrom(EndpointId endpointId, const EmberAfCluster & cluster) +std::variant ClusterEntryFrom(EndpointId endpointId, const EmberAfCluster & cluster) { ConcreteClusterPath clusterPath(endpointId, cluster.clusterId); auto info = LoadClusterInfo(clusterPath, cluster); @@ -61,9 +60,9 @@ std::variant ClusterEntryFrom(Endpoi return *err; } - if (InteractionModel::ClusterInfo * infoValue = std::get_if(&info)) + if (DataModel::ClusterInfo * infoValue = std::get_if(&info)) { - return InteractionModel::ClusterEntry{ + return DataModel::ClusterEntry{ .path = clusterPath, .info = *infoValue, }; @@ -74,8 +73,8 @@ std::variant ClusterEntryFrom(Endpoi /// Finds the first server cluster entry for the given endpoint data starting at [start_index] /// /// Returns an invalid entry if no more server clusters are found -InteractionModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, const EmberAfEndpointType * endpoint, - unsigned start_index, unsigned & found_index) +DataModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, const EmberAfEndpointType * endpoint, unsigned start_index, + unsigned & found_index) { for (unsigned cluster_idx = start_index; cluster_idx < endpoint->clusterCount; cluster_idx++) { @@ -88,7 +87,7 @@ InteractionModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, co found_index = cluster_idx; auto entry = ClusterEntryFrom(endpointId, cluster); - if (InteractionModel::ClusterEntry * entryValue = std::get_if(&entry)) + if (DataModel::ClusterEntry * entryValue = std::get_if(&entry)) { return *entryValue; } @@ -106,14 +105,14 @@ InteractionModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, co #endif } - return InteractionModel::ClusterEntry::kInvalid; + return DataModel::ClusterEntry::kInvalid; } /// Load the attribute information into the specified destination /// /// `info` is assumed to be default-constructed/clear (i.e. this sets flags, but does not reset them). void LoadAttributeInfo(const ConcreteAttributePath & path, const EmberAfAttributeMetadata & attribute, - InteractionModel::AttributeInfo * info) + DataModel::AttributeInfo * info) { info->readPrivilege = RequiredPrivilege::ForReadAttribute(path); if (!attribute.IsReadOnly()) @@ -121,8 +120,8 @@ void LoadAttributeInfo(const ConcreteAttributePath & path, const EmberAfAttribut info->writePrivilege = RequiredPrivilege::ForWriteAttribute(path); } - info->flags.Set(InteractionModel::AttributeQualityFlags::kListAttribute, (attribute.attributeType == ZCL_ARRAY_ATTRIBUTE_TYPE)); - info->flags.Set(InteractionModel::AttributeQualityFlags::kTimed, attribute.MustUseTimedWrite()); + info->flags.Set(DataModel::AttributeQualityFlags::kListAttribute, (attribute.attributeType == ZCL_ARRAY_ATTRIBUTE_TYPE)); + info->flags.Set(DataModel::AttributeQualityFlags::kTimed, attribute.MustUseTimedWrite()); // NOTE: we do NOT provide additional info for: // - IsExternal/IsSingleton/IsAutomaticallyPersisted is not used by IM handling @@ -131,15 +130,14 @@ void LoadAttributeInfo(const ConcreteAttributePath & path, const EmberAfAttribut // fixed, source attribution) // TODO: Set additional flags: - // info->flags.Set(InteractionModel::AttributeQualityFlags::kFabricScoped) - // info->flags.Set(InteractionModel::AttributeQualityFlags::kFabricSensitive) - // info->flags.Set(InteractionModel::AttributeQualityFlags::kChangesOmitted) + // info->flags.Set(DataModel::AttributeQualityFlags::kFabricScoped) + // info->flags.Set(DataModel::AttributeQualityFlags::kFabricSensitive) + // info->flags.Set(DataModel::AttributeQualityFlags::kChangesOmitted) } -InteractionModel::AttributeEntry AttributeEntryFrom(const ConcreteClusterPath & clusterPath, - const EmberAfAttributeMetadata & attribute) +DataModel::AttributeEntry AttributeEntryFrom(const ConcreteClusterPath & clusterPath, const EmberAfAttributeMetadata & attribute) { - InteractionModel::AttributeEntry entry; + DataModel::AttributeEntry entry; entry.path = ConcreteAttributePath(clusterPath.mEndpointId, clusterPath.mClusterId, attribute.attributeId); LoadAttributeInfo(entry.path, attribute, &entry.info); @@ -147,16 +145,15 @@ InteractionModel::AttributeEntry AttributeEntryFrom(const ConcreteClusterPath & return entry; } -InteractionModel::CommandEntry CommandEntryFrom(const ConcreteClusterPath & clusterPath, CommandId clusterCommandId) +DataModel::CommandEntry CommandEntryFrom(const ConcreteClusterPath & clusterPath, CommandId clusterCommandId) { - InteractionModel::CommandEntry entry; + DataModel::CommandEntry entry; entry.path = ConcreteCommandPath(clusterPath.mEndpointId, clusterPath.mClusterId, clusterCommandId); entry.info.invokePrivilege = RequiredPrivilege::ForInvokeCommand(entry.path); - entry.info.flags.Set(InteractionModel::CommandQualityFlags::kTimed, - CommandNeedsTimedInvoke(clusterPath.mClusterId, clusterCommandId)); + entry.info.flags.Set(DataModel::CommandQualityFlags::kTimed, CommandNeedsTimedInvoke(clusterPath.mClusterId, clusterCommandId)); - entry.info.flags.Set(InteractionModel::CommandQualityFlags::kFabricScoped, + entry.info.flags.Set(DataModel::CommandQualityFlags::kFabricScoped, CommandIsFabricScoped(clusterPath.mClusterId, clusterCommandId)); return entry; @@ -166,7 +163,7 @@ const ConcreteCommandPath kInvalidCommandPath(kInvalidEndpointId, kInvalidCluste } // namespace -std::optional CodegenDataModel::EmberCommandListIterator::First(const CommandId * list) +std::optional CodegenDataModelProvider::EmberCommandListIterator::First(const CommandId * list) { VerifyOrReturnValue(list != nullptr, std::nullopt); mCurrentList = mCurrentHint = list; @@ -175,7 +172,7 @@ std::optional CodegenDataModel::EmberCommandListIterator::First(const return *mCurrentList; } -std::optional CodegenDataModel::EmberCommandListIterator::Next(const CommandId * list, CommandId previousId) +std::optional CodegenDataModelProvider::EmberCommandListIterator::Next(const CommandId * list, CommandId previousId) { VerifyOrReturnValue(list != nullptr, std::nullopt); VerifyOrReturnValue(previousId != kInvalidCommandId, std::nullopt); @@ -204,7 +201,7 @@ std::optional CodegenDataModel::EmberCommandListIterator::Next(const return (*mCurrentHint == kInvalidCommandId) ? std::nullopt : std::make_optional(*mCurrentHint); } -bool CodegenDataModel::EmberCommandListIterator::Exists(const CommandId * list, CommandId toCheck) +bool CodegenDataModelProvider::EmberCommandListIterator::Exists(const CommandId * list, CommandId toCheck) { VerifyOrReturnValue(list != nullptr, false); VerifyOrReturnValue(toCheck != kInvalidCommandId, false); @@ -232,8 +229,8 @@ bool CodegenDataModel::EmberCommandListIterator::Exists(const CommandId * list, return (*mCurrentHint == toCheck); } -CHIP_ERROR CodegenDataModel::Invoke(const InteractionModel::InvokeRequest & request, TLV::TLVReader & input_arguments, - CommandHandler * handler) +CHIP_ERROR CodegenDataModelProvider::Invoke(const DataModel::InvokeRequest & request, TLV::TLVReader & input_arguments, + CommandHandler * handler) { // TODO: CommandHandlerInterface support is currently // residing in InteractionModelEngine itself. We may want to separate this out @@ -248,7 +245,7 @@ CHIP_ERROR CodegenDataModel::Invoke(const InteractionModel::InvokeRequest & requ return CHIP_NO_ERROR; } -EndpointId CodegenDataModel::FirstEndpoint() +EndpointId CodegenDataModelProvider::FirstEndpoint() { // find the first enabled index const uint16_t lastEndpointIndex = emberAfEndpointCount(); @@ -265,7 +262,7 @@ EndpointId CodegenDataModel::FirstEndpoint() return kInvalidEndpointId; } -std::optional CodegenDataModel::TryFindEndpointIndex(EndpointId id) const +std::optional CodegenDataModelProvider::TryFindEndpointIndex(EndpointId id) const { const uint16_t lastEndpointIndex = emberAfEndpointCount(); @@ -285,7 +282,7 @@ std::optional CodegenDataModel::TryFindEndpointIndex(EndpointId id) co return std::make_optional(idx); } -EndpointId CodegenDataModel::NextEndpoint(EndpointId before) +EndpointId CodegenDataModelProvider::NextEndpoint(EndpointId before) { const unsigned lastEndpointIndex = emberAfEndpointCount(); @@ -309,17 +306,18 @@ EndpointId CodegenDataModel::NextEndpoint(EndpointId before) return kInvalidEndpointId; } -InteractionModel::ClusterEntry CodegenDataModel::FirstCluster(EndpointId endpointId) +DataModel::ClusterEntry CodegenDataModelProvider::FirstCluster(EndpointId endpointId) { const EmberAfEndpointType * endpoint = emberAfFindEndpointType(endpointId); - VerifyOrReturnValue(endpoint != nullptr, InteractionModel::ClusterEntry::kInvalid); - VerifyOrReturnValue(endpoint->clusterCount > 0, InteractionModel::ClusterEntry::kInvalid); - VerifyOrReturnValue(endpoint->cluster != nullptr, InteractionModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint != nullptr, DataModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint->clusterCount > 0, DataModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint->cluster != nullptr, DataModel::ClusterEntry::kInvalid); return FirstServerClusterEntry(endpointId, endpoint, 0, mClusterIterationHint); } -std::optional CodegenDataModel::TryFindServerClusterIndex(const EmberAfEndpointType * endpoint, ClusterId id) const +std::optional CodegenDataModelProvider::TryFindServerClusterIndex(const EmberAfEndpointType * endpoint, + ClusterId id) const { const unsigned clusterCount = endpoint->clusterCount; @@ -347,26 +345,26 @@ std::optional CodegenDataModel::TryFindServerClusterIndex(const EmberA return std::nullopt; } -InteractionModel::ClusterEntry CodegenDataModel::NextCluster(const ConcreteClusterPath & before) +DataModel::ClusterEntry CodegenDataModelProvider::NextCluster(const ConcreteClusterPath & before) { // TODO: This search still seems slow (ember will loop). Should use index hints as long // as ember API supports it const EmberAfEndpointType * endpoint = emberAfFindEndpointType(before.mEndpointId); - VerifyOrReturnValue(endpoint != nullptr, InteractionModel::ClusterEntry::kInvalid); - VerifyOrReturnValue(endpoint->clusterCount > 0, InteractionModel::ClusterEntry::kInvalid); - VerifyOrReturnValue(endpoint->cluster != nullptr, InteractionModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint != nullptr, DataModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint->clusterCount > 0, DataModel::ClusterEntry::kInvalid); + VerifyOrReturnValue(endpoint->cluster != nullptr, DataModel::ClusterEntry::kInvalid); std::optional cluster_idx = TryFindServerClusterIndex(endpoint, before.mClusterId); if (!cluster_idx.has_value()) { - return InteractionModel::ClusterEntry::kInvalid; + return DataModel::ClusterEntry::kInvalid; } return FirstServerClusterEntry(before.mEndpointId, endpoint, *cluster_idx + 1, mClusterIterationHint); } -std::optional CodegenDataModel::GetClusterInfo(const ConcreteClusterPath & path) +std::optional CodegenDataModelProvider::GetClusterInfo(const ConcreteClusterPath & path) { const EmberAfCluster * cluster = FindServerCluster(path); @@ -384,22 +382,22 @@ std::optional CodegenDataModel::GetClusterInfo(co return std::nullopt; } - return std::make_optional(std::get(info)); + return std::make_optional(std::get(info)); } -InteractionModel::AttributeEntry CodegenDataModel::FirstAttribute(const ConcreteClusterPath & path) +DataModel::AttributeEntry CodegenDataModelProvider::FirstAttribute(const ConcreteClusterPath & path) { const EmberAfCluster * cluster = FindServerCluster(path); - VerifyOrReturnValue(cluster != nullptr, InteractionModel::AttributeEntry::kInvalid); - VerifyOrReturnValue(cluster->attributeCount > 0, InteractionModel::AttributeEntry::kInvalid); - VerifyOrReturnValue(cluster->attributes != nullptr, InteractionModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster != nullptr, DataModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster->attributeCount > 0, DataModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster->attributes != nullptr, DataModel::AttributeEntry::kInvalid); mAttributeIterationHint = 0; return AttributeEntryFrom(path, cluster->attributes[0]); } -std::optional CodegenDataModel::TryFindAttributeIndex(const EmberAfCluster * cluster, AttributeId id) const +std::optional CodegenDataModelProvider::TryFindAttributeIndex(const EmberAfCluster * cluster, AttributeId id) const { const unsigned attributeCount = cluster->attributeCount; @@ -422,7 +420,7 @@ std::optional CodegenDataModel::TryFindAttributeIndex(const EmberAfClu return std::nullopt; } -const EmberAfCluster * CodegenDataModel::FindServerCluster(const ConcreteClusterPath & path) +const EmberAfCluster * CodegenDataModelProvider::FindServerCluster(const ConcreteClusterPath & path) { // cache things if (mPreviouslyFoundCluster.has_value() && (mPreviouslyFoundCluster->path == path)) @@ -438,18 +436,18 @@ const EmberAfCluster * CodegenDataModel::FindServerCluster(const ConcreteCluster return cluster; } -InteractionModel::AttributeEntry CodegenDataModel::NextAttribute(const ConcreteAttributePath & before) +DataModel::AttributeEntry CodegenDataModelProvider::NextAttribute(const ConcreteAttributePath & before) { const EmberAfCluster * cluster = FindServerCluster(before); - VerifyOrReturnValue(cluster != nullptr, InteractionModel::AttributeEntry::kInvalid); - VerifyOrReturnValue(cluster->attributeCount > 0, InteractionModel::AttributeEntry::kInvalid); - VerifyOrReturnValue(cluster->attributes != nullptr, InteractionModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster != nullptr, DataModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster->attributeCount > 0, DataModel::AttributeEntry::kInvalid); + VerifyOrReturnValue(cluster->attributes != nullptr, DataModel::AttributeEntry::kInvalid); // find the given attribute in the list and then return the next one std::optional attribute_idx = TryFindAttributeIndex(cluster, before.mAttributeId); if (!attribute_idx.has_value()) { - return InteractionModel::AttributeEntry::kInvalid; + return DataModel::AttributeEntry::kInvalid; } unsigned next_idx = *attribute_idx + 1; @@ -460,10 +458,10 @@ InteractionModel::AttributeEntry CodegenDataModel::NextAttribute(const ConcreteA } // iteration complete - return InteractionModel::AttributeEntry::kInvalid; + return DataModel::AttributeEntry::kInvalid; } -std::optional CodegenDataModel::GetAttributeInfo(const ConcreteAttributePath & path) +std::optional CodegenDataModelProvider::GetAttributeInfo(const ConcreteAttributePath & path) { const EmberAfCluster * cluster = FindServerCluster(path); @@ -478,36 +476,36 @@ std::optional CodegenDataModel::GetAttributeInf return std::nullopt; } - InteractionModel::AttributeInfo info; + DataModel::AttributeInfo info; LoadAttributeInfo(path, cluster->attributes[*attribute_idx], &info); return std::make_optional(info); } -InteractionModel::CommandEntry CodegenDataModel::FirstAcceptedCommand(const ConcreteClusterPath & path) +DataModel::CommandEntry CodegenDataModelProvider::FirstAcceptedCommand(const ConcreteClusterPath & path) { const EmberAfCluster * cluster = FindServerCluster(path); - VerifyOrReturnValue(cluster != nullptr, InteractionModel::CommandEntry::kInvalid); + VerifyOrReturnValue(cluster != nullptr, DataModel::CommandEntry::kInvalid); std::optional commandId = mAcceptedCommandsIterator.First(cluster->acceptedCommandList); - VerifyOrReturnValue(commandId.has_value(), InteractionModel::CommandEntry::kInvalid); + VerifyOrReturnValue(commandId.has_value(), DataModel::CommandEntry::kInvalid); return CommandEntryFrom(path, *commandId); } -InteractionModel::CommandEntry CodegenDataModel::NextAcceptedCommand(const ConcreteCommandPath & before) +DataModel::CommandEntry CodegenDataModelProvider::NextAcceptedCommand(const ConcreteCommandPath & before) { const EmberAfCluster * cluster = FindServerCluster(before); - VerifyOrReturnValue(cluster != nullptr, InteractionModel::CommandEntry::kInvalid); + VerifyOrReturnValue(cluster != nullptr, DataModel::CommandEntry::kInvalid); std::optional commandId = mAcceptedCommandsIterator.Next(cluster->acceptedCommandList, before.mCommandId); - VerifyOrReturnValue(commandId.has_value(), InteractionModel::CommandEntry::kInvalid); + VerifyOrReturnValue(commandId.has_value(), DataModel::CommandEntry::kInvalid); return CommandEntryFrom(before, *commandId); } -std::optional CodegenDataModel::GetAcceptedCommandInfo(const ConcreteCommandPath & path) +std::optional CodegenDataModelProvider::GetAcceptedCommandInfo(const ConcreteCommandPath & path) { const EmberAfCluster * cluster = FindServerCluster(path); @@ -517,7 +515,7 @@ std::optional CodegenDataModel::GetAcceptedComman return CommandEntryFrom(path, path.mCommandId).info; } -ConcreteCommandPath CodegenDataModel::FirstGeneratedCommand(const ConcreteClusterPath & path) +ConcreteCommandPath CodegenDataModelProvider::FirstGeneratedCommand(const ConcreteClusterPath & path) { const EmberAfCluster * cluster = FindServerCluster(path); @@ -528,7 +526,7 @@ ConcreteCommandPath CodegenDataModel::FirstGeneratedCommand(const ConcreteCluste return ConcreteCommandPath(path.mEndpointId, path.mClusterId, *commandId); } -ConcreteCommandPath CodegenDataModel::NextGeneratedCommand(const ConcreteCommandPath & before) +ConcreteCommandPath CodegenDataModelProvider::NextGeneratedCommand(const ConcreteCommandPath & before) { const EmberAfCluster * cluster = FindServerCluster(before); diff --git a/src/app/codegen-data-model/CodegenDataModel.h b/src/app/codegen-data-model-provider/CodegenDataModelProvider.h similarity index 75% rename from src/app/codegen-data-model/CodegenDataModel.h rename to src/app/codegen-data-model-provider/CodegenDataModelProvider.h index 123dcd72382291..21dc0cc87e1a31 100644 --- a/src/app/codegen-data-model/CodegenDataModel.h +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider.h @@ -16,7 +16,7 @@ */ #pragma once -#include +#include #include @@ -33,9 +33,9 @@ namespace app { /// as well as application-specific overrides to provide data model functionality. /// /// Given that this relies on global data at link time, there generally can be -/// only one CodegenDataModel per application (you can create more instances, +/// only one CodegenDataModelProvider per application (you can create more instances, /// however they would share the exact same underlying data and storage). -class CodegenDataModel : public chip::app::InteractionModel::DataModel +class CodegenDataModelProvider : public chip::app::DataModel::Provider { private: /// Ember commands are stored as a `CommandId *` pointer that is either null (i.e. no commands) @@ -68,26 +68,26 @@ class CodegenDataModel : public chip::app::InteractionModel::DataModel /// Generic model implementations CHIP_ERROR Shutdown() override { return CHIP_NO_ERROR; } - CHIP_ERROR ReadAttribute(const InteractionModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; - CHIP_ERROR WriteAttribute(const InteractionModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; - CHIP_ERROR Invoke(const InteractionModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, + CHIP_ERROR ReadAttribute(const DataModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; + CHIP_ERROR WriteAttribute(const DataModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; + CHIP_ERROR Invoke(const DataModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, CommandHandler * handler) override; /// attribute tree iteration EndpointId FirstEndpoint() override; EndpointId NextEndpoint(EndpointId before) override; - InteractionModel::ClusterEntry FirstCluster(EndpointId endpoint) override; - InteractionModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; - std::optional GetClusterInfo(const ConcreteClusterPath & path) override; + DataModel::ClusterEntry FirstCluster(EndpointId endpoint) override; + DataModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; + std::optional GetClusterInfo(const ConcreteClusterPath & path) override; - InteractionModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; - InteractionModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; - std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; + DataModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; + DataModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; + std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; - InteractionModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; - InteractionModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; - std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; + DataModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; + DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; + std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override; ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override; diff --git a/src/app/codegen-data-model/CodegenDataModel_Read.cpp b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp similarity index 97% rename from src/app/codegen-data-model/CodegenDataModel_Read.cpp rename to src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp index 3e1f246cb3a2f9..d27d18964dccf7 100644 --- a/src/app/codegen-data-model/CodegenDataModel_Read.cpp +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -258,7 +258,7 @@ CHIP_ERROR EncodeEmberValue(ByteSpan data, const EmberAfAttributeMetadata * meta /// - validate ACL (only for non-internal requests) /// - Try to read attribute via the AttributeAccessInterface /// - Try to read the value from ember RAM storage -CHIP_ERROR CodegenDataModel::ReadAttribute(const InteractionModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) +CHIP_ERROR CodegenDataModelProvider::ReadAttribute(const DataModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) { ChipLogDetail(DataManagement, "Reading attribute: Cluster=" ChipLogFormatMEI " Endpoint=0x%x AttributeId=" ChipLogFormatMEI " (expanded=%d)", @@ -266,7 +266,7 @@ CHIP_ERROR CodegenDataModel::ReadAttribute(const InteractionModel::ReadAttribute request.path.mExpanded); // ACL check for non-internal requests - if (!request.operationFlags.Has(InteractionModel::OperationFlags::kInternal)) + if (!request.operationFlags.Has(DataModel::OperationFlags::kInternal)) { ReturnErrorCodeIf(!request.subjectDescriptor.has_value(), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/app/codegen-data-model/CodegenDataModel_Write.cpp b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp similarity index 96% rename from src/app/codegen-data-model/CodegenDataModel_Write.cpp rename to src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp index 999f35ea7836cf..962355e8e47b08 100644 --- a/src/app/codegen-data-model/CodegenDataModel_Write.cpp +++ b/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include #include #include #include -#include +#include #include #include #include @@ -266,14 +266,14 @@ CHIP_ERROR DecodeValueIntoEmberBuffer(AttributeValueDecoder & decoder, const Emb } // namespace -CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttributeRequest & request, - AttributeValueDecoder & decoder) +CHIP_ERROR CodegenDataModelProvider::WriteAttribute(const DataModel::WriteAttributeRequest & request, + AttributeValueDecoder & decoder) { ChipLogDetail(DataManagement, "Writing attribute: Cluster=" ChipLogFormatMEI " Endpoint=0x%x AttributeId=" ChipLogFormatMEI, ChipLogValueMEI(request.path.mClusterId), request.path.mEndpointId, ChipLogValueMEI(request.path.mAttributeId)); // ACL check for non-internal requests - if (!request.operationFlags.Has(InteractionModel::OperationFlags::kInternal)) + if (!request.operationFlags.Has(DataModel::OperationFlags::kInternal)) { ReturnErrorCodeIf(!request.subjectDescriptor.has_value(), CHIP_IM_GLOBAL_STATUS(UnsupportedAccess)); @@ -314,12 +314,11 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu bool isReadOnly = (attributeMetadata == nullptr) || (*attributeMetadata)->IsReadOnly(); // Internal is allowed to bypass timed writes and read-only. - if (!request.operationFlags.Has(InteractionModel::OperationFlags::kInternal)) + if (!request.operationFlags.Has(DataModel::OperationFlags::kInternal)) { VerifyOrReturnError(!isReadOnly, CHIP_IM_GLOBAL_STATUS(UnsupportedWrite)); - VerifyOrReturnError(!(*attributeMetadata)->MustUseTimedWrite() || - request.writeFlags.Has(InteractionModel::WriteFlags::kTimed), + VerifyOrReturnError(!(*attributeMetadata)->MustUseTimedWrite() || request.writeFlags.Has(DataModel::WriteFlags::kTimed), CHIP_IM_GLOBAL_STATUS(NeedsTimedInteraction)); } @@ -329,7 +328,7 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu if (request.path.mDataVersion.HasValue()) { - std::optional clusterInfo = GetClusterInfo(request.path); + std::optional clusterInfo = GetClusterInfo(request.path); if (!clusterInfo.has_value()) { ChipLogError(DataManagement, "Unable to get cluster info for Endpoint 0x%x, Cluster " ChipLogFormatMEI, @@ -371,7 +370,7 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu return CHIP_IM_GLOBAL_STATUS(InvalidValue); } - if (request.operationFlags.Has(InteractionModel::OperationFlags::kInternal)) + if (request.operationFlags.Has(DataModel::OperationFlags::kInternal)) { // Internal requests use the non-External interface that has less enforcement // than the external version (e.g. does not check/enforce writable settings, does not diff --git a/src/app/codegen-data-model/EmberMetadata.cpp b/src/app/codegen-data-model-provider/EmberMetadata.cpp similarity index 98% rename from src/app/codegen-data-model/EmberMetadata.cpp rename to src/app/codegen-data-model-provider/EmberMetadata.cpp index 9114196a377906..b8d998d29f0b7e 100644 --- a/src/app/codegen-data-model/EmberMetadata.cpp +++ b/src/app/codegen-data-model-provider/EmberMetadata.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include diff --git a/src/app/codegen-data-model/EmberMetadata.h b/src/app/codegen-data-model-provider/EmberMetadata.h similarity index 100% rename from src/app/codegen-data-model/EmberMetadata.h rename to src/app/codegen-data-model-provider/EmberMetadata.h diff --git a/src/app/codegen-data-model/Instance.cpp b/src/app/codegen-data-model-provider/Instance.cpp similarity index 76% rename from src/app/codegen-data-model/Instance.cpp rename to src/app/codegen-data-model-provider/Instance.cpp index 98eeeb604503b9..30a52dd5fb219a 100644 --- a/src/app/codegen-data-model/Instance.cpp +++ b/src/app/codegen-data-model-provider/Instance.cpp @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include +#include +#include namespace chip { namespace app { -InteractionModel::DataModel * CodegenDataModelInstance() +DataModel::Provider * CodegenDataModelProviderInstance() { - static CodegenDataModel gCodegenModel; + static CodegenDataModelProvider gCodegenModel; return &gCodegenModel; } diff --git a/src/app/codegen-data-model/Instance.h b/src/app/codegen-data-model-provider/Instance.h similarity index 87% rename from src/app/codegen-data-model/Instance.h rename to src/app/codegen-data-model-provider/Instance.h index 4c7530981920c1..37f891280424f7 100644 --- a/src/app/codegen-data-model/Instance.h +++ b/src/app/codegen-data-model-provider/Instance.h @@ -16,12 +16,12 @@ */ #pragma once -#include +#include namespace chip { namespace app { -InteractionModel::DataModel * CodegenDataModelInstance(); +DataModel::Provider * CodegenDataModelProviderInstance(); } // namespace app } // namespace chip diff --git a/src/app/codegen-data-model/model.cmake b/src/app/codegen-data-model-provider/model.cmake similarity index 81% rename from src/app/codegen-data-model/model.cmake rename to src/app/codegen-data-model-provider/model.cmake index 73b54247a81033..777219549e44eb 100644 --- a/src/app/codegen-data-model/model.cmake +++ b/src/app/codegen-data-model-provider/model.cmake @@ -15,10 +15,10 @@ set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) # If you change this list, please ALSO CHANGE model.gni SET(CODEGEN_DATA_MODEL_SOURCES - "${BASE_DIR}/CodegenDataModel.cpp" - "${BASE_DIR}/CodegenDataModel.h" - "${BASE_DIR}/CodegenDataModel_Read.cpp" - "${BASE_DIR}/CodegenDataModel_Write.cpp" + "${BASE_DIR}/CodegenDataModelProvider.cpp" + "${BASE_DIR}/CodegenDataModelProvider.h" + "${BASE_DIR}/CodegenDataModelProvider_Read.cpp" + "${BASE_DIR}/CodegenDataModelProvider_Write.cpp" "${BASE_DIR}/EmberMetadata.cpp" "${BASE_DIR}/EmberMetadata.h" "${BASE_DIR}/Instance.cpp" diff --git a/src/app/codegen-data-model/model.gni b/src/app/codegen-data-model-provider/model.gni similarity index 66% rename from src/app/codegen-data-model/model.gni rename to src/app/codegen-data-model-provider/model.gni index 25f50571223971..f70d0b9ce96455 100644 --- a/src/app/codegen-data-model/model.gni +++ b/src/app/codegen-data-model-provider/model.gni @@ -25,17 +25,17 @@ import("//build_overrides/chip.gni") # be cleanly built as a stand-alone and instead have to be imported as part of # a different data model or compilation unit. codegen_data_model_SOURCES = [ - "${chip_root}/src/app/codegen-data-model/CodegenDataModel.cpp", - "${chip_root}/src/app/codegen-data-model/CodegenDataModel.h", - "${chip_root}/src/app/codegen-data-model/CodegenDataModel_Read.cpp", - "${chip_root}/src/app/codegen-data-model/CodegenDataModel_Write.cpp", - "${chip_root}/src/app/codegen-data-model/EmberMetadata.cpp", - "${chip_root}/src/app/codegen-data-model/EmberMetadata.h", - "${chip_root}/src/app/codegen-data-model/Instance.cpp", + "${chip_root}/src/app/codegen-data-model-provider/CodegenDataModelProvider.cpp", + "${chip_root}/src/app/codegen-data-model-provider/CodegenDataModelProvider.h", + "${chip_root}/src/app/codegen-data-model-provider/CodegenDataModelProvider_Read.cpp", + "${chip_root}/src/app/codegen-data-model-provider/CodegenDataModelProvider_Write.cpp", + "${chip_root}/src/app/codegen-data-model-provider/EmberMetadata.cpp", + "${chip_root}/src/app/codegen-data-model-provider/EmberMetadata.h", + "${chip_root}/src/app/codegen-data-model-provider/Instance.cpp", ] codegen_data_model_PUBLIC_DEPS = [ "${chip_root}/src/app/common:attribute-type", - "${chip_root}/src/app/data-model-interface", - "${chip_root}/src/app/codegen-data-model:instance-header", + "${chip_root}/src/app/data-model-provider", + "${chip_root}/src/app/codegen-data-model-provider:instance-header", ] diff --git a/src/app/codegen-data-model/tests/AttributeReportIBEncodeDecode.cpp b/src/app/codegen-data-model-provider/tests/AttributeReportIBEncodeDecode.cpp similarity index 100% rename from src/app/codegen-data-model/tests/AttributeReportIBEncodeDecode.cpp rename to src/app/codegen-data-model-provider/tests/AttributeReportIBEncodeDecode.cpp diff --git a/src/app/codegen-data-model/tests/AttributeReportIBEncodeDecode.h b/src/app/codegen-data-model-provider/tests/AttributeReportIBEncodeDecode.h similarity index 100% rename from src/app/codegen-data-model/tests/AttributeReportIBEncodeDecode.h rename to src/app/codegen-data-model-provider/tests/AttributeReportIBEncodeDecode.h diff --git a/src/app/codegen-data-model/tests/BUILD.gn b/src/app/codegen-data-model-provider/tests/BUILD.gn similarity index 94% rename from src/app/codegen-data-model/tests/BUILD.gn rename to src/app/codegen-data-model-provider/tests/BUILD.gn index 3f88ac61c41766..451a276c0367d2 100644 --- a/src/app/codegen-data-model/tests/BUILD.gn +++ b/src/app/codegen-data-model-provider/tests/BUILD.gn @@ -13,7 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") import("${chip_root}/build/chip/chip_test_suite.gni") -import("${chip_root}/src/app/codegen-data-model/model.gni") +import("${chip_root}/src/app/codegen-data-model-provider/model.gni") source_set("ember_extra_files") { sources = [ @@ -51,7 +51,7 @@ source_set("mock_model") { } chip_test_suite("tests") { - output_name = "libCodegenDataModelTests" + output_name = "libCodegenDataModelProviderTests" test_sources = [ "TestCodegenModelViaMocks.cpp" ] diff --git a/src/app/codegen-data-model/tests/EmberInvokeOverride.cpp b/src/app/codegen-data-model-provider/tests/EmberInvokeOverride.cpp similarity index 100% rename from src/app/codegen-data-model/tests/EmberInvokeOverride.cpp rename to src/app/codegen-data-model-provider/tests/EmberInvokeOverride.cpp diff --git a/src/app/codegen-data-model/tests/EmberInvokeOverride.h b/src/app/codegen-data-model-provider/tests/EmberInvokeOverride.h similarity index 100% rename from src/app/codegen-data-model/tests/EmberInvokeOverride.h rename to src/app/codegen-data-model-provider/tests/EmberInvokeOverride.h diff --git a/src/app/codegen-data-model/tests/EmberReadWriteOverride.cpp b/src/app/codegen-data-model-provider/tests/EmberReadWriteOverride.cpp similarity index 100% rename from src/app/codegen-data-model/tests/EmberReadWriteOverride.cpp rename to src/app/codegen-data-model-provider/tests/EmberReadWriteOverride.cpp diff --git a/src/app/codegen-data-model/tests/EmberReadWriteOverride.h b/src/app/codegen-data-model-provider/tests/EmberReadWriteOverride.h similarity index 100% rename from src/app/codegen-data-model/tests/EmberReadWriteOverride.h rename to src/app/codegen-data-model-provider/tests/EmberReadWriteOverride.h diff --git a/src/app/codegen-data-model/tests/InteractionModelTemporaryOverrides.cpp b/src/app/codegen-data-model-provider/tests/InteractionModelTemporaryOverrides.cpp similarity index 100% rename from src/app/codegen-data-model/tests/InteractionModelTemporaryOverrides.cpp rename to src/app/codegen-data-model-provider/tests/InteractionModelTemporaryOverrides.cpp diff --git a/src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp b/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp similarity index 96% rename from src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp rename to src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp index 796c845ebe7787..947d0aecd9684d 100644 --- a/src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp +++ b/src/app/codegen-data-model-provider/tests/TestCodegenModelViaMocks.cpp @@ -20,11 +20,11 @@ #include #include "app/ConcreteCommandPath.h" -#include +#include -#include -#include -#include +#include +#include +#include #include #include @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ using namespace chip; using namespace chip::Test; using namespace chip::app; -using namespace chip::app::InteractionModel; +using namespace chip::app::DataModel; using namespace chip::app::Clusters::Globals::Attributes; namespace { @@ -126,7 +126,7 @@ bool operator==(const Access::SubjectDescriptor & a, const Access::SubjectDescri return true; } -class TestDataModelChangeListener : public DataModelChangeListener +class TestProviderChangeListener : public ProviderChangeListener { public: void MarkDirty(const ConcreteAttributePath & path) override { mDirtyList.push_back(path); } @@ -153,10 +153,10 @@ class TestActionContext : public ActionContext Messaging::ExchangeContext * CurrentExchange() override { return nullptr; } }; -class CodegenDataModelWithContext : public CodegenDataModel +class CodegenDataModelProviderWithContext : public CodegenDataModelProvider { public: - CodegenDataModelWithContext() + CodegenDataModelProviderWithContext() { InteractionModelContext context{ .eventsGenerator = &mEventGenerator, @@ -166,14 +166,14 @@ class CodegenDataModelWithContext : public CodegenDataModel Startup(context); } - ~CodegenDataModelWithContext() { Shutdown(); } + ~CodegenDataModelProviderWithContext() { Shutdown(); } - TestDataModelChangeListener & ChangeListener() { return mChangeListener; } - const TestDataModelChangeListener & ChangeListener() const { return mChangeListener; } + TestProviderChangeListener & ChangeListener() { return mChangeListener; } + const TestProviderChangeListener & ChangeListener() const { return mChangeListener; } private: TestEventGenerator mEventGenerator; - TestDataModelChangeListener mChangeListener; + TestProviderChangeListener mChangeListener; TestActionContext mActionContext; }; @@ -625,7 +625,7 @@ struct TestReadRequest request.path = path; } - std::unique_ptr StartEncoding(InteractionModel::DataModel * model, + std::unique_ptr StartEncoding(DataModel::Provider * model, AttributeEncodeState state = AttributeEncodeState()) { std::optional info = model->GetClusterInfo(request.path); @@ -658,7 +658,7 @@ struct TestReadRequest // Sets up data for writing struct TestWriteRequest { - InteractionModel::WriteAttributeRequest request; + DataModel::WriteAttributeRequest request; uint8_t tlvBuffer[128] = { 0 }; TLV::TLVReader tlvReader; /// tlv reader used for the returned AttributeValueDecoder (since attributeValueDecoder uses references) @@ -708,7 +708,7 @@ template void TestEmberScalarTypeRead(typename NumericAttributeTraits::WorkingType value) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest( @@ -743,7 +743,7 @@ template void TestEmberScalarNullRead() { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest( @@ -776,7 +776,7 @@ template void TestEmberScalarTypeWrite(const typename NumericAttributeTraits::WorkingType value) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; // non-nullable test @@ -833,7 +833,7 @@ template void TestEmberScalarNullWrite() { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -861,7 +861,7 @@ template void TestEmberScalarTypeWriteNullValueToNullable() { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test( @@ -893,7 +893,7 @@ void WriteLe16(void * buffer, uint16_t value) TEST(TestCodegenModelViaMocks, IterateOverEndpoints) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // This iteration relies on the hard-coding that occurs when mock_ember is used EXPECT_EQ(model.FirstEndpoint(), kMockEndpoint1); @@ -921,7 +921,7 @@ TEST(TestCodegenModelViaMocks, IterateOverEndpoints) TEST(TestCodegenModelViaMocks, IterateOverClusters) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; chip::Test::ResetVersion(); @@ -984,7 +984,7 @@ TEST(TestCodegenModelViaMocks, GetClusterInfo) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; chip::Test::ResetVersion(); @@ -1009,7 +1009,7 @@ TEST(TestCodegenModelViaMocks, GetClusterInfo) TEST(TestCodegenModelViaMocks, IterateOverAttributes) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // invalid paths should return in "no more data" ASSERT_FALSE(model.FirstAttribute(ConcreteClusterPath(kEndpointIdThatIsMissing, MockClusterId(1))).path.HasValidIds()); @@ -1080,7 +1080,7 @@ TEST(TestCodegenModelViaMocks, IterateOverAttributes) TEST(TestCodegenModelViaMocks, GetAttributeInfo) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // various non-existent or invalid paths should return no info data ASSERT_FALSE( @@ -1120,7 +1120,7 @@ TEST(TestCodegenModelViaMocks, GetAttributeInfo) TEST(TestCodegenModelViaMocks, GlobalAttributeInfo) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; std::optional info = model.GetAttributeInfo( ConcreteAttributePath(kMockEndpoint1, MockClusterId(1), Clusters::Globals::Attributes::GeneratedCommandList::Id)); @@ -1135,7 +1135,7 @@ TEST(TestCodegenModelViaMocks, GlobalAttributeInfo) TEST(TestCodegenModelViaMocks, IterateOverAcceptedCommands) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // invalid paths should return in "no more data" ASSERT_FALSE(model.FirstAcceptedCommand(ConcreteClusterPath(kEndpointIdThatIsMissing, MockClusterId(1))).path.HasValidIds()); @@ -1200,7 +1200,7 @@ TEST(TestCodegenModelViaMocks, IterateOverAcceptedCommands) TEST(TestCodegenModelViaMocks, AcceptedCommandInfo) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // invalid paths should return in "no more data" ASSERT_FALSE(model.GetAcceptedCommandInfo(ConcreteCommandPath(kEndpointIdThatIsMissing, MockClusterId(1), 1)).has_value()); @@ -1232,7 +1232,7 @@ TEST(TestCodegenModelViaMocks, AcceptedCommandInfo) TEST(TestCodegenModelViaMocks, IterateOverGeneratedCommands) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; // invalid paths should return in "no more data" ASSERT_FALSE(model.FirstGeneratedCommand(ConcreteClusterPath(kEndpointIdThatIsMissing, MockClusterId(1))).HasValidIds()); @@ -1291,7 +1291,7 @@ TEST(TestCodegenModelViaMocks, IterateOverGeneratedCommands) TEST(TestCodegenModelViaMocks, EmberAttributeReadAclDeny) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kDenySubjectDescriptor, @@ -1304,7 +1304,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadAclDeny) TEST(TestCodegenModelViaMocks, ReadForInvalidGlobalAttributePath) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; { @@ -1325,7 +1325,7 @@ TEST(TestCodegenModelViaMocks, ReadForInvalidGlobalAttributePath) TEST(TestCodegenModelViaMocks, EmberAttributeInvalidRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; // Invalid attribute @@ -1359,7 +1359,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeInvalidRead) TEST(TestCodegenModelViaMocks, EmberAttributePathExpansionAccessDeniedRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kDenySubjectDescriptor, @@ -1377,7 +1377,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributePathExpansionAccessDeniedRead) TEST(TestCodegenModelViaMocks, AccessInterfaceUnsupportedRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kTestPath(kMockEndpoint3, MockClusterId(4), @@ -1481,7 +1481,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadNulls) TEST(TestCodegenModelViaMocks, EmberAttributeReadErrorReading) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; { @@ -1517,7 +1517,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadErrorReading) TEST(TestCodegenModelViaMocks, EmberAttributeReadNullOctetString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kAdminSubjectDescriptor, @@ -1552,7 +1552,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadNullOctetString) TEST(TestCodegenModelViaMocks, EmberAttributeReadOctetString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest( @@ -1591,7 +1591,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadOctetString) TEST(TestCodegenModelViaMocks, EmberAttributeReadLongOctetString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kAdminSubjectDescriptor, @@ -1628,7 +1628,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadLongOctetString) TEST(TestCodegenModelViaMocks, EmberAttributeReadShortString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kAdminSubjectDescriptor, @@ -1664,7 +1664,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadShortString) TEST(TestCodegenModelViaMocks, EmberAttributeReadLongString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest( @@ -1701,7 +1701,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadLongString) TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceStructRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -1744,7 +1744,7 @@ TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceStructRead) TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceReadError) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -1759,7 +1759,7 @@ TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceReadError) TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -1811,7 +1811,7 @@ TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListRead) TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListOverflowRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -1870,7 +1870,7 @@ TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListOverflowRead) TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListIncrementalRead) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -1932,7 +1932,7 @@ TEST(TestCodegenModelViaMocks, AttributeAccessInterfaceListIncrementalRead) TEST(TestCodegenModelViaMocks, ReadGlobalAttributeAttributeList) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestReadRequest testRequest(kAdminSubjectDescriptor, @@ -1988,7 +1988,7 @@ TEST(TestCodegenModelViaMocks, ReadGlobalAttributeAttributeList) TEST(TestCodegenModelViaMocks, EmberAttributeWriteAclDeny) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kDenySubjectDescriptor, ConcreteDataAttributePath(kMockEndpoint1, MockClusterId(1), MockAttributeId(10))); @@ -2053,7 +2053,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteInvalidValueToNullable) TEST(TestCodegenModelViaMocks, EmberTestWriteReservedNullPlaceholderToNullable) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test( @@ -2071,7 +2071,7 @@ TEST(TestCodegenModelViaMocks, EmberTestWriteReservedNullPlaceholderToNullable) TEST(TestCodegenModelViaMocks, EmberTestWriteOutOfRepresentableRangeOddIntegerNonNullable) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2090,7 +2090,7 @@ TEST(TestCodegenModelViaMocks, EmberTestWriteOutOfRepresentableRangeOddIntegerNo TEST(TestCodegenModelViaMocks, EmberTestWriteOutOfRepresentableRangeOddIntegerNullable) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test( @@ -2145,7 +2145,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteNulls) TEST(TestCodegenModelViaMocks, EmberAttributeWriteShortString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2162,7 +2162,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteShortString) TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongStringOutOfBounds) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2179,7 +2179,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongStringOutOfBounds) TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongString) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2200,7 +2200,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongString) TEST(TestCodegenModelViaMocks, EmberAttributeWriteNullableLongStringValue) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2222,7 +2222,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteNullableLongStringValue) TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongNullableStringNull) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2240,7 +2240,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongNullableStringNull) TEST(TestCodegenModelViaMocks, EmberAttributeWriteShortBytes) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2262,7 +2262,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteShortBytes) TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongBytes) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2286,7 +2286,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteLongBytes) TEST(TestCodegenModelViaMocks, EmberAttributeWriteTimedWrite) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, ConcreteAttributePath(kMockEndpoint3, MockClusterId(4), kAttributeIdTimedWrite)); @@ -2302,7 +2302,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteTimedWrite) TEST(TestCodegenModelViaMocks, EmberAttributeWriteReadOnlyAttribute) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, ConcreteAttributePath(kMockEndpoint3, MockClusterId(4), kAttributeIdReadOnly)); @@ -2318,7 +2318,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteReadOnlyAttribute) TEST(TestCodegenModelViaMocks, EmberAttributeWriteDataVersion) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2345,7 +2345,7 @@ TEST(TestCodegenModelViaMocks, EmberAttributeWriteDataVersion) TEST(TestCodegenModelViaMocks, WriteToInvalidPath) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; { @@ -2369,7 +2369,7 @@ TEST(TestCodegenModelViaMocks, WriteToInvalidPath) TEST(TestCodegenModelViaMocks, WriteToGlobalAttribute) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, ConcreteAttributePath(kMockEndpoint1, MockClusterId(1), AttributeList::Id)); @@ -2380,7 +2380,7 @@ TEST(TestCodegenModelViaMocks, WriteToGlobalAttribute) TEST(TestCodegenModelViaMocks, EmberWriteFailure) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; TestWriteRequest test(kAdminSubjectDescriptor, @@ -2404,7 +2404,7 @@ TEST(TestCodegenModelViaMocks, EmberWriteFailure) TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceTest) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -2447,7 +2447,7 @@ TEST(TestCodegenModelViaMocks, EmberInvokeTest) // is actually invoked. UseMockNodeConfig config(gTestNodeConfig); - chip::app::CodegenDataModel model; + chip::app::CodegenDataModelProvider model; { const ConcreteCommandPath kCommandPath(kMockEndpoint1, MockClusterId(1), kMockCommandId1); @@ -2481,7 +2481,7 @@ TEST(TestCodegenModelViaMocks, EmberInvokeTest) TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceReturningError) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), @@ -2505,7 +2505,7 @@ TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceReturningError) TEST(TestCodegenModelViaMocks, EmberWriteInvalidDataType) { UseMockNodeConfig config(gTestNodeConfig); - CodegenDataModelWithContext model; + CodegenDataModelProviderWithContext model; ScopedMockAccessControl accessControl; const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4), diff --git a/src/app/data-model-interface/ActionContext.h b/src/app/data-model-provider/ActionContext.h similarity index 95% rename from src/app/data-model-interface/ActionContext.h rename to src/app/data-model-provider/ActionContext.h index bfc2555870c780..71c9c5e7710877 100644 --- a/src/app/data-model-interface/ActionContext.h +++ b/src/app/data-model-provider/ActionContext.h @@ -20,7 +20,7 @@ namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { // Context for a currently executing action class ActionContext @@ -38,6 +38,6 @@ class ActionContext virtual Messaging::ExchangeContext * CurrentExchange() = 0; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/BUILD.gn b/src/app/data-model-provider/BUILD.gn similarity index 93% rename from src/app/data-model-interface/BUILD.gn rename to src/app/data-model-provider/BUILD.gn index abe66a68f342bd..5093cce2f4124d 100644 --- a/src/app/data-model-interface/BUILD.gn +++ b/src/app/data-model-provider/BUILD.gn @@ -13,16 +13,16 @@ # limitations under the License. import("//build_overrides/chip.gni") -source_set("data-model-interface") { +source_set("data-model-provider") { sources = [ "ActionContext.h", "Context.h", - "DataModel.h", - "DataModelChangeListener.h", "EventsGenerator.h", "MetadataTypes.cpp", "MetadataTypes.h", "OperationTypes.h", + "Provider.h", + "ProviderChangeListener.h", ] public_deps = [ diff --git a/src/app/data-model-interface/Context.h b/src/app/data-model-provider/Context.h similarity index 80% rename from src/app/data-model-interface/Context.h rename to src/app/data-model-provider/Context.h index 1ccfd1eb6586b7..e5dc725f713b0a 100644 --- a/src/app/data-model-interface/Context.h +++ b/src/app/data-model-provider/Context.h @@ -16,13 +16,13 @@ */ #pragma once -#include -#include -#include +#include +#include +#include namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { /// Data provided to data models in order to interface with the interaction model environment. /// @@ -32,10 +32,10 @@ namespace InteractionModel { struct InteractionModelContext { EventsGenerator * eventsGenerator; - DataModelChangeListener * dataModelChangeListener; + ProviderChangeListener * dataModelChangeListener; ActionContext * actionContext; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/EventsGenerator.h b/src/app/data-model-provider/EventsGenerator.h similarity index 98% rename from src/app/data-model-interface/EventsGenerator.h rename to src/app/data-model-provider/EventsGenerator.h index b37d5107ca76c4..94b15bfa07d4a1 100644 --- a/src/app/data-model-interface/EventsGenerator.h +++ b/src/app/data-model-provider/EventsGenerator.h @@ -29,7 +29,7 @@ namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { namespace internal { template @@ -131,6 +131,6 @@ class EventsGenerator } }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/MetadataTypes.cpp b/src/app/data-model-provider/MetadataTypes.cpp similarity index 92% rename from src/app/data-model-interface/MetadataTypes.cpp rename to src/app/data-model-provider/MetadataTypes.cpp index 92104b9bf90115..3ff238d7436a94 100644 --- a/src/app/data-model-interface/MetadataTypes.cpp +++ b/src/app/data-model-provider/MetadataTypes.cpp @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { const AttributeEntry AttributeEntry::kInvalid{ .path = ConcreteAttributePath(kInvalidEndpointId, kInvalidClusterId, kInvalidAttributeId) }; @@ -30,6 +30,6 @@ const ClusterEntry ClusterEntry::kInvalid{ .info = ClusterInfo(0 /* version */), // version of invalid cluster entry does not matter }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/MetadataTypes.h b/src/app/data-model-provider/MetadataTypes.h similarity index 97% rename from src/app/data-model-interface/MetadataTypes.h rename to src/app/data-model-provider/MetadataTypes.h index 5b3c62f0be2247..5e46d63b967e81 100644 --- a/src/app/data-model-interface/MetadataTypes.h +++ b/src/app/data-model-provider/MetadataTypes.h @@ -28,7 +28,7 @@ namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { enum class ClusterQualityFlags : uint32_t { @@ -121,10 +121,10 @@ struct CommandEntry /// are returned, when iterating over a cluster, all attributes/commands are iterated over) /// - uniqueness and completeness (iterate over all possible distinct values as long as no /// internal structural changes occur) -class DataModelMetadataTree +class ProviderMetadataTree { public: - virtual ~DataModelMetadataTree() = default; + virtual ~ProviderMetadataTree() = default; virtual EndpointId FirstEndpoint() = 0; virtual EndpointId NextEndpoint(EndpointId before) = 0; @@ -150,6 +150,6 @@ class DataModelMetadataTree virtual ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) = 0; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/OperationTypes.h b/src/app/data-model-provider/OperationTypes.h similarity index 98% rename from src/app/data-model-interface/OperationTypes.h rename to src/app/data-model-provider/OperationTypes.h index c9e5ae642158b3..00ec0424763cf5 100644 --- a/src/app/data-model-interface/OperationTypes.h +++ b/src/app/data-model-provider/OperationTypes.h @@ -26,7 +26,7 @@ namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { /// Contains common flags among all interaction model operations: read/write/invoke enum class OperationFlags : uint32_t @@ -92,6 +92,6 @@ struct InvokeRequest : OperationRequest BitFlags invokeFlags; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/DataModel.h b/src/app/data-model-provider/Provider.h similarity index 94% rename from src/app/data-model-interface/DataModel.h rename to src/app/data-model-provider/Provider.h index bcf24c1aa9e7b2..f5d550c806fd89 100644 --- a/src/app/data-model-interface/DataModel.h +++ b/src/app/data-model-provider/Provider.h @@ -23,13 +23,13 @@ #include #include -#include -#include -#include +#include +#include +#include namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { /// Represents operations against a matter-defined data model. /// @@ -38,10 +38,10 @@ namespace InteractionModel { /// thread or equivalent /// - class is allowed to attempt to cache indexes/locations for faster /// lookups of things (e.g during iterations) -class DataModel : public DataModelMetadataTree +class Provider : public ProviderMetadataTree { public: - virtual ~DataModel() = default; + virtual ~Provider() = default; // `context` pointers will be guaranteed valid until Shutdown is called() virtual CHIP_ERROR Startup(InteractionModelContext context) @@ -107,6 +107,6 @@ class DataModel : public DataModelMetadataTree InteractionModelContext mContext = { nullptr }; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/DataModelChangeListener.h b/src/app/data-model-provider/ProviderChangeListener.h similarity index 90% rename from src/app/data-model-interface/DataModelChangeListener.h rename to src/app/data-model-provider/ProviderChangeListener.h index a5ba12684baffe..97061865921b0f 100644 --- a/src/app/data-model-interface/DataModelChangeListener.h +++ b/src/app/data-model-provider/ProviderChangeListener.h @@ -20,7 +20,7 @@ namespace chip { namespace app { -namespace InteractionModel { +namespace DataModel { /// Notification listener for changes of the underlying data in a /// data model. @@ -31,10 +31,10 @@ namespace InteractionModel { /// Methods on this class MUST be called from within the matter /// main loop as they will likely trigger interaction model /// internal updates and subscription data reporting. -class DataModelChangeListener +class ProviderChangeListener { public: - virtual ~DataModelChangeListener() = default; + virtual ~ProviderChangeListener() = default; /// Mark all attributes matching the given path (which may be a wildcard) dirty. /// @@ -42,6 +42,6 @@ class DataModelChangeListener virtual void MarkDirty(const ConcreteAttributePath & path) = 0; }; -} // namespace InteractionModel +} // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model-interface/tests/BUILD.gn b/src/app/data-model-provider/tests/BUILD.gn similarity index 94% rename from src/app/data-model-interface/tests/BUILD.gn rename to src/app/data-model-provider/tests/BUILD.gn index 94faf695f687af..23107b9b5b1fd8 100644 --- a/src/app/data-model-interface/tests/BUILD.gn +++ b/src/app/data-model-provider/tests/BUILD.gn @@ -22,7 +22,7 @@ chip_test_suite("tests") { cflags = [ "-Wconversion" ] public_deps = [ - "${chip_root}/src/app/data-model-interface", + "${chip_root}/src/app/data-model-provider", "${chip_root}/src/lib/core:string-builder-adapters", ] } diff --git a/src/app/data-model-interface/tests/TestEventEmitting.cpp b/src/app/data-model-provider/tests/TestEventEmitting.cpp similarity index 98% rename from src/app/data-model-interface/tests/TestEventEmitting.cpp rename to src/app/data-model-provider/tests/TestEventEmitting.cpp index fe4e37e57b7dd0..36dd28312cc73c 100644 --- a/src/app/data-model-interface/tests/TestEventEmitting.cpp +++ b/src/app/data-model-provider/tests/TestEventEmitting.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include @@ -28,7 +28,7 @@ namespace { using namespace chip; using namespace chip::app; -using namespace chip::app::InteractionModel; +using namespace chip::app::DataModel; using StartUpEventType = chip::app::Clusters::BasicInformation::Events::StartUp::Type; using AccessControlEntryChangedType = chip::app::Clusters::AccessControl::Events::AccessControlEntryChanged::Type; diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index 50e23498aeeadb..faf76e031e177e 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -182,7 +182,7 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu ConcreteReadAttributePath pathForRetrieval(readPath); // Load the saved state from previous encoding session for chunking of one single attribute (list chunking). AttributeEncodeState encodeState = apReadHandler->GetAttributeEncodeState(); - err = Impl::RetrieveClusterData(mpImEngine->GetDataModel(), apReadHandler->GetSubjectDescriptor(), + err = Impl::RetrieveClusterData(mpImEngine->GetDataModelProvider(), apReadHandler->GetSubjectDescriptor(), apReadHandler->IsFabricFiltered(), attributeReportIBs, pathForRetrieval, &encodeState); if (err != CHIP_NO_ERROR) { diff --git a/src/app/reporting/Read-Checked.cpp b/src/app/reporting/Read-Checked.cpp index 76a6d1378eb653..3b434d5da5f624 100644 --- a/src/app/reporting/Read-Checked.cpp +++ b/src/app/reporting/Read-Checked.cpp @@ -50,7 +50,7 @@ class ScopedAttributeReportIBsBuilderState } // namespace -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState) { diff --git a/src/app/reporting/Read-Checked.h b/src/app/reporting/Read-Checked.h index 6df9715fcc3da9..2652d4f98c86d7 100644 --- a/src/app/reporting/Read-Checked.h +++ b/src/app/reporting/Read-Checked.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace chip { @@ -27,7 +27,7 @@ namespace app { namespace reporting { namespace CheckedImpl { -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState); diff --git a/src/app/reporting/Read-DataModel.cpp b/src/app/reporting/Read-DataModel.cpp index c004853cdaa495..9364d5c5fde9ce 100644 --- a/src/app/reporting/Read-DataModel.cpp +++ b/src/app/reporting/Read-DataModel.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include namespace chip { @@ -33,7 +33,7 @@ bool IsOutOfSpaceError(CHIP_ERROR err) } // namespace -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState) { @@ -45,17 +45,17 @@ CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Ac DataModelCallbacks::OperationOrder::Pre, path); #endif // !CHIP_CONFIG_USE_EMBER_DATA_MODEL - InteractionModel::ReadAttributeRequest readRequest; + DataModel::ReadAttributeRequest readRequest; if (isFabricFiltered) { - readRequest.readFlags.Set(InteractionModel::ReadFlags::kFabricFiltered); + readRequest.readFlags.Set(DataModel::ReadFlags::kFabricFiltered); } readRequest.subjectDescriptor = subjectDescriptor; readRequest.path = path; DataVersion version = 0; - if (std::optional clusterInfo = dataModel->GetClusterInfo(path); clusterInfo.has_value()) + if (std::optional clusterInfo = dataModel->GetClusterInfo(path); clusterInfo.has_value()) { version = clusterInfo->dataVersion; } diff --git a/src/app/reporting/Read-DataModel.h b/src/app/reporting/Read-DataModel.h index 231429c4a2e242..346ebb2340f6d7 100644 --- a/src/app/reporting/Read-DataModel.h +++ b/src/app/reporting/Read-DataModel.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace chip { @@ -27,7 +27,7 @@ namespace app { namespace reporting { namespace DataModelImpl { -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState); diff --git a/src/app/reporting/Read-Ember.cpp b/src/app/reporting/Read-Ember.cpp index 290c4e627ac7bb..3e9ad543a6e2b4 100644 --- a/src/app/reporting/Read-Ember.cpp +++ b/src/app/reporting/Read-Ember.cpp @@ -25,7 +25,7 @@ namespace app { namespace reporting { namespace EmberImpl { -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState) { diff --git a/src/app/reporting/Read-Ember.h b/src/app/reporting/Read-Ember.h index 0181734d205053..5ff3fff4103dc5 100644 --- a/src/app/reporting/Read-Ember.h +++ b/src/app/reporting/Read-Ember.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace chip { @@ -27,7 +27,7 @@ namespace app { namespace reporting { namespace EmberImpl { -CHIP_ERROR RetrieveClusterData(InteractionModel::DataModel * dataModel, const Access::SubjectDescriptor & subjectDescriptor, +CHIP_ERROR RetrieveClusterData(DataModel::Provider * dataModel, const Access::SubjectDescriptor & subjectDescriptor, bool isFabricFiltered, AttributeReportIBs::Builder & reportBuilder, const ConcreteReadAttributePath & path, AttributeEncodeState * encoderState); diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index e600fbeb3f1987..681f16aedc1e6c 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -229,7 +229,7 @@ chip_test_suite("tests") { ":thread-network-directory-test-srcs", ":time-sync-data-provider-test-srcs", "${chip_root}/src/app", - "${chip_root}/src/app/codegen-data-model:instance-header", + "${chip_root}/src/app/codegen-data-model-provider:instance-header", "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/icd/client:manager", "${chip_root}/src/app/tests:helpers", diff --git a/src/app/tests/TestAclAttribute.cpp b/src/app/tests/TestAclAttribute.cpp index c11adde08d6208..264137dbfbdd8b 100644 --- a/src/app/tests/TestAclAttribute.cpp +++ b/src/app/tests/TestAclAttribute.cpp @@ -118,17 +118,17 @@ class TestAclAttribute : public Test::AppContext Access::GetAccessControl().Finish(); Access::GetAccessControl().Init(GetTestAccessControlDelegate(), gDeviceTypeResolver); - mOldModel = InteractionModelEngine::GetInstance()->SetDataModel(&TestImCustomDataModel::Instance()); + mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&TestImCustomDataModel::Instance()); } void TearDown() override { AppContext::TearDown(); - InteractionModelEngine::GetInstance()->SetDataModel(mOldModel); + InteractionModelEngine::GetInstance()->SetDataModelProvider(mOldProvider); } private: - chip::app::InteractionModel::DataModel * mOldModel = nullptr; + chip::app::DataModel::Provider * mOldProvider = nullptr; }; // Read Client sends a malformed subscribe request, interaction model engine fails to parse the request and generates a status diff --git a/src/app/tests/TestAttributePathExpandIterator.cpp b/src/app/tests/TestAttributePathExpandIterator.cpp index 236203098c8fb8..d27c2780f2ec17 100644 --- a/src/app/tests/TestAttributePathExpandIterator.cpp +++ b/src/app/tests/TestAttributePathExpandIterator.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -133,7 +133,7 @@ TEST(TestAttributePathExpandIterator, TestAllWildcard) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -157,7 +157,7 @@ TEST(TestAttributePathExpandIterator, TestWildcardEndpoint) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -184,7 +184,7 @@ TEST(TestAttributePathExpandIterator, TestWildcardCluster) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -211,7 +211,7 @@ TEST(TestAttributePathExpandIterator, TestWildcardClusterGlobalAttributeNotInMet size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -245,7 +245,7 @@ TEST(TestAttributePathExpandIterator, TestWildcardAttribute) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -270,7 +270,7 @@ TEST(TestAttributePathExpandIterator, TestNoWildcard) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); @@ -414,7 +414,7 @@ TEST(TestAttributePathExpandIterator, TestMultipleClusInfo) size_t index = 0; - for (app::AttributePathExpandIterator iter(CodegenDataModelInstance(), &clusInfo1); iter.Get(path); iter.Next()) + for (app::AttributePathExpandIterator iter(CodegenDataModelProviderInstance(), &clusInfo1); iter.Get(path); iter.Next()) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); diff --git a/src/app/tests/TestInteractionModelEngine.cpp b/src/app/tests/TestInteractionModelEngine.cpp index db79875b010f48..0a4a8bd5af6ef4 100644 --- a/src/app/tests/TestInteractionModelEngine.cpp +++ b/src/app/tests/TestInteractionModelEngine.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -267,7 +267,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create and setup readHandler 1 ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify that Bob still doesn't have an active subscription EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId)); @@ -313,7 +313,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create readHandler 1 engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify that Bob still doesn't have an active subscription EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId)); @@ -321,7 +321,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create and setup readHandler 2 ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify that Bob still doesn't have an active subscription EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId)); @@ -373,12 +373,12 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create and setup readHandler 1 ReadHandler * readHandler1 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx1, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Create and setup readHandler 2 ReadHandler * readHandler2 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx2, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify that Bob still doesn't have an active subscription EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId)); @@ -454,21 +454,21 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create and setup readHandler 1-1 engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx11, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Create and setup readHandler 1-2 ReadHandler * readHandler12 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx12, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Create and setup readHandler 2-1 engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx21, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Create and setup readHandler 2-2 ReadHandler * readHandler22 = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx22, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify that both Alice and Bob have no active subscriptions EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, bobNodeId)); @@ -540,7 +540,7 @@ TEST_F_FROM_FIXTURE(TestInteractionModelEngine, TestSubjectHasActiveSubscription // Create readHandler ReadHandler * readHandler = engine->GetReadHandlerPool().CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); // Verify there are not active subscriptions EXPECT_FALSE(engine->SubjectHasActiveSubscription(bobFabricIndex, valideSubjectId)); diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 5c712b7c0a9a4a..e984b3ee081d89 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -272,11 +272,11 @@ class TestReadInteraction : public chip::Test::AppContext ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); - mOldModel = InteractionModelEngine::GetInstance()->SetDataModel(&TestImCustomDataModel::Instance()); + mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&TestImCustomDataModel::Instance()); } void TearDown() { - InteractionModelEngine::GetInstance()->SetDataModel(mOldModel); + InteractionModelEngine::GetInstance()->SetDataModelProvider(mOldProvider); chip::app::EventManagement::DestroyEventManagement(); AppContext::TearDown(); } @@ -331,7 +331,7 @@ class TestReadInteraction : public chip::Test::AppContext protected: chip::MonotonicallyIncreasingCounter mEventCounter; static bool sSyncScheduler; - chip::app::InteractionModel::DataModel * mOldModel = nullptr; + chip::app::DataModel::Provider * mOldProvider = nullptr; }; bool TestReadInteraction::sSyncScheduler = false; @@ -474,7 +474,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestReadHandler) { Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false); ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); GenerateReportData(reportDatabuf, ReportType::kValid, false /* aSuppressResponse*/); EXPECT_EQ(readHandler.SendReportData(std::move(reportDatabuf), false), CHIP_ERROR_INCORRECT_STATE); @@ -630,7 +630,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestReadHandlerInvalidAttributePath) { Messaging::ExchangeContext * exchangeCtx = NewExchangeToAlice(nullptr, false); ReadHandler readHandler(nullCallback, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); GenerateReportData(reportDatabuf, ReportType::kValid, false /* aSuppressResponse*/); EXPECT_EQ(readHandler.SendReportData(std::move(reportDatabuf), false), CHIP_ERROR_INCORRECT_STATE); @@ -1356,7 +1356,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestProcessSubscribeRequest) { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); @@ -1416,7 +1416,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestICDProcessSubscribeRequestSupMaxInt { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); @@ -1483,7 +1483,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestICDProcessSubscribeRequestInfMaxInt { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); @@ -1550,7 +1550,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestICDProcessSubscribeRequestSupMinInt { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); @@ -1617,7 +1617,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestICDProcessSubscribeRequestMaxMinInt { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); @@ -1682,7 +1682,7 @@ TEST_F_FROM_FIXTURE(TestReadInteraction, TestICDProcessSubscribeRequestInvalidId { ReadHandler readHandler(*engine, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, gReportScheduler, - CodegenDataModelInstance()); + CodegenDataModelProviderInstance()); writer.Init(std::move(subscribeRequestbuf)); EXPECT_EQ(subscribeRequestBuilder.Init(&writer), CHIP_NO_ERROR); diff --git a/src/app/tests/TestReportScheduler.cpp b/src/app/tests/TestReportScheduler.cpp index f9ff58eac9e017..79ff67ec9bff25 100644 --- a/src/app/tests/TestReportScheduler.cpp +++ b/src/app/tests/TestReportScheduler.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include @@ -276,7 +276,7 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestReadHandlerList) for (size_t i = 0; i < kNumMaxReadHandlers; i++) { ReadHandler * readHandler = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &sScheduler, CodegenDataModelInstance()); + &sScheduler, CodegenDataModelProviderInstance()); sScheduler.OnSubscriptionEstablished(readHandler); ASSERT_NE(nullptr, readHandler); ASSERT_NE(nullptr, sScheduler.FindReadHandlerNode(readHandler)); @@ -340,19 +340,19 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestReportTiming) // Dirty read handler, will be triggered at min interval // Test OnReadHandler created ReadHandler * readHandler1 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &sScheduler, CodegenDataModelInstance()); + &sScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler1, &sScheduler, 1, 2)); readHandler1->ForceDirtyState(); // Clean read handler, will be triggered at max interval ReadHandler * readHandler2 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &sScheduler, CodegenDataModelInstance()); + &sScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler2, &sScheduler, 0, 3)); // Clean read handler, will be triggered at max interval, but will be cancelled before ReadHandler * readHandler3 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &sScheduler, CodegenDataModelInstance()); + &sScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler3, &sScheduler, 0, 3)); // Confirms that none of the ReadHandlers are currently reportable @@ -406,7 +406,7 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestObserverCallbacks) sTestTimerDelegate.SetMockSystemTimestamp(Milliseconds64(0)); ReadHandler * readHandler = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &sScheduler, CodegenDataModelInstance()); + &sScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler, &sScheduler, 1, 2)); @@ -482,13 +482,13 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestSynchronizedScheduler) sTestTimerSynchronizedDelegate.SetMockSystemTimestamp(System::Clock::Milliseconds64(0)); ReadHandler * readHandler1 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &syncScheduler, CodegenDataModelInstance()); + &syncScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler1, &syncScheduler, 0, 2)); ReadHandlerNode * node1 = syncScheduler.FindReadHandlerNode(readHandler1); ReadHandler * readHandler2 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &syncScheduler, CodegenDataModelInstance()); + &syncScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler2, &syncScheduler, 1, 3)); ReadHandlerNode * node2 = syncScheduler.FindReadHandlerNode(readHandler2); @@ -616,7 +616,7 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestSynchronizedScheduler) sTestTimerSynchronizedDelegate.IncrementMockTimestamp(System::Clock::Milliseconds64(1000)); ReadHandler * readHandler3 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &syncScheduler, CodegenDataModelInstance()); + &syncScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler3, &syncScheduler, 2, 3)); ReadHandlerNode * node3 = syncScheduler.FindReadHandlerNode(readHandler3); @@ -670,7 +670,7 @@ TEST_F_FROM_FIXTURE(TestReportScheduler, TestSynchronizedScheduler) // Now simulate a new readHandler being added with a max forcing a conflict ReadHandler * readHandler4 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, - &syncScheduler, CodegenDataModelInstance()); + &syncScheduler, CodegenDataModelProviderInstance()); EXPECT_EQ(CHIP_NO_ERROR, MockReadHandlerSubscriptionTransaction(readHandler4, &syncScheduler, 0, 1)); ReadHandlerNode * node4 = syncScheduler.FindReadHandlerNode(readHandler4); diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index c18fbdbf1f2dcc..f4f52b83f8bfa7 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -59,12 +59,12 @@ class TestReportingEngine : public chip::Test::AppContext void SetUp() override { chip::Test::AppContext::SetUp(); - mOldModel = InteractionModelEngine::GetInstance()->SetDataModel(&TestImCustomDataModel::Instance()); + mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&TestImCustomDataModel::Instance()); } void TearDown() override { - InteractionModelEngine::GetInstance()->SetDataModel(mOldModel); + InteractionModelEngine::GetInstance()->SetDataModelProvider(mOldProvider); chip::Test::AppContext::TearDown(); } @@ -77,7 +77,7 @@ class TestReportingEngine : public chip::Test::AppContext void TestMergeAttributePathWhenDirtySetPoolExhausted(); private: - chip::app::InteractionModel::DataModel * mOldModel = nullptr; + chip::app::DataModel::Provider * mOldProvider = nullptr; struct ExpectedDirtySetContent : public AttributePathParams { @@ -186,7 +186,7 @@ TEST_F_FROM_FIXTURE(TestReportingEngine, TestBuildAndSendSingleReportData) EXPECT_EQ(readRequestBuilder.GetError(), CHIP_NO_ERROR); EXPECT_EQ(writer.Finalize(&readRequestbuf), CHIP_NO_ERROR); app::ReadHandler readHandler(dummy, exchangeCtx, chip::app::ReadHandler::InteractionType::Read, - app::reporting::GetDefaultReportScheduler(), CodegenDataModelInstance()); + app::reporting::GetDefaultReportScheduler(), CodegenDataModelProviderInstance()); readHandler.OnInitialRequest(std::move(readRequestbuf)); EXPECT_EQ(InteractionModelEngine::GetInstance()->GetReportingEngine().BuildAndSendSingleReportData(&readHandler), diff --git a/src/app/tests/test-interaction-model-api.cpp b/src/app/tests/test-interaction-model-api.cpp index 444516a79ddf1a..f626d061c2b107 100644 --- a/src/app/tests/test-interaction-model-api.cpp +++ b/src/app/tests/test-interaction-model-api.cpp @@ -17,14 +17,14 @@ #include #include -#include +#include #include #include #include #include #include -using namespace chip::app::InteractionModel; +using namespace chip::app::DataModel; namespace chip { uint8_t Test::attributeDataTLV[CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE]; @@ -180,67 +180,67 @@ CHIP_ERROR TestImCustomDataModel::Invoke(const InvokeRequest & request, chip::TL EndpointId TestImCustomDataModel::FirstEndpoint() { - return CodegenDataModelInstance()->FirstEndpoint(); + return CodegenDataModelProviderInstance()->FirstEndpoint(); } EndpointId TestImCustomDataModel::NextEndpoint(EndpointId before) { - return CodegenDataModelInstance()->NextEndpoint(before); + return CodegenDataModelProviderInstance()->NextEndpoint(before); } ClusterEntry TestImCustomDataModel::FirstCluster(EndpointId endpoint) { - return CodegenDataModelInstance()->FirstCluster(endpoint); + return CodegenDataModelProviderInstance()->FirstCluster(endpoint); } ClusterEntry TestImCustomDataModel::NextCluster(const ConcreteClusterPath & before) { - return CodegenDataModelInstance()->NextCluster(before); + return CodegenDataModelProviderInstance()->NextCluster(before); } std::optional TestImCustomDataModel::GetClusterInfo(const ConcreteClusterPath & path) { - return CodegenDataModelInstance()->GetClusterInfo(path); + return CodegenDataModelProviderInstance()->GetClusterInfo(path); } AttributeEntry TestImCustomDataModel::FirstAttribute(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstAttribute(cluster); + return CodegenDataModelProviderInstance()->FirstAttribute(cluster); } AttributeEntry TestImCustomDataModel::NextAttribute(const ConcreteAttributePath & before) { - return CodegenDataModelInstance()->NextAttribute(before); + return CodegenDataModelProviderInstance()->NextAttribute(before); } std::optional TestImCustomDataModel::GetAttributeInfo(const ConcreteAttributePath & path) { - return CodegenDataModelInstance()->GetAttributeInfo(path); + return CodegenDataModelProviderInstance()->GetAttributeInfo(path); } CommandEntry TestImCustomDataModel::FirstAcceptedCommand(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstAcceptedCommand(cluster); + return CodegenDataModelProviderInstance()->FirstAcceptedCommand(cluster); } CommandEntry TestImCustomDataModel::NextAcceptedCommand(const ConcreteCommandPath & before) { - return CodegenDataModelInstance()->NextAcceptedCommand(before); + return CodegenDataModelProviderInstance()->NextAcceptedCommand(before); } std::optional TestImCustomDataModel::GetAcceptedCommandInfo(const ConcreteCommandPath & path) { - return CodegenDataModelInstance()->GetAcceptedCommandInfo(path); + return CodegenDataModelProviderInstance()->GetAcceptedCommandInfo(path); } ConcreteCommandPath TestImCustomDataModel::FirstGeneratedCommand(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstGeneratedCommand(cluster); + return CodegenDataModelProviderInstance()->FirstGeneratedCommand(cluster); } ConcreteCommandPath TestImCustomDataModel::NextGeneratedCommand(const ConcreteCommandPath & before) { - return CodegenDataModelInstance()->NextGeneratedCommand(before); + return CodegenDataModelProviderInstance()->NextGeneratedCommand(before); } } // namespace app diff --git a/src/app/tests/test-interaction-model-api.h b/src/app/tests/test-interaction-model-api.h index e88fee62ec1d23..ccaf6514890546 100644 --- a/src/app/tests/test-interaction-model-api.h +++ b/src/app/tests/test-interaction-model-api.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -111,29 +111,29 @@ bool IsDeviceTypeOnEndpoint(DeviceTypeId deviceType, EndpointId endpoint); /// TODO items for above: /// - once IM only supports DataModel /// - break ember-overrides in this h/cpp file -class TestImCustomDataModel : public InteractionModel::DataModel +class TestImCustomDataModel : public DataModel::Provider { public: static TestImCustomDataModel & Instance(); CHIP_ERROR Shutdown() override { return CHIP_NO_ERROR; } - CHIP_ERROR ReadAttribute(const InteractionModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; - CHIP_ERROR WriteAttribute(const InteractionModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; - CHIP_ERROR Invoke(const InteractionModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, + CHIP_ERROR ReadAttribute(const DataModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; + CHIP_ERROR WriteAttribute(const DataModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; + CHIP_ERROR Invoke(const DataModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, CommandHandler * handler) override; EndpointId FirstEndpoint() override; EndpointId NextEndpoint(EndpointId before) override; - InteractionModel::ClusterEntry FirstCluster(EndpointId endpoint) override; - InteractionModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; - std::optional GetClusterInfo(const ConcreteClusterPath & path) override; - InteractionModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; - InteractionModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; - std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; - InteractionModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; - InteractionModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; - std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; + DataModel::ClusterEntry FirstCluster(EndpointId endpoint) override; + DataModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; + std::optional GetClusterInfo(const ConcreteClusterPath & path) override; + DataModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; + DataModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; + std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; + DataModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; + DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; + std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override; ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override; }; diff --git a/src/app/util/mock/BUILD.gn b/src/app/util/mock/BUILD.gn index fa57cf4e9e71e9..db566aad578793 100644 --- a/src/app/util/mock/BUILD.gn +++ b/src/app/util/mock/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/src/app/codegen-data-model/model.gni") +import("${chip_root}/src/app/codegen-data-model-provider/model.gni") config("mock_include") { include_dirs = [ "include" ] diff --git a/src/controller/tests/data_model/BUILD.gn b/src/controller/tests/data_model/BUILD.gn index 692696d3be2548..9bf2eac9391bac 100644 --- a/src/controller/tests/data_model/BUILD.gn +++ b/src/controller/tests/data_model/BUILD.gn @@ -41,7 +41,7 @@ chip_test_suite("data_model") { public_deps = [ "${chip_root}/src/app", "${chip_root}/src/app/common:cluster-objects", - "${chip_root}/src/app/data-model-interface", + "${chip_root}/src/app/data-model-provider", "${chip_root}/src/app/tests:helpers", "${chip_root}/src/app/util/mock:mock_codegen_data_model", "${chip_root}/src/app/util/mock:mock_ember", diff --git a/src/controller/tests/data_model/DataModelFixtures.cpp b/src/controller/tests/data_model/DataModelFixtures.cpp index eb043acd04353d..ff22f2063e6e62 100644 --- a/src/controller/tests/data_model/DataModelFixtures.cpp +++ b/src/controller/tests/data_model/DataModelFixtures.cpp @@ -23,12 +23,12 @@ #include #include #include -#include +#include using namespace chip; using namespace chip::app; using namespace chip::app::DataModelTests; -using namespace chip::app::InteractionModel; +using namespace chip::app::DataModel; using namespace chip::app::Clusters; using namespace chip::app::Clusters::UnitTesting; using namespace chip::Protocols; @@ -531,67 +531,67 @@ CHIP_ERROR CustomDataModel::Invoke(const InvokeRequest & request, chip::TLV::TLV EndpointId CustomDataModel::FirstEndpoint() { - return CodegenDataModelInstance()->FirstEndpoint(); + return CodegenDataModelProviderInstance()->FirstEndpoint(); } EndpointId CustomDataModel::NextEndpoint(EndpointId before) { - return CodegenDataModelInstance()->NextEndpoint(before); + return CodegenDataModelProviderInstance()->NextEndpoint(before); } ClusterEntry CustomDataModel::FirstCluster(EndpointId endpoint) { - return CodegenDataModelInstance()->FirstCluster(endpoint); + return CodegenDataModelProviderInstance()->FirstCluster(endpoint); } ClusterEntry CustomDataModel::NextCluster(const ConcreteClusterPath & before) { - return CodegenDataModelInstance()->NextCluster(before); + return CodegenDataModelProviderInstance()->NextCluster(before); } std::optional CustomDataModel::GetClusterInfo(const ConcreteClusterPath & path) { - return CodegenDataModelInstance()->GetClusterInfo(path); + return CodegenDataModelProviderInstance()->GetClusterInfo(path); } AttributeEntry CustomDataModel::FirstAttribute(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstAttribute(cluster); + return CodegenDataModelProviderInstance()->FirstAttribute(cluster); } AttributeEntry CustomDataModel::NextAttribute(const ConcreteAttributePath & before) { - return CodegenDataModelInstance()->NextAttribute(before); + return CodegenDataModelProviderInstance()->NextAttribute(before); } std::optional CustomDataModel::GetAttributeInfo(const ConcreteAttributePath & path) { - return CodegenDataModelInstance()->GetAttributeInfo(path); + return CodegenDataModelProviderInstance()->GetAttributeInfo(path); } CommandEntry CustomDataModel::FirstAcceptedCommand(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstAcceptedCommand(cluster); + return CodegenDataModelProviderInstance()->FirstAcceptedCommand(cluster); } CommandEntry CustomDataModel::NextAcceptedCommand(const ConcreteCommandPath & before) { - return CodegenDataModelInstance()->NextAcceptedCommand(before); + return CodegenDataModelProviderInstance()->NextAcceptedCommand(before); } std::optional CustomDataModel::GetAcceptedCommandInfo(const ConcreteCommandPath & path) { - return CodegenDataModelInstance()->GetAcceptedCommandInfo(path); + return CodegenDataModelProviderInstance()->GetAcceptedCommandInfo(path); } ConcreteCommandPath CustomDataModel::FirstGeneratedCommand(const ConcreteClusterPath & cluster) { - return CodegenDataModelInstance()->FirstGeneratedCommand(cluster); + return CodegenDataModelProviderInstance()->FirstGeneratedCommand(cluster); } ConcreteCommandPath CustomDataModel::NextGeneratedCommand(const ConcreteCommandPath & before) { - return CodegenDataModelInstance()->NextGeneratedCommand(before); + return CodegenDataModelProviderInstance()->NextGeneratedCommand(before); } } // namespace app diff --git a/src/controller/tests/data_model/DataModelFixtures.h b/src/controller/tests/data_model/DataModelFixtures.h index 405b4ff4d4e7d8..a36e905c23ce41 100644 --- a/src/controller/tests/data_model/DataModelFixtures.h +++ b/src/controller/tests/data_model/DataModelFixtures.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include @@ -108,29 +108,29 @@ extern CommandHandler::Handle gAsyncCommandHandle; /// TODO items for above: /// - once IM only supports DataModel /// - break ember-overrides in this h/cpp file -class CustomDataModel : public InteractionModel::DataModel +class CustomDataModel : public DataModel::Provider { public: static CustomDataModel & Instance(); CHIP_ERROR Shutdown() override { return CHIP_NO_ERROR; } - CHIP_ERROR ReadAttribute(const InteractionModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; - CHIP_ERROR WriteAttribute(const InteractionModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; - CHIP_ERROR Invoke(const InteractionModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, + CHIP_ERROR ReadAttribute(const DataModel::ReadAttributeRequest & request, AttributeValueEncoder & encoder) override; + CHIP_ERROR WriteAttribute(const DataModel::WriteAttributeRequest & request, AttributeValueDecoder & decoder) override; + CHIP_ERROR Invoke(const DataModel::InvokeRequest & request, chip::TLV::TLVReader & input_arguments, CommandHandler * handler) override; EndpointId FirstEndpoint() override; EndpointId NextEndpoint(EndpointId before) override; - InteractionModel::ClusterEntry FirstCluster(EndpointId endpoint) override; - InteractionModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; - std::optional GetClusterInfo(const ConcreteClusterPath & path) override; - InteractionModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; - InteractionModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; - std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; - InteractionModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; - InteractionModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; - std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; + DataModel::ClusterEntry FirstCluster(EndpointId endpoint) override; + DataModel::ClusterEntry NextCluster(const ConcreteClusterPath & before) override; + std::optional GetClusterInfo(const ConcreteClusterPath & path) override; + DataModel::AttributeEntry FirstAttribute(const ConcreteClusterPath & cluster) override; + DataModel::AttributeEntry NextAttribute(const ConcreteAttributePath & before) override; + std::optional GetAttributeInfo(const ConcreteAttributePath & path) override; + DataModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override; + DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override; + std::optional GetAcceptedCommandInfo(const ConcreteCommandPath & path) override; ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override; ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override; }; diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index 1281d9190c56bc..c2c2e63689f932 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -56,13 +56,13 @@ class TestRead : public chip::Test::AppContext, public app::ReadHandler::Applica void SetUp() override { chip::Test::AppContext::SetUp(); - mOldModel = InteractionModelEngine::GetInstance()->SetDataModel(&CustomDataModel::Instance()); + mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&CustomDataModel::Instance()); } // Performs teardown for each individual test in the test suite void TearDown() override { - InteractionModelEngine::GetInstance()->SetDataModel(mOldModel); + InteractionModelEngine::GetInstance()->SetDataModelProvider(mOldProvider); chip::Test::AppContext::TearDown(); } @@ -97,10 +97,10 @@ class TestRead : public chip::Test::AppContext, public app::ReadHandler::Applica // max-interval to time out. static System::Clock::Timeout ComputeSubscriptionTimeout(System::Clock::Seconds16 aMaxInterval); - bool mEmitSubscriptionError = false; - int32_t mNumActiveSubscriptions = 0; - bool mAlterSubscriptionIntervals = false; - chip::app::InteractionModel::DataModel * mOldModel = nullptr; + bool mEmitSubscriptionError = false; + int32_t mNumActiveSubscriptions = 0; + bool mAlterSubscriptionIntervals = false; + chip::app::DataModel::Provider * mOldProvider = nullptr; }; uint16_t TestRead::mMaxInterval = 66;