Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file api.Queue.hpp |
3 |
|
|
* @author Sergey Baigudin, sergey@baigudin.software |
4 |
|
|
* @copyright 2016-2022, Sergey Baigudin, Baigudin Software |
5 |
|
|
*/ |
6 |
|
|
#ifndef API_QUEUE_HPP_ |
7 |
|
|
#define API_QUEUE_HPP_ |
8 |
|
|
|
9 |
|
|
#include "api.Collection.hpp" |
10 |
|
|
#include "api.IllegalValue.hpp" |
11 |
|
|
|
12 |
|
|
namespace eoos |
13 |
|
|
{ |
14 |
|
|
namespace api |
15 |
|
|
{ |
16 |
|
|
|
17 |
|
|
/** |
18 |
|
|
* @class Queue<T> |
19 |
|
|
* @brief Queue interface. |
20 |
|
|
* |
21 |
|
|
* @tparam T Data type of queue element. |
22 |
|
|
*/ |
23 |
|
|
template <typename T> |
24 |
|
|
class Queue : public Collection<T>, public IllegalValue<T> |
25 |
|
|
{ |
26 |
|
|
|
27 |
|
|
public: |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* @brief Destructor. |
31 |
|
|
*/ |
32 |
|
|
virtual ~Queue() = 0; |
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* @brief Inserts a new element to the end of this container. |
36 |
|
|
* |
37 |
|
|
* @note A passed element must be copied to an internal data structure of |
38 |
|
|
* a realizing class by calling a copy constructor so that the element |
39 |
|
|
* might be invalidated after the function called. |
40 |
|
|
* |
41 |
|
|
* @param element An inserting element. |
42 |
|
|
* @return True if element is added. |
43 |
|
|
*/ |
44 |
|
|
virtual bool_t add(T const& element) = 0; |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* @brief Removes the head element of this container. |
48 |
|
|
* |
49 |
|
|
* @return True if an element is removed successfully. |
50 |
|
|
*/ |
51 |
|
|
virtual bool_t remove() = 0; |
52 |
|
|
|
53 |
|
|
/** |
54 |
|
|
* @brief Examines the head element of this container. |
55 |
|
|
* |
56 |
|
|
* @return The head element. |
57 |
|
|
* |
58 |
|
|
* @todo Declare constant function to satisfy MISRA-C++:2008 Rule 9–3–1 |
59 |
|
|
*/ |
60 |
|
|
virtual T& peek() = 0; |
61 |
|
|
|
62 |
|
|
}; |
63 |
|
|
|
64 |
|
|
template <typename T> ///< SCA MISRA-C++:2008 Defected Rule 7-3-1 |
65 |
|
152 |
inline Queue<T>::~Queue() {} |
66 |
|
|
|
67 |
|
|
} // namespace api |
68 |
|
|
} // namespace eoos |
69 |
|
|
#endif // API_QUEUE_HPP_ |
70 |
|
|
|