Matter SDK Coverage Report
Current view: top level - app/server-cluster - AttributeListBuilder.h (source / functions) Coverage Total Hit
Test: SHA:4d2388ac7eed75b2fe5e05e20de377999c632502 Lines: 100.0 % 1 1
Test Date: 2025-07-27 07:17:09 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 2025 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 <app/data-model-provider/MetadataTypes.h>
      20              : #include <lib/core/CHIPError.h>
      21              : #include <lib/support/ReadOnlyBuffer.h>
      22              : 
      23              : #include <initializer_list>
      24              : 
      25              : namespace chip {
      26              : namespace app {
      27              : 
      28              : /// Provides a centralized implementation of the very common operation of
      29              : /// appending a list of attributes to a ReadOnlyBufferBuilder.
      30              : ///
      31              : /// The intent is that the more complex logic of `Append` to be shared across
      32              : /// cluster implementations, so that flash size is kept small.
      33              : ///
      34              : /// Append handles both mandatory and optional attributes and also handles
      35              : /// the required auto-add of `GlobalAttributes`.
      36              : class AttributeListBuilder
      37              : {
      38              : public:
      39           11 :     AttributeListBuilder(ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) : mBuilder(builder) {}
      40              : 
      41              :     struct OptionalAttributeEntry
      42              :     {
      43              :         bool enabled;                               // Is this optional attribute enabled?
      44              :         const DataModel::AttributeEntry & metadata; // Metadata for the attribute
      45              :     };
      46              : 
      47              :     /// Appends the given attributes to the builder.
      48              :     ///
      49              :     /// It is very common to have a set of mandatory and a set of optional attributes for a
      50              :     /// cluster. This method allows for a single call to set up all of the given attributes in `builder`:
      51              :     ///   - mandatoryAttributes
      52              :     ///   - optionalAttributes IF AND ONLY IF they are enabled
      53              :     ///   - all of `GlobalAttributes()`
      54              :     CHIP_ERROR Append(Span<const DataModel::AttributeEntry> mandatoryAttributes,
      55              :                       Span<const OptionalAttributeEntry> optionalAttributes);
      56              : 
      57              : private:
      58              :     ReadOnlyBufferBuilder<DataModel::AttributeEntry> & mBuilder;
      59              : };
      60              : 
      61              : } // namespace app
      62              : } // namespace chip
        

Generated by: LCOV version 2.0-1