-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update AttributePathExpandIterator to be able to use the IM/DM DataMo…
…del split (#34288) * Ember invoke implementation with unit tests inside DataModel * Support ember/datamodel/dual(checked) attribute path expand iterators * Code review comments * Fix interactionmodel::status compilation in icd-management-server when ICD is on * Do not include CodegeDataModelInstance if we do not use the codegen data model * Fix linter * Fix java controller linkage. This is still broken: there should be no reason java should want ember, yet here we are (with odd dependencies inside libCHIP) * Fix Amebad compilation: OUT is defined in Ameba * Update log formatting * Review comment: use GlobalAttributesNotInMetadata directly * Remove debug bits * Code review update: we just need to match next logic in the ember code in the dm code. * Restyle * Do not check for differences if result is false ... this is what people expect even if we guarantee perfect overlap * Fix typo * Restyle * Update src/app/AttributePathExpandIterator-DataModel.cpp Co-authored-by: Boris Zbarsky <[email protected]> --------- Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
1 parent
4762aaa
commit 483af54
Showing
33 changed files
with
1,042 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "lib/support/logging/TextOnlyLogging.h" | ||
#include <app/AttributePathExpandIterator-Checked.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
AttributePathExpandIteratorChecked::AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel, | ||
SingleLinkedListNode<AttributePathParams> * attributePath) : | ||
mDataModelIterator(dataModel, attributePath), | ||
mEmberIterator(dataModel, attributePath) | ||
{ | ||
CheckOutputsIdentical("Constructor"); | ||
} | ||
|
||
bool AttributePathExpandIteratorChecked::Next() | ||
{ | ||
bool dmResult = mDataModelIterator.Next(); | ||
bool emResult = mEmberIterator.Next(); | ||
|
||
CheckOutputsIdentical("Next"); | ||
|
||
VerifyOrDie(dmResult == emResult); | ||
|
||
return emResult; | ||
} | ||
|
||
bool AttributePathExpandIteratorChecked::Get(ConcreteAttributePath & aPath) | ||
{ | ||
CheckOutputsIdentical("Get"); | ||
return mEmberIterator.Get(aPath); | ||
} | ||
|
||
void AttributePathExpandIteratorChecked::ResetCurrentCluster() | ||
{ | ||
mDataModelIterator.ResetCurrentCluster(); | ||
mEmberIterator.ResetCurrentCluster(); | ||
|
||
CheckOutputsIdentical("ResetCurrentCluster"); | ||
} | ||
|
||
void AttributePathExpandIteratorChecked::ResetTo(SingleLinkedListNode<AttributePathParams> * paths) | ||
|
||
{ | ||
mDataModelIterator.ResetTo(paths); | ||
mEmberIterator.ResetTo(paths); | ||
CheckOutputsIdentical("ResetTo"); | ||
} | ||
|
||
void AttributePathExpandIteratorChecked::CheckOutputsIdentical(const char * msg) | ||
{ | ||
ConcreteAttributePath dmPath; | ||
ConcreteAttributePath emPath; | ||
|
||
bool dmResult = mDataModelIterator.Get(dmPath); | ||
bool emResult = mEmberIterator.Get(emPath); | ||
|
||
if (dmResult == emResult) | ||
{ | ||
// We check for: | ||
// - either failed result (in which case path should not matter) | ||
// - or exact match of paths on success | ||
// | ||
// NOTE: extra logic because mExpanded is NOT considered in operator== (ugly...) | ||
if ((dmResult == false) || ((dmPath == emPath) && (dmPath.mExpanded == emPath.mExpanded))) | ||
{ | ||
// outputs are identical. All is good | ||
return; | ||
} | ||
} | ||
|
||
ChipLogProgress(Test, "Different paths in DM vs EMBER (%d and %d) in %s", dmResult, emResult, msg); | ||
ChipLogProgress(Test, " DM PATH: 0x%X/" ChipLogFormatMEI "/" ChipLogFormatMEI " (%s)", dmPath.mEndpointId, | ||
ChipLogValueMEI(dmPath.mClusterId), ChipLogValueMEI(dmPath.mAttributeId), | ||
dmPath.mExpanded ? "EXPANDED" : "NOT expanded"); | ||
ChipLogProgress(Test, " EMBER PATH: 0x%X/" ChipLogFormatMEI "/" ChipLogFormatMEI " (%s)", emPath.mEndpointId, | ||
ChipLogValueMEI(emPath.mClusterId), ChipLogValueMEI(emPath.mAttributeId), | ||
emPath.mExpanded ? "EXPANDED" : "NOT expanded"); | ||
|
||
chipDie(); | ||
} | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/AttributePathExpandIterator-DataModel.h> | ||
#include <app/AttributePathExpandIterator-Ember.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
|
||
class AttributePathExpandIteratorChecked | ||
{ | ||
public: | ||
AttributePathExpandIteratorChecked(InteractionModel::DataModel * dataModel, | ||
SingleLinkedListNode<AttributePathParams> * attributePath); | ||
|
||
bool Next(); | ||
bool Get(ConcreteAttributePath & aPath); | ||
void ResetCurrentCluster(); | ||
void ResetTo(SingleLinkedListNode<AttributePathParams> * paths); | ||
|
||
private: | ||
AttributePathExpandIteratorDataModel mDataModelIterator; | ||
AttributePathExpandIteratorEmber mEmberIterator; | ||
|
||
void CheckOutputsIdentical(const char * msg); | ||
}; | ||
|
||
} // namespace app | ||
} // namespace chip |
Oops, something went wrong.