Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file api.IllegalValue.hpp |
3 |
|
|
* @author Sergey Baigudin, sergey@baigudin.software |
4 |
|
|
* @copyright 2016-2022, Sergey Baigudin, Baigudin Software |
5 |
|
|
*/ |
6 |
|
|
#ifndef API_ILLEGALVALUE_HPP_ |
7 |
|
|
#define API_ILLEGALVALUE_HPP_ |
8 |
|
|
|
9 |
|
|
#include "api.Object.hpp" |
10 |
|
|
|
11 |
|
|
namespace eoos |
12 |
|
|
{ |
13 |
|
|
namespace api |
14 |
|
|
{ |
15 |
|
|
|
16 |
|
|
/** |
17 |
|
|
* @class IllegalValue<T> |
18 |
|
|
* @brief Illegal value interface. |
19 |
|
|
* |
20 |
|
|
* @tparam T Data type of value. |
21 |
|
|
*/ |
22 |
|
|
template <typename T> |
23 |
|
|
class IllegalValue : public Object |
24 |
|
|
{ |
25 |
|
|
|
26 |
|
|
public: |
27 |
|
|
|
28 |
|
|
/** |
29 |
|
|
* @brief Destructor. |
30 |
|
|
*/ |
31 |
|
|
virtual ~IllegalValue() = 0; |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
* @brief Returns illegal element which will be returned as error value. |
35 |
|
|
* |
36 |
|
|
* @return Illegal element. |
37 |
|
|
*/ |
38 |
|
|
virtual T const& getIllegal() const = 0; |
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
* @brief Sets illegal element which will be returned as error value. |
42 |
|
|
* |
43 |
|
|
* @note A passed value must be copied to an internal data structure of |
44 |
|
|
* a realizing class by calling a copy constructor so that the variable |
45 |
|
|
* might be invalidated after the function called. |
46 |
|
|
* |
47 |
|
|
* @param value An illegal value. |
48 |
|
|
*/ |
49 |
|
|
virtual void setIllegal(T const& value) = 0; |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* @brief Tests if given value is an illegal. |
53 |
|
|
* |
54 |
|
|
* @param value A testing value. |
55 |
|
|
* @return True if value is an illegal. |
56 |
|
|
*/ |
57 |
|
|
virtual bool_t isIllegal(T const& value) const = 0; |
58 |
|
|
|
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
template <typename T> ///< SCA MISRA-C++:2008 Defected Rule 7-3-1 |
62 |
|
506 |
inline IllegalValue<T>::~IllegalValue() {} |
63 |
|
|
|
64 |
|
|
} // namespace api |
65 |
|
|
} // namespace eoos |
66 |
|
|
#endif // API_ILLEGALVALUE_HPP_ |
67 |
|
|
|