PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
n_get_scu.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
18#ifndef PACS_SERVICES_N_GET_SCU_HPP
19#define PACS_SERVICES_N_GET_SCU_HPP
20
26
27#include <atomic>
28#include <chrono>
29#include <memory>
30#include <string>
31#include <string_view>
32#include <vector>
33
34namespace kcenon::pacs::services {
35
36// =============================================================================
37// N-GET SCU Data Structures
38// =============================================================================
39
47 uint16_t status{0};
48
51
53 std::string error_comment;
54
56 std::chrono::milliseconds elapsed{0};
57
59 [[nodiscard]] bool is_success() const noexcept {
60 return status == 0x0000;
61 }
62
64 [[nodiscard]] bool is_warning() const noexcept {
65 return (status & 0xF000) == 0xB000;
66 }
67
69 [[nodiscard]] bool is_error() const noexcept {
70 return !is_success() && !is_warning();
71 }
72};
73
79 std::chrono::milliseconds timeout{30000};
80};
81
82// =============================================================================
83// N-GET SCU Class
84// =============================================================================
85
127public:
128 // =========================================================================
129 // Construction
130 // =========================================================================
131
137 explicit n_get_scu(std::shared_ptr<di::ILogger> logger = nullptr);
138
145 explicit n_get_scu(const n_get_scu_config& config,
146 std::shared_ptr<di::ILogger> logger = nullptr);
147
148 ~n_get_scu() = default;
149
150 // Non-copyable, non-movable (due to atomic members)
151 n_get_scu(const n_get_scu&) = delete;
152 n_get_scu& operator=(const n_get_scu&) = delete;
153 n_get_scu(n_get_scu&&) = delete;
155
156 // =========================================================================
157 // N-GET Operation
158 // =========================================================================
159
173 std::string_view sop_class_uid,
174 std::string_view sop_instance_uid,
175 const std::vector<core::dicom_tag>& attribute_tags = {});
176
177 // =========================================================================
178 // Statistics
179 // =========================================================================
180
184 [[nodiscard]] size_t gets_performed() const noexcept;
185
189 void reset_statistics() noexcept;
190
191private:
192 // =========================================================================
193 // Private Implementation
194 // =========================================================================
195
199 [[nodiscard]] uint16_t next_message_id() noexcept;
200
201 // =========================================================================
202 // Private Members
203 // =========================================================================
204
205 std::shared_ptr<di::ILogger> logger_;
207 std::atomic<uint16_t> message_id_counter_{1};
208 std::atomic<size_t> gets_performed_{0};
209};
210
211} // namespace kcenon::pacs::services
212
213#endif // PACS_SERVICES_N_GET_SCU_HPP
DICOM Association management per PS3.8.
std::atomic< uint16_t > message_id_counter_
Definition n_get_scu.h:207
void reset_statistics() noexcept
Reset statistics counters to zero.
uint16_t next_message_id() noexcept
Get the next message ID for DIMSE operations.
size_t gets_performed() const noexcept
Get the number of N-GET operations performed.
network::Result< n_get_result > get(network::association &assoc, std::string_view sop_class_uid, std::string_view sop_instance_uid, const std::vector< core::dicom_tag > &attribute_tags={})
Retrieve attributes from a managed SOP Instance.
Definition n_get_scu.cpp:37
n_get_scu & operator=(const n_get_scu &)=delete
n_get_scu & operator=(n_get_scu &&)=delete
n_get_scu(std::shared_ptr< di::ILogger > logger=nullptr)
Construct N-GET SCU with default configuration.
Definition n_get_scu.cpp:25
std::atomic< size_t > gets_performed_
Definition n_get_scu.h:208
std::shared_ptr< di::ILogger > logger_
Definition n_get_scu.h:205
n_get_scu(n_get_scu &&)=delete
n_get_scu(const n_get_scu &)=delete
DICOM Dataset - ordered collection of Data Elements.
DICOM Tag representation (Group, Element pairs)
DIMSE message encoding and decoding.
Logger interface for dependency injection.
Result of an N-GET operation.
Definition n_get_scu.h:45
std::chrono::milliseconds elapsed
Time taken for the operation.
Definition n_get_scu.h:56
bool is_error() const noexcept
Check if this was an error status.
Definition n_get_scu.h:69
std::string error_comment
Error comment from the SCP (if any)
Definition n_get_scu.h:53
core::dicom_dataset attributes
Retrieved attributes from the SOP Instance.
Definition n_get_scu.h:50
bool is_warning() const noexcept
Check if this was a warning status.
Definition n_get_scu.h:64
uint16_t status
DIMSE status code (0x0000 = success)
Definition n_get_scu.h:47
bool is_success() const noexcept
Check if the operation was successful.
Definition n_get_scu.h:59
Configuration for N-GET SCU service.
Definition n_get_scu.h:77
std::chrono::milliseconds timeout
Timeout for receiving DIMSE response.
Definition n_get_scu.h:79