Coverage Report

Created: 2024-12-17 06:44

/src/connectedhomeip/src/app/AttributeValueDecoder.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *    Copyright (c) 2021-2024 Project CHIP Authors
3
 *    All rights reserved.
4
 *
5
 *    Licensed under the Apache License, Version 2.0 (the "License");
6
 *    you may not use this file except in compliance with the License.
7
 *    You may obtain a copy of the License at
8
 *
9
 *        http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 *    Unless required by applicable law or agreed to in writing, software
12
 *    distributed under the License is distributed on an "AS IS" BASIS,
13
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 *    See the License for the specific language governing permissions and
15
 *    limitations under the License.
16
 */
17
#pragma once
18
19
#include <access/SubjectDescriptor.h>
20
#include <app/data-model/Decode.h>
21
#include <app/data-model/FabricScoped.h>
22
#include <lib/core/TLVReader.h>
23
24
#include <type_traits>
25
26
namespace chip {
27
namespace app {
28
29
class AttributeValueDecoder
30
{
31
public:
32
    AttributeValueDecoder(TLV::TLVReader & aReader, const Access::SubjectDescriptor & aSubjectDescriptor) :
33
0
        mReader(aReader), mSubjectDescriptor(aSubjectDescriptor)
34
0
    {}
35
36
    template <typename T, typename std::enable_if_t<!DataModel::IsFabricScoped<T>::value, bool> = true>
37
    CHIP_ERROR Decode(T & aArg)
38
0
    {
39
0
        mTriedDecode = true;
40
0
        return DataModel::Decode(mReader, aArg);
41
0
    }
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_5Ember24EmberAttributeDataBufferETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS7_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS_4SpanIKcEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS8_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeIhTnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS5_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeIlTnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS5_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeIjTnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS5_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeItTnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS5_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel8NullableIhEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS8_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeIbTnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS5_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel8NullableIjEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS8_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListIhEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS8_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS_4SpanIKhEEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSB_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS_4SpanIKhEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS8_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters11UnitTesting7Structs19TestListStructOctet4TypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters11UnitTesting7Structs19TestListStructOctet4TypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters11UnitTesting7Structs27NullablesAndOptionalsStruct13DecodableTypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters11UnitTesting7Structs27NullablesAndOptionalsStruct13DecodableTypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters11UnitTesting7Structs12SimpleStruct4TypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters7Globals7Structs16TestGlobalStruct4TypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel8NullableINS0_8Clusters11UnitTesting7Structs12SimpleStruct4TypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel8NullableINS0_8Clusters7Globals7Structs16TestGlobalStruct4TypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters10Thermostat7Structs12PresetStruct4TypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters10Thermostat7Structs12PresetStruct4TypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters6detail7Structs11LabelStruct4TypeEEETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters6detail7Structs11LabelStruct4TypeETnNSt3__19enable_ifIXntsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
42
43
    template <typename T, typename std::enable_if_t<DataModel::IsFabricScoped<T>::value, bool> = true>
44
    CHIP_ERROR Decode(T & aArg)
45
0
    {
46
0
        mTriedDecode = true;
47
        // The WriteRequest comes with no fabric index, this will happen when receiving a write request on a PASE session before
48
        // AddNOC.
49
0
        VerifyOrReturnError(AccessingFabricIndex() != kUndefinedFabricIndex, CHIP_IM_GLOBAL_STATUS(UnsupportedAccess));
50
0
        ReturnErrorOnFailure(DataModel::Decode(mReader, aArg));
51
0
        aArg.SetFabricIndex(AccessingFabricIndex());
52
0
        return CHIP_NO_ERROR;
53
0
    }
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_10AclStorage14DecodableEntryEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_10AclStorage14DecodableEntryETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERS7_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters13AccessControl7Structs28AccessControlExtensionStruct4TypeEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters13AccessControl7Structs28AccessControlExtensionStruct4TypeETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters7Binding7Structs12TargetStruct4TypeEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters7Binding7Structs12TargetStruct4TypeETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters18GroupKeyManagement7Structs17GroupKeyMapStruct4TypeEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters18GroupKeyManagement7Structs17GroupKeyMapStruct4TypeETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters26OtaSoftwareUpdateRequestor7Structs16ProviderLocation4TypeEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters26OtaSoftwareUpdateRequestor7Structs16ProviderLocation4TypeETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_9DataModel13DecodableListINS0_8Clusters11UnitTesting7Structs16TestFabricScoped13DecodableTypeEEETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSD_
Unexecuted instantiation: _ZN4chip3app21AttributeValueDecoder6DecodeINS0_8Clusters11UnitTesting7Structs16TestFabricScoped13DecodableTypeETnNSt3__19enable_ifIXsr9DataModel14IsFabricScopedIT_EE5valueEbE4typeELb1EEENS_9ChipErrorERSA_
54
55
0
    bool TriedDecode() const { return mTriedDecode; }
56
57
    /**
58
     * The accessing fabric index for this write interaction.
59
     */
60
0
    FabricIndex AccessingFabricIndex() const { return mSubjectDescriptor.fabricIndex; }
61
62
    /**
63
     * The accessing subject descriptor for this write interaction.
64
     */
65
0
    const Access::SubjectDescriptor & GetSubjectDescriptor() const { return mSubjectDescriptor; }
66
67
private:
68
    friend class TestOnlyAttributeValueDecoderAccessor;
69
70
    TLV::TLVReader & mReader;
71
    bool mTriedDecode = false;
72
    const Access::SubjectDescriptor mSubjectDescriptor;
73
};
74
75
} // namespace app
76
} // namespace chip