Matter SDK Coverage Report
Current view: top level - app - PendingResponseTrackerImpl.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 18 18
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /*
       2              :  *    Copyright (c) 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              : 
      18              : #include <app/PendingResponseTrackerImpl.h>
      19              : 
      20              : #include <lib/support/CodeUtils.h>
      21              : 
      22              : namespace chip {
      23              : namespace app {
      24              : 
      25        65556 : CHIP_ERROR PendingResponseTrackerImpl::Add(uint16_t aCommandRef)
      26              : {
      27        65556 :     VerifyOrReturnError(!IsTracked(aCommandRef), CHIP_ERROR_INVALID_ARGUMENT);
      28        65554 :     mCommandReferenceSet.insert(aCommandRef);
      29        65554 :     return CHIP_NO_ERROR;
      30              : }
      31              : 
      32        65538 : CHIP_ERROR PendingResponseTrackerImpl::Remove(uint16_t aCommandRef)
      33              : {
      34        65538 :     VerifyOrReturnError(IsTracked(aCommandRef), CHIP_ERROR_KEY_NOT_FOUND);
      35        65536 :     mCommandReferenceSet.erase(aCommandRef);
      36        65536 :     return CHIP_NO_ERROR;
      37              : }
      38              : 
      39       393269 : bool PendingResponseTrackerImpl::IsTracked(uint16_t aCommandRef)
      40              : {
      41       393269 :     return mCommandReferenceSet.find(aCommandRef) != mCommandReferenceSet.end();
      42              : }
      43              : 
      44           17 : size_t PendingResponseTrackerImpl::Count()
      45              : {
      46           17 :     return mCommandReferenceSet.size();
      47              : }
      48              : 
      49           11 : Optional<uint16_t> PendingResponseTrackerImpl::PopPendingResponse()
      50              : {
      51           11 :     if (Count() == 0)
      52              :     {
      53            5 :         return NullOptional;
      54              :     }
      55            6 :     uint16_t commandRef = *mCommandReferenceSet.begin();
      56            6 :     mCommandReferenceSet.erase(mCommandReferenceSet.begin());
      57            6 :     return MakeOptional(commandRef);
      58              : }
      59              : 
      60              : } // namespace app
      61              : } // namespace chip
        

Generated by: LCOV version 2.0-1