LCOV - code coverage report
Current view: top level - lib/support - CommonIterator.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 2 2 100.0 %
Date: 2024-02-15 08:20:41 Functions: 14 21 66.7 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2022 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             : 
      18             : /**
      19             :  *    @file
      20             :  *          Contains a standard iterator class.
      21             :  */
      22             : 
      23             : #pragma once
      24             : 
      25             : namespace chip {
      26             : 
      27             : /**
      28             :  * Template used to generate a custom iterator
      29             :  */
      30             : template <typename T>
      31             : class CommonIterator
      32             : {
      33             : public:
      34          30 :     virtual ~CommonIterator() = default;
      35             :     /**
      36             :      *  @retval The number of entries in total that will be iterated.
      37             :      */
      38             :     virtual size_t Count() = 0;
      39             :     /**
      40             :      *   @param[out] item  Value associated with the next element in the iteration.
      41             :      *  @retval true if the next entry is successfully retrieved.
      42             :      *  @retval false if no more entries can be found.
      43             :      */
      44             :     virtual bool Next(T & item) = 0;
      45             :     /**
      46             :      * Release the memory allocated by this iterator.
      47             :      * Must be called before the iterator goes out of scope in the iterator was dynamically allocated.
      48             :      */
      49             :     virtual void Release() = 0;
      50             : 
      51             : protected:
      52          30 :     CommonIterator() = default;
      53             : };
      54             : 
      55             : } // namespace chip

Generated by: LCOV version 1.14