Matter SDK Coverage Report
Current view: top level - app/util/persistence - DefaultAttributePersistenceProvider.h (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 2 2
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 2021 Project CHIP Authors
       3              :  *
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : #pragma once
      17              : 
      18              : #include <app/StorageDelegateWrapper.h>
      19              : #include <app/util/persistence/AttributePersistenceProvider.h>
      20              : #include <lib/core/CHIPPersistentStorageDelegate.h>
      21              : #include <lib/support/DefaultStorageKeyAllocator.h>
      22              : 
      23              : namespace chip {
      24              : namespace app {
      25              : 
      26              : /**
      27              :  * Default implementation of AttributePersistenceProvider.  This uses
      28              :  * PersistentStorageDelegate to store the attribute values.
      29              :  *
      30              :  * NOTE: SetAttributePersistenceProvider must still be called with an instance
      31              :  * of this class, since it can't be constructed automatically without knowing
      32              :  * what PersistentStorageDelegate is to be used.
      33              :  */
      34              : class DefaultAttributePersistenceProvider : protected StorageDelegateWrapper, public AttributePersistenceProvider
      35              : {
      36              : public:
      37           62 :     DefaultAttributePersistenceProvider() = default;
      38              : 
      39            1 :     CHIP_ERROR Init(PersistentStorageDelegate * storage) { return StorageDelegateWrapper::Init(storage); }
      40              : 
      41              :     // AttributePersistenceProvider implementation.
      42              :     CHIP_ERROR WriteValue(const ConcreteAttributePath & aPath, const ByteSpan & aValue) override;
      43              :     CHIP_ERROR ReadValue(const ConcreteAttributePath & aPath, const EmberAfAttributeMetadata * aMetadata,
      44              :                          MutableByteSpan & aValue) override;
      45              : 
      46              : private:
      47              :     CHIP_ERROR InternalReadValue(const StorageKeyName & aKey, EmberAfAttributeType aType, size_t aExpectedSize,
      48              :                                  MutableByteSpan & aValue);
      49              : };
      50              : 
      51              : } // namespace app
      52              : } // namespace chip
        

Generated by: LCOV version 2.0-1