Skip to content

Commit

Permalink
[cluster object] Change MatchesFabricIndex to GetFabricIndex (project…
Browse files Browse the repository at this point in the history
…-chip#13902)

* [cluster object] Change MatchesFabricIndex to GetFabricIndex

* Run Codegen

* Fix comment
  • Loading branch information
erjiaqing authored and selissia committed Jan 28, 2022
1 parent b5a2afa commit c0e6cf2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/AttributeAccessInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AttributeValueEncoder
// If we are encoding for a fabric filtered attribute read and the fabric index does not match that present in the
// request, skip encoding this list item.
VerifyOrReturnError(!mAttributeValueEncoder.mIsFabricFiltered ||
aArg.MatchesFabricIndex(mAttributeValueEncoder.mAccessingFabricIndex),
aArg.GetFabricIndex() == mAttributeValueEncoder.mAccessingFabricIndex,
CHIP_NO_ERROR);
return mAttributeValueEncoder.EncodeListItem(std::forward<T>(aArg));
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/data-model/FabricScoped.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ namespace DataModel {
/*
* Check whether a cluster object struct is fabric scoped.
* A fabric scoped struct contains a field of "FabricIndex" type, however, we cannot tell the difference between that field and
* other uint8_t fields. Thus we add a MatchesFabricIndex member function for checking the fabric id. Here, IsFabricScoped check the
* presence of MatchesFabricIndex function. This template can be used with std::enable_if.
* other uint8_t fields. Thus we add a GetFabricIndex member function for getting the fabric id. Here, IsFabricScoped checks the
* presence of GetFabricIndex function. This template can be used with std::enable_if.
*/
template <typename T>
class IsFabricScoped
{
private:
template <typename Tp>
static auto TestHasMatchesFabricIndex(int) -> TemplatedTrueType<decltype(&Tp::MatchesFabricIndex)>;
static auto TestHasFabricIndex(int) -> TemplatedTrueType<decltype(&Tp::GetFabricIndex)>;

template <typename Tp>
static auto TestHasMatchesFabricIndex(long) -> std::false_type;
static auto TestHasFabricIndex(long) -> std::false_type;

public:
static constexpr bool value = decltype(TestHasMatchesFabricIndex<std::decay_t<T>>(0))::value;
static constexpr bool value = decltype(TestHasFabricIndex<std::decay_t<T>>(0))::value;
};

} // namespace DataModel
Expand Down
6 changes: 3 additions & 3 deletions src/app/zap-templates/partials/cluster-objects-struct.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace {{asUpperCamelCase name}} {
CHIP_ERROR Decode(TLV::TLVReader &reader);
{{/unless}}
{{#if struct_is_fabric_scoped}}
bool MatchesFabricIndex(FabricIndex fabricIndex_) const {
return {{ asLowerCamelCase struct_fabric_idx_field }} == fabricIndex_;
auto GetFabricIndex() const {
return {{ asLowerCamelCase struct_fabric_idx_field }};
}
{{/if}}
};
Expand Down Expand Up @@ -74,4 +74,4 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {
}

} // namespace {{asUpperCamelCase name}}
{{/if}}
{{/if}}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0e6cf2

Please sign in to comment.