Matter SDK Coverage Report
Current view: top level - app - ChunkedWriteCallback.h (source / functions) Coverage Total Hit
Test: SHA:a3f00eecfccfb30133c3bcd3c5c7d0ea4a2c71a4 Lines: 100.0 % 1 1
Test Date: 2025-07-31 07:11:52 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2022 Project CHIP Authors
       4              :  *    All rights reserved.
       5              :  *
       6              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7              :  *    you may not use this file except in compliance with the License.
       8              :  *    You may obtain a copy of the License at
       9              :  *
      10              :  *        http://www.apache.org/licenses/LICENSE-2.0
      11              :  *
      12              :  *    Unless required by applicable law or agreed to in writing, software
      13              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15              :  *    See the License for the specific language governing permissions and
      16              :  *    limitations under the License.
      17              :  */
      18              : 
      19              : #pragma once
      20              : 
      21              : #include <app/WriteClient.h>
      22              : 
      23              : namespace chip {
      24              : namespace app {
      25              : 
      26              : /*
      27              :  * This is an adapter that intercepts calls that deliver status codes from the WriteClient and
      28              :  * selectively "merge"s the status codes for a chunked list write as follows:
      29              :  * - If the whole list was successfully written, callback->OnResponse will be called with success.
      30              :  * - If any element in the list was not successfully written, callback->OnResponse will be called with the first error received.
      31              :  * - callback->OnResponse will always have NotList as mListOp since we have merged the chunked responses.
      32              :  * The merge logic assumes all list operations are part of list chunking.
      33              :  */
      34              : class ChunkedWriteCallback : public WriteClient::Callback
      35              : {
      36              : public:
      37            7 :     ChunkedWriteCallback(WriteClient::Callback * apCallback) : callback(apCallback) {}
      38              : 
      39              :     void OnResponse(const WriteClient * apWriteClient, const ConcreteDataAttributePath & aPath, StatusIB status) override;
      40              :     void OnError(const WriteClient * apWriteClient, CHIP_ERROR aError) override;
      41              :     void OnDone(WriteClient * apWriteClient) override;
      42              : 
      43              : private:
      44              :     bool IsAppendingToLastItem(const ConcreteDataAttributePath & aPath);
      45              : 
      46              :     // We are using the casts between ConcreteAttributePath and ConcreteDataAttributePath, then all paths passed to upper
      47              :     // applications will always have NotList as mListOp.
      48              :     Optional<ConcreteAttributePath> mProcessingAttributePath;
      49              :     StatusIB mAttributeStatus;
      50              : 
      51              :     WriteClient::Callback * callback;
      52              : };
      53              : 
      54              : } // namespace app
      55              : } // namespace chip
        

Generated by: LCOV version 2.0-1