Skip to content

Commit

Permalink
API renames: chip::app::InteractionModel::* becomes `chip::app::Dat…
Browse files Browse the repository at this point in the history
…aModel` 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 <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Sep 11, 2024
1 parent 66b6ff0 commit 3608298
Show file tree
Hide file tree
Showing 68 changed files with 407 additions and 412 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down
6 changes: 3 additions & 3 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
]
Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathExpandIterator-Checked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace chip {
namespace app {
AttributePathExpandIteratorChecked::AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel,
AttributePathExpandIteratorChecked::AttributePathExpandIteratorChecked(DataModel::Provider * dataModel,
SingleLinkedListNode<AttributePathParams> * attributePath) :
mDataModelIterator(dataModel, attributePath),
mEmberIterator(dataModel, attributePath)
Expand Down
3 changes: 1 addition & 2 deletions src/app/AttributePathExpandIterator-Checked.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace app {
class AttributePathExpandIteratorChecked
{
public:
AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel,
SingleLinkedListNode<AttributePathParams> * attributePath);
AttributePathExpandIteratorChecked(DataModel::Provider * dataModel, SingleLinkedListNode<AttributePathParams> * attributePath);

bool Next();
bool Get(ConcreteAttributePath & aPath);
Expand Down
22 changes: 11 additions & 11 deletions src/app/AttributePathExpandIterator-DataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#include <app/AttributePathExpandIterator-DataModel.h>
#include <app/GlobalAttributes.h>

using namespace chip::app::InteractionModel;
using namespace chip::app::DataModel;

namespace chip {
namespace app {

AttributePathExpandIteratorDataModel::AttributePathExpandIteratorDataModel(
InteractionModel::DataModel * dataModel, SingleLinkedListNode<AttributePathParams> * attributePath) :
mDataModel(dataModel),
DataModel::Provider * provider, SingleLinkedListNode<AttributePathParams> * attributePath) :
mDataModelProvider(provider),
mpAttributePath(attributePath), mOutputPath(kInvalidEndpointId, kInvalidClusterId, kInvalidAttributeId)

{
Expand All @@ -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<AttributeId> AttributePathExpandIteratorDataModel::NextAttributeId()
Expand All @@ -61,7 +61,7 @@ std::optional<AttributeId> 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; //
Expand Down Expand Up @@ -99,7 +99,7 @@ std::optional<AttributeId> AttributePathExpandIteratorDataModel::NextAttributeId
return std::nullopt;
}

AttributeEntry entry = mDataModel->NextAttribute(mOutputPath);
AttributeEntry entry = mDataModelProvider->NextAttribute(mOutputPath);
if (entry.IsValid())
{
return entry.path.mAttributeId;
Expand All @@ -117,13 +117,13 @@ std::optional<ClusterId> 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;
}
Expand All @@ -133,7 +133,7 @@ std::optional<ClusterId> 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;
}

Expand All @@ -143,7 +143,7 @@ std::optional<ClusterId> AttributePathExpandIteratorDataModel::NextEndpointId()
{
if (mpAttributePath->mValue.HasWildcardEndpointId())
{
EndpointId id = mDataModel->FirstEndpoint();
EndpointId id = mDataModelProvider->FirstEndpoint();
return (id != kInvalidEndpointId) ? std::make_optional(id) : std::nullopt;
}

Expand All @@ -152,7 +152,7 @@ std::optional<ClusterId> 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;
}

Expand Down
9 changes: 4 additions & 5 deletions src/app/AttributePathExpandIterator-DataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <app/AttributePathParams.h>
#include <app/ConcreteAttributePath.h>
#include <app/data-model-interface/DataModel.h>
#include <app/data-model-provider/Provider.h>
#include <lib/support/LinkedList.h>

namespace chip {
Expand Down Expand Up @@ -53,8 +53,7 @@ namespace app {
class AttributePathExpandIteratorDataModel
{
public:
AttributePathExpandIteratorDataModel(InteractionModel::DataModel * dataModel,
SingleLinkedListNode<AttributePathParams> * attributePath);
AttributePathExpandIteratorDataModel(DataModel::Provider * provider, SingleLinkedListNode<AttributePathParams> * attributePath);

/**
* Proceed the iterator to the next attribute path in the given cluster info.
Expand Down Expand Up @@ -85,11 +84,11 @@ class AttributePathExpandIteratorDataModel
/** Start iterating over the given `paths` */
inline void ResetTo(SingleLinkedListNode<AttributePathParams> * paths)
{
*this = AttributePathExpandIteratorDataModel(mDataModel, paths);
*this = AttributePathExpandIteratorDataModel(mDataModelProvider, paths);
}

private:
InteractionModel::DataModel * mDataModel;
DataModel::Provider * mDataModelProvider;
SingleLinkedListNode<AttributePathParams> * mpAttributePath;
ConcreteAttributePath mOutputPath;

Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathExpandIterator-Ember.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern bool emberAfEndpointIndexIsEnabled(uint16_t index);
namespace chip {
namespace app {

AttributePathExpandIteratorEmber::AttributePathExpandIteratorEmber(InteractionModel::DataModel *,
AttributePathExpandIteratorEmber::AttributePathExpandIteratorEmber(DataModel::Provider *,
SingleLinkedListNode<AttributePathParams> * aAttributePath) :
mpAttributePath(aAttributePath)
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/AttributePathExpandIterator-Ember.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <app/AttributePathParams.h>
#include <app/ConcreteAttributePath.h>
#include <app/EventManagement.h>
#include <app/data-model-interface/DataModel.h>
#include <app/data-model-provider/Provider.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DLLUtil.h>
Expand Down Expand Up @@ -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<AttributePathParams> * aAttributePath);

/**
Expand Down
12 changes: 6 additions & 6 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <lib/support/FibonacciUtils.h>

#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
#include <app/codegen-data-model/Instance.h>
#include <app/codegen-data-model-provider/Instance.h>
#endif

namespace chip {
Expand Down Expand Up @@ -485,7 +485,7 @@ CHIP_ERROR InteractionModelEngine::ParseAttributePaths(const Access::SubjectDesc

if (paramsList.mValue.IsWildcardPath())
{
AttributePathExpandIterator pathIterator(GetDataModel(), &paramsList);
AttributePathExpandIterator pathIterator(GetDataModelProvider(), &paramsList);
ConcreteAttributePath readPath;

// The definition of "valid path" is "path exists and ACL allows access". The "path exists" part is handled by
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <app/TimedHandler.h>
#include <app/WriteClient.h>
#include <app/WriteHandler.h>
#include <app/data-model-interface/DataModel.h>
#include <app/data-model-provider/Provider.h>
#include <app/icd/server/ICDServerConfig.h>
#include <app/reporting/Engine.h>
#include <app/reporting/ReportScheduler.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -698,7 +698,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

SubscriptionResumptionStorage * mpSubscriptionResumptionStorage = nullptr;

InteractionModel::DataModel * mDataModel = nullptr;
DataModel::Provider * mDataModelProvider = nullptr;
};

} // namespace app
Expand Down
6 changes: 3 additions & 3 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
*
*/

#include "data-model-interface/DataModel.h"
#include <app/AppConfig.h>
#include <app/InteractionModelEngine.h>
#include <app/MessageDef/EventPathIB.h>
#include <app/MessageDef/StatusResponseMessage.h>
#include <app/MessageDef/SubscribeRequestMessage.h>
#include <app/MessageDef/SubscribeResponseMessage.h>
#include <app/data-model-provider/Provider.h>
#include <app/icd/server/ICDServerConfig.h>
#include <lib/core/TLVUtilities.h>
#include <messaging/ExchangeContext.h>
Expand All @@ -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)
{
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand All @@ -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<AttributePathParams> * GetAttributePathList() const { return mpAttributePathList; }
Expand Down
Loading

0 comments on commit 3608298

Please sign in to comment.