File: series_puller.hpp

package info (click to toggle)
sight 25.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,180 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (151 lines) | stat: -rw-r--r-- 4,663 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/************************************************************************
 *
 * Copyright (C) 2018-2025 IRCAD France
 * Copyright (C) 2018-2019 IHU Strasbourg
 *
 * This file is part of Sight.
 *
 * Sight is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Sight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#pragma once

#include <core/progress/has_monitors.hpp>

#include <data/integer.hpp>
#include <data/series_set.hpp>
#include <data/string.hpp>
#include <data/vector.hpp>

#include <io/__/service/reader.hpp>
#include <io/http/client_qt.hpp>

#include <service/controller.hpp>

#include <filesystem>

namespace sight::data
{

class dicom_series;

} // namespace sight::data

namespace sight::module::io::dicomweb
{

/**
 * @brief   This service is used to pull series from a PACS (Orthanc).
 *

 * @section Slots Slots
 * - \b displayErrorMessage(const std::string&) : display an error message.

 * @section XML XML Configuration
 *
 * @code{.xml}
        <service type="sight::module::io::dicomweb::series_puller">
            <in key="selectedSeries" uid="..." />
            <inout key="seriesSet" uid="..." />
            <config dicom_reader="sight::module::io::dicom::series_set_reader" reader_config="config" />
            <properties host_name="${host_name}" port="${port_id}" />
       </service>
   @endcode
 * @subsection Input Input:
 * - \b selectedSeries [sight::data::vector]: List of DICOM series to pull from the PACS..
 * @subsection In-Out In-Out:
 * - \b seriesSet [sight::data::series_set]: series_set where to put the retrieved dicom series.
 * @subsection Properties Properties
 * - \b host_name : Need hostname string (default value is "127.0.0.1").
 * - \b port : Need the value of port (default value is 8042).
 */

class series_puller : public service::controller,
                      public core::progress::has_monitors
{
public:

    SIGHT_DECLARE_SERVICE(series_puller, sight::service::controller);

    using dicom_series_container_t = data::series_set::container_t;
    using instance_uid_container_t = std::vector<std::string>;
    using dicom_series_map_t       = std::map<std::string, std::weak_ptr<data::series> >;

    series_puller() noexcept;
    ~series_puller() noexcept override = default;

protected:

    /// Gets the configuration.
    void configuring() override;

    /// Registers the DICOM reader.
    void starting() override;

    /// Stops the DICOM reader.
    void stopping() override;

    /// Checks the configuration and pull the series.
    void updating() override;

private:

    /// Pull the Series from the Pacs.
    void pull_series();

    /**
     * @brief Read local series.
     * @param[in] _selected_series Series to read
     */
    void read_local_series(dicom_series_container_t _selected_series);

    /**
     * @brief Display an error message.
     * @param[in] _message Error message to display
     */
    static void display_error_message(const std::string& _message);

    /// Http Qt Client
    sight::io::http::client_qt m_client_qt;

    /// Temporary series_set
    data::series_set::sptr m_tmp_series_set;

    /// Local Series
    instance_uid_container_t m_local_series;

    /// Is pulling is set to true when we are pulling series
    bool m_is_pulling {false};

    /// Index of the series being downloaded
    unsigned int m_series_index {0};

    /// Map of Dicom series being pulled
    dicom_series_map_t m_pulling_dicom_series_map;

    /// Server hostname preference key
    std::string m_server_hostname_key;

    /// Server port preference key
    std::string m_server_port_key;

    sight::data::property<sight::data::string> m_server_hostname {this, "host_name", std::string("localhost")};
    sight::data::property<sight::data::integer> m_server_port {this, "port", 4242};

    sight::data::ptr<sight::data::vector, sight::data::access::in> m_selected_series {this, "selected_series"};
    sight::data::ptr<sight::data::series_set, sight::data::access::inout> m_series_set {this, "series_set"};
};

} // namespace sight::module::io::dicomweb