Line | Branch | Exec | Source |
---|---|---|---|
1 | /** | ||
2 | * @file lib.NonCopyable.hpp | ||
3 | * @author Sergey Baigudin, sergey@baigudin.software | ||
4 | * @copyright 2022, Sergey Baigudin, Baigudin Software | ||
5 | */ | ||
6 | #ifndef LIB_NONCOPYABLE_HPP_ | ||
7 | #define LIB_NONCOPYABLE_HPP_ | ||
8 | |||
9 | #include "lib.Object.hpp" | ||
10 | |||
11 | namespace eoos | ||
12 | { | ||
13 | namespace lib | ||
14 | { | ||
15 | |||
16 | /** | ||
17 | * @class NonCopyable | ||
18 | * @brief Next to root class of the operating system for objects which cannot be copied or moved. | ||
19 | * | ||
20 | * @tparam A Heap memory allocator class. | ||
21 | */ | ||
22 | template <class A = Allocator> | ||
23 | class NonCopyable : public Object<A> | ||
24 | { | ||
25 | typedef lib::Object<A> Parent; | ||
26 | |||
27 | public: | ||
28 | |||
29 | /** | ||
30 | * @brief Constructor. | ||
31 | */ | ||
32 | 747 | NonCopyable() | |
33 | 747 | : Object<A>() { | |
34 | 747 | } | |
35 | |||
36 | /** | ||
37 | * @brief Destructor. | ||
38 | */ | ||
39 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
1332 | virtual ~NonCopyable() {} |
40 | |||
41 | private: | ||
42 | |||
43 | /** | ||
44 | * @copydoc eoos::Object::Object(Object const&) | ||
45 | */ | ||
46 | NonCopyable(NonCopyable const&); ///< SCA MISRA-C++:2008 Justified Rule 3-2-2 and Rule 3-2-4 | ||
47 | |||
48 | /** | ||
49 | * @copydoc eoos::Object::operator=(Object const&) | ||
50 | */ | ||
51 | NonCopyable& operator=(NonCopyable const&); ///< SCA MISRA-C++:2008 Justified Rule 3-2-2 and Rule 3-2-4 | ||
52 | |||
53 | #if EOOS_CPP_STANDARD >= 2011 | ||
54 | |||
55 | /** | ||
56 | * @copydoc eoos::Object::Object(Object&&) | ||
57 | */ | ||
58 | NonCopyable(NonCopyable&&) noexcept = delete; | ||
59 | |||
60 | /** | ||
61 | * @copydoc eoos::Object::operator=(Object&&) | ||
62 | */ | ||
63 | NonCopyable& operator=(NonCopyable&&) & noexcept = delete; | ||
64 | |||
65 | #endif // EOOS_CPP_STANDARD >= 2011 | ||
66 | |||
67 | }; | ||
68 | |||
69 | } // namespace sys | ||
70 | } // namespace eoos | ||
71 | #endif // SYS_NONCOPYABLE_HPP_ | ||
72 |