Coverage Report

Created: 2026-02-12 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/connectedhomeip/examples/providers/AllClustersExampleDeviceInfoProviderImpl.h
Line
Count
Source
1
/*
2
 *
3
 *    Copyright (c) 2025 Project CHIP Authors
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 <lib/core/DataModelTypes.h>
20
#include <lib/support/CHIPMem.h>
21
#include <platform/DeviceInfoProvider.h>
22
23
namespace chip {
24
namespace DeviceLayer {
25
26
class AllClustersExampleDeviceInfoProviderImpl : public DeviceInfoProvider
27
{
28
public:
29
    AllClustersExampleDeviceInfoProviderImpl() = default;
30
0
    ~AllClustersExampleDeviceInfoProviderImpl() override {}
31
32
    // Iterators
33
    FixedLabelIterator * IterateFixedLabel(EndpointId endpoint) override;
34
    UserLabelIterator * IterateUserLabel(EndpointId endpoint) override;
35
    SupportedLocalesIterator * IterateSupportedLocales() override;
36
    SupportedCalendarTypesIterator * IterateSupportedCalendarTypes() override;
37
38
    static AllClustersExampleDeviceInfoProviderImpl & GetDefaultInstance();
39
40
protected:
41
    class FixedLabelIteratorImpl : public FixedLabelIterator
42
    {
43
    public:
44
        FixedLabelIteratorImpl(EndpointId endpoint);
45
        size_t Count() override;
46
        bool Next(FixedLabelType & output) override;
47
0
        void Release() override { chip::Platform::Delete(this); }
48
49
    private:
50
        static constexpr size_t kNumSupportedFixedLabels = 1;
51
        EndpointId mEndpoint                             = 0;
52
        size_t mIndex                                    = 0;
53
    };
54
55
    class UserLabelIteratorImpl : public UserLabelIterator
56
    {
57
    public:
58
        UserLabelIteratorImpl(AllClustersExampleDeviceInfoProviderImpl & provider, EndpointId endpoint);
59
0
        size_t Count() override { return mTotal; }
60
        bool Next(UserLabelType & output) override;
61
0
        void Release() override { chip::Platform::Delete(this); }
62
63
    private:
64
        AllClustersExampleDeviceInfoProviderImpl & mProvider;
65
        EndpointId mEndpoint = 0;
66
        size_t mIndex        = 0;
67
        size_t mTotal        = 0;
68
        char mUserLabelNameBuf[kMaxLabelNameLength + 1];
69
        char mUserLabelValueBuf[kMaxLabelValueLength + 1];
70
    };
71
72
    class SupportedLocalesIteratorImpl : public SupportedLocalesIterator
73
    {
74
    public:
75
1
        SupportedLocalesIteratorImpl() = default;
76
        size_t Count() override;
77
        bool Next(CharSpan & output) override;
78
1
        void Release() override { chip::Platform::Delete(this); }
79
80
    private:
81
        static constexpr size_t kNumSupportedLocales = 8;
82
        size_t mIndex                                = 0;
83
    };
84
85
    class SupportedCalendarTypesIteratorImpl : public SupportedCalendarTypesIterator
86
    {
87
    public:
88
1
        SupportedCalendarTypesIteratorImpl() = default;
89
        size_t Count() override;
90
        bool Next(CalendarType & output) override;
91
1
        void Release() override { chip::Platform::Delete(this); }
92
93
    private:
94
        static constexpr size_t kNumSupportedCalendarTypes = 1;
95
        size_t mIndex                                      = 0;
96
    };
97
98
    CHIP_ERROR SetUserLabelLength(EndpointId endpoint, size_t val) override;
99
    CHIP_ERROR GetUserLabelLength(EndpointId endpoint, size_t & val) override;
100
    CHIP_ERROR SetUserLabelAt(EndpointId endpoint, size_t index, const UserLabelType & userLabel) override;
101
    CHIP_ERROR DeleteUserLabelAt(EndpointId endpoint, size_t index) override;
102
103
private:
104
0
    static constexpr size_t UserLabelTLVMaxSize() { return TLV::EstimateStructOverhead(kMaxLabelNameLength, kMaxLabelValueLength); }
105
};
106
107
} // namespace DeviceLayer
108
} // namespace chip