| /* |
| * |
| * Copyright (c) 2021 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/util/basic-types.h> |
| |
| #include <app/ClusterInfo.h> |
| #include <app/MessageDef/AttributePathIB.h> |
| |
| namespace chip { |
| namespace app { |
| struct AttributePathParams |
| { |
| // |
| // TODO: (Issue #10596) Need to ensure that we do not encode the NodeId over the wire |
| // if it is either not 'set', or is set to a value that matches accessing fabric |
| // on which the interaction is undertaken. |
| // |
| // TODO: (#11420) This class is overlapped with ClusterInfo class, need to do a clean up. |
| AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId) : |
| AttributePathParams(aEndpointId, aClusterId, ClusterInfo::kInvalidAttributeId, ClusterInfo::kInvalidListIndex) |
| {} |
| |
| AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId) : |
| AttributePathParams(aEndpointId, aClusterId, aFieldId, ClusterInfo::kInvalidListIndex) |
| {} |
| |
| AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId, ListIndex aListIndex) : |
| mEndpointId(aEndpointId), mClusterId(aClusterId), mFieldId(aFieldId), mListIndex(aListIndex) |
| {} |
| |
| AttributePathParams() {} |
| |
| CHIP_ERROR BuildAttributePath(AttributePathIB::Builder & aBuilder) const; |
| |
| bool HasWildcard() const { return HasWildcardEndpointId() || HasWildcardClusterId() || HasWildcardAttributeId(); } |
| |
| /** |
| * Check that the path meets some basic constraints of an attribute path: If list index is not wildcard, then field id must not |
| * be wildcard. This does not verify that the attribute being targeted is actually of list type when the list index is not |
| * wildcard. |
| */ |
| bool IsValidAttributePath() const { return HasWildcardListIndex() || !HasWildcardAttributeId(); } |
| |
| inline bool HasWildcardEndpointId() const { return mEndpointId == ClusterInfo::kInvalidEndpointId; } |
| inline bool HasWildcardClusterId() const { return mClusterId == ClusterInfo::kInvalidClusterId; } |
| inline bool HasWildcardAttributeId() const { return mFieldId == ClusterInfo::kInvalidAttributeId; } |
| inline bool HasWildcardListIndex() const { return mListIndex == ClusterInfo::kInvalidListIndex; } |
| |
| EndpointId mEndpointId = ClusterInfo::kInvalidEndpointId; |
| ClusterId mClusterId = ClusterInfo::kInvalidClusterId; |
| AttributeId mFieldId = ClusterInfo::kInvalidAttributeId; |
| ListIndex mListIndex = ClusterInfo::kInvalidListIndex; |
| }; |
| } // namespace app |
| } // namespace chip |