GCC Code Coverage Report


./
File: libs/__/data/frame_tl.hpp
Date: 2025-01-21 16:21:04
Lines:
12/12
100.0%
Functions:
2/6
33.3%
Branches:
69/141
48.9%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2009-2024 IRCAD France
4 * Copyright (C) 2012-2020 IHU Strasbourg
5 *
6 * This file is part of Sight.
7 *
8 * Sight is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Sight is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
20 *
21 ***********************************************************************/
22
23 #pragma once
24
25 #include "data/factory/new.hpp"
26 #include "data/generic_tl.hpp"
27 #include "data/generic_tl.hxx"
28 #include "data/timeline/generic_object.hpp"
29 #include "data/timeline/generic_object.hxx"
30
31 #include <core/type.hpp>
32
33 #include <data/factory/new.hpp>
34
35 namespace sight::data
36 {
37
38 /**
39 * @brief This class defines a timeline of images.
40 */
41 class SIGHT_DATA_CLASS_API frame_tl final : public generic_tl<uint8_t>
42 {
43 public:
44
45
4/9
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 70 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
154 SIGHT_DECLARE_CLASS(frame_tl, generic_tl<uint8_t>);
46
47 /// Frame format
48 enum class pixel_format
49 {
50 undefined = 0, ///< Undefined pixel format
51 rgb, ///< Frame with 3 component RGB.
52 rgba, ///< Frame with 4 component RGBA.
53 bgr, ///< Frame with 3 component BGR.
54 bgra, ///< Frame with 4 component BGRA.
55 gray_scale ///< Frame with 1 component.
56 };
57
58 /**
59 * @brief Constructor
60 */
61 SIGHT_DATA_API frame_tl();
62
63 /// Destructor
64 57 SIGHT_DATA_API ~frame_tl() noexcept override = default;
65
66 /// Initializes the size of the pool buffer.
67 SIGHT_DATA_API void init_pool_size(
68 std::size_t _width,
69 std::size_t _height,
70 const core::type& _type,
71 pixel_format _format,
72 unsigned int _max_element_num = 1
73 );
74
75 /// Returns the width of an image in the timeline
76 507 std::size_t get_width() const
77 {
78
12/26
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
507 return m_width;
79 }
80
81 /// Returns the height of an image in the timeline
82 507 std::size_t get_height() const
83 {
84
14/27
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
507 return m_height;
85 }
86
87 /// Returns the number of components of an image in the timeline
88 502 std::size_t num_components() const
89 {
90
13/28
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
503 return m_number_of_components;
91 }
92
93 /// Returns the type of the frame pixel
94 500 core::type type() const
95 {
96
13/26
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
500 return m_type;
97 }
98
99 /// Returns the frame pixel format
100 pixel_format pixel_format() const;
101
102 /// Set the frame pixel format
103 void set_pixel_format(enum pixel_format _format);
104
105 /// Equality comparison operators
106 /// @{
107 SIGHT_DATA_API bool operator==(const frame_tl& _other) const noexcept;
108 SIGHT_DATA_API bool operator!=(const frame_tl& _other) const noexcept;
109 /// @}
110
111 /// Defines shallow copy
112 /// @throws data::exception if an errors occurs during copy
113 /// @param[in] _source the source object to copy
114 SIGHT_DATA_API void shallow_copy(const object::csptr& _source) override;
115
116 /// Defines deep copy
117 /// @throws data::exception if an errors occurs during copy
118 /// @param _source source object to copy
119 /// @param _cache cache used to deduplicate pointers
120 SIGHT_DATA_API void deep_copy(
121 const object::csptr& _source,
122 const std::unique_ptr<deep_copy_cache_t>& _cache = std::make_unique<deep_copy_cache_t>()
123 ) override;
124
125 private:
126
127 /// Forbid the use of this inherited method.
128 SIGHT_DATA_API void init_pool_size(unsigned int _max_element_num) override;
129
130 /// frame width
131 std::size_t m_width {0};
132
133 /// frame height
134 std::size_t m_height {0};
135
136 /// number of components
137 std::size_t m_number_of_components {3};
138
139 /// type of frame pixel
140 core::type m_type;
141
142 /// Frame format
143 enum pixel_format m_pixel_format
144 {
145 pixel_format::undefined
146 };
147 }; // class frame_tl
148
149 //-----------------------------------------------------------------------------
150
151 inline void frame_tl::set_pixel_format(enum pixel_format _format)
152 {
153 m_pixel_format = _format;
154 }
155
156 //-----------------------------------------------------------------------------
157
158 487 inline enum frame_tl::pixel_format frame_tl::pixel_format() const
159 {
160
13/25
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
487 return m_pixel_format;
161 }
162
163 } // namespace sight::data
164