GCC Code Coverage Report


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

Line Branch Exec Source
1 /**
2 * @file api.Collection.hpp
3 * @author Sergey Baigudin, sergey@baigudin.software
4 * @copyright 2016-2022, Sergey Baigudin, Baigudin Software
5 */
6 #ifndef API_COLLECTION_HPP_
7 #define API_COLLECTION_HPP_
8
9 #include "api.Object.hpp"
10
11 namespace eoos
12 {
13 namespace api
14 {
15
16 /**
17 * @class Collection<T>
18 * @brief The root interface of some collections.
19 *
20 * @tparam T Data type of collection element.
21 */
22 template <typename T>
23 class Collection : public Object
24 {
25
26 public:
27
28 /**
29 * @brief Destructor.
30 */
31 virtual ~Collection() = 0;
32
33 /**
34 * @brief Returns a number of elements in this container.
35 *
36 * For dynamic-size class implementation the return value depends on
37 * length of containing data. For example, the String class shall return
38 * length of containing string.
39 *
40 * From other side, for static-size class implementation the return value equals
41 * to number of element of such container. For example, the Buffer class shall return
42 * number of its elements not relying on if element assigned a value.
43 *
44 * @return Number of elements, or always 0 if an error occurred.
45 */
46 virtual size_t getLength() const = 0;
47
48 /**
49 * @brief Tests if this collection has elements.
50 *
51 * For dynamic-size class implementation the return value depends on
52 * length of containing data. For example, the String class shall return
53 * true if containing string length is zero.
54 *
55 * From other side, for static-size class implementation the return value relies
56 * on number of its elements, which actually means that the Buffer class
57 * for example shall return always false if it's constructed.
58 *
59 * @return True if this collection does not contain any elements, or always true if an error occurred.
60 */
61 virtual bool_t isEmpty() const = 0;
62
63 };
64
65 template <typename T> ///< SCA MISRA-C++:2008 Defected Rule 7-3-1
66 1066 inline Collection<T>::~Collection() {}
67
68 } // namespace api
69 } // namespace eoos
70 #endif // API_COLLECTION_HPP_
71