GCC Code Coverage Report


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

Line Branch Exec Source
1 /**
2 * @file api.SmartPointer.hpp
3 * @author Sergey Baigudin, sergey@baigudin.software
4 * @copyright 2022, Sergey Baigudin, Baigudin Software
5 */
6 #ifndef API_SMARTPOINTER_HPP_
7 #define API_SMARTPOINTER_HPP_
8
9 #include "api.Object.hpp"
10
11 namespace eoos
12 {
13 namespace api
14 {
15
16 /**
17 * @class SmartPointer<T>
18 * @brief Smart Pointer interface.
19 *
20 * @tparam T Data type of an owning object.
21 */
22 template <typename T>
23 class SmartPointer : public Object
24 {
25
26 public:
27
28 /**
29 * @brief Destructor.
30 */
31 virtual ~SmartPointer() = 0;
32
33 /**
34 * @brief Returns pointer to the managed object.
35 *
36 * @return Pointer to the managed object or NULLPTR if no object managed.
37 */
38 virtual T* get() const = 0;
39
40 /**
41 * @brief Releases the managed object.
42 */
43 virtual void reset() = 0;
44
45 /**
46 * @brief Replaces the managed object with a given object.
47 *
48 * @param ptr An object to replace the managed object.
49 */
50 virtual void reset(T* ptr) = 0;
51
52 /**
53 * @brief Returns amount of smart objects for the managed object.
54 *
55 * @return Amount of smart objects manage the same object, if no managed object, 0 is returned.
56 */
57 virtual int32_t getCount() const = 0;
58
59 /**
60 * @brief Tests if this smart object does not manage any object.
61 *
62 * @return true if no object managed.
63 */
64 virtual bool_t isNull() const = 0;
65
66 /**
67 * @brief Tests if this smart object is only one manages an object.
68 *
69 * @return true if this smart object is one, otherwise false.
70 */
71 virtual bool_t isUnique() const = 0;
72
73 };
74
75 template <typename T> ///< SCA MISRA-C++:2008 Defected Rule 7-3-1
76 432 inline SmartPointer<T>::~SmartPointer() {}
77
78 } // namespace api
79 } // namespace eoos
80 #endif // API_STRING_HPP_
81