GCC Code Coverage Report


Directory: codebase/
File: codebase/interface/include/public/api.Iterator.hpp
Date: 2023-03-16 04:37:09
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 2 50.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * @file api.Iterator.hpp
3 * @author Sergey Baigudin, sergey@baigudin.software
4 * @copyright 2016-2022, Sergey Baigudin, Baigudin Software
5 */
6 #ifndef API_ITERATOR_HPP_
7 #define API_ITERATOR_HPP_
8
9 #include "api.IllegalValue.hpp"
10
11 namespace eoos
12 {
13 namespace api
14 {
15
16 /**
17 * @class Iterator<T>
18 * @brief Iterator interface.
19 *
20 * @tparam T Data type of iterator element.
21 */
22 template <typename T>
23 class Iterator : public IllegalValue<T>
24 {
25
26 public:
27
28 /**
29 * @brief Destructor.
30 */
31 virtual ~Iterator() = 0;
32
33 /**
34 * @brief Returns next element and advances the cursor position.
35 *
36 * @return Reference to element.
37 *
38 * @todo Declare constant function to satisfy MISRA-C++:2008 Rule 9–3–1
39 */
40 virtual T& getNext() = 0;
41
42 /**
43 * @brief Tests if this iteration may return a next element.
44 *
45 * @return True if next element is had.
46 */
47 virtual bool_t hasNext() const = 0;
48
49 /**
50 * @brief Removes the last element returned by this iterator.
51 *
52 * The function removes an element that was returned by last call of an element getter.
53 * In general such the element getter is the getNext() function, or a getPrevious() function
54 * of a child class.
55 *
56 * @return True if an element is removed successfully.
57 */
58 virtual bool_t remove() = 0;
59
60 };
61
62 template <typename T> ///< SCA MISRA-C++:2008 Defected Rule 7-3-1
63 72 inline Iterator<T>::~Iterator() {}
64
65 }
66 }
67 #endif // API_ITERATOR_HPP_
68