GCC Code Coverage Report


./
File: libs/io/session/detail/image_series.hxx
Date: 2025-01-21 16:21:04
Lines:
14/14
100.0%
Functions:
2/2
100.0%
Branches:
22/46
47.8%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2021-2024 IRCAD France
4 *
5 * This file is part of Sight.
6 *
7 * Sight is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Sight is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
19 *
20 ***********************************************************************/
21
22 #pragma once
23
24 #include <sight/io/session/config.hpp>
25
26 #include "io/session/detail/image.hxx"
27 #include "io/session/detail/series.hxx"
28 #include "io/session/helper.hpp"
29 #include "io/session/macros.hpp"
30
31 #include <data/image_series.hpp>
32
33 namespace sight::io::session::detail::image_series
34 {
35
36 constexpr static auto DICOM_REFERENCE {"DicomReference"};
37
38 //------------------------------------------------------------------------------
39
40 12 inline static void write(
41 zip::archive_writer& _archive,
42 boost::property_tree::ptree& _tree,
43 data::object::csptr _object,
44 std::map<std::string, data::object::csptr>& _children,
45 const core::crypto::secure_string& _password = ""
46 )
47 {
48
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
24 const auto image_series = helper::safe_cast<data::image_series>(_object);
49
50 // Add a version number. Not mandatory, but could help for future release
51
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 helper::write_version<data::image_series>(_tree, 1);
52
53 // Since image_series inherits from Series, we could use SeriesSerializer
54
1/2
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 series::write(_archive, _tree, image_series, _children, _password);
55
1/2
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 image::write(_archive, _tree, image_series, _children, _password);
56
57 // Serialize other attributes
58
6/14
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
21 _children[DICOM_REFERENCE] = image_series->get_dicom_reference();
59 12 }
60
61 //------------------------------------------------------------------------------
62
63 12 inline static data::image_series::sptr read(
64 zip::archive_reader& _archive,
65 const boost::property_tree::ptree& _tree,
66 const std::map<std::string, data::object::sptr>& _children,
67 data::object::sptr _object,
68 const core::crypto::secure_string& _password = ""
69 )
70 {
71 // Create or reuse the object
72
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
24 auto image_series = helper::cast_or_create<data::image_series>(_object);
73
74 // Check version number. Not mandatory, but could help for future release
75
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 helper::read_version<data::image_series>(_tree, 0, 1);
76
77
2/4
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
24 image::read(_archive, _tree, _children, image_series, _password);
78 // Deserialize series last since it overwrites some attributes of image.
79
2/4
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
24 series::read(_archive, _tree, _children, image_series, _password);
80
81 // Deserialize other attributes
82
4/8
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
21 image_series->set_dicom_reference(std::dynamic_pointer_cast<data::dicom_series>(_children.at(DICOM_REFERENCE)));
83
84 12 return image_series;
85 }
86
87 SIGHT_REGISTER_SERIALIZER(data::image_series, write, read);
88
89 } // namespace sight::io::session::detail::image_series
90