PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
n_get_scp.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_SCP_HPP
19#define PACS_SERVICES_N_GET_SCP_HPP
20
21#include "scp_service.h"
22
23#include <atomic>
24#include <functional>
25#include <string>
26#include <vector>
27
28namespace kcenon::pacs::services {
29
30// =============================================================================
31// Handler Types
32// =============================================================================
33
51using n_get_handler = std::function<network::Result<core::dicom_dataset>(
52 const std::string& sop_class_uid,
53 const std::string& sop_instance_uid,
54 const std::vector<core::dicom_tag>& attribute_tags)>;
55
56// =============================================================================
57// N-GET SCP Class
58// =============================================================================
59
105class n_get_scp final : public scp_service {
106public:
107 // =========================================================================
108 // Construction
109 // =========================================================================
110
116 explicit n_get_scp(std::shared_ptr<di::ILogger> logger = nullptr);
117
118 ~n_get_scp() override = default;
119
120 // =========================================================================
121 // Configuration
122 // =========================================================================
123
132 void set_handler(n_get_handler handler);
133
143 void add_supported_sop_class(std::string sop_class_uid);
144
145 // =========================================================================
146 // scp_service Interface Implementation
147 // =========================================================================
148
154 [[nodiscard]] std::vector<std::string> supported_sop_classes() const override;
155
166 uint8_t context_id,
167 const network::dimse::dimse_message& request) override;
168
174 [[nodiscard]] std::string_view service_name() const noexcept override;
175
176 // =========================================================================
177 // Statistics
178 // =========================================================================
179
183 [[nodiscard]] size_t gets_processed() const noexcept;
184
188 void reset_statistics() noexcept;
189
190private:
191 // =========================================================================
192 // Private Implementation
193 // =========================================================================
194
198 [[nodiscard]] network::Result<std::monostate> send_n_get_response(
199 network::association& assoc,
200 uint8_t context_id,
201 uint16_t message_id,
202 const std::string& sop_class_uid,
203 const std::string& sop_instance_uid,
204 network::dimse::status_code status,
205 core::dicom_dataset* dataset = nullptr);
206
207 // =========================================================================
208 // Member Variables
209 // =========================================================================
210
212 std::vector<std::string> supported_sop_classes_;
213
214 std::atomic<size_t> gets_processed_{0};
215};
216
217} // namespace kcenon::pacs::services
218
219#endif // PACS_SERVICES_N_GET_SCP_HPP
std::vector< std::string > supported_sop_classes_
Definition n_get_scp.h:212
network::Result< std::monostate > send_n_get_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const std::string &sop_class_uid, const std::string &sop_instance_uid, network::dimse::status_code status, core::dicom_dataset *dataset=nullptr)
Send N-GET response.
void set_handler(n_get_handler handler)
Set the N-GET handler function.
Definition n_get_scp.cpp:32
std::atomic< size_t > gets_processed_
Definition n_get_scp.h:214
std::vector< std::string > supported_sop_classes() const override
Get supported SOP Class UIDs.
Definition n_get_scp.cpp:44
n_get_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct N-GET SCP with optional logger.
Definition n_get_scp.cpp:25
void reset_statistics() noexcept
Reset statistics counters.
size_t gets_processed() const noexcept
Get total number of N-GET requests processed.
network::Result< std::monostate > handle_message(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request) override
Handle an incoming N-GET-RQ message.
Definition n_get_scp.cpp:48
void add_supported_sop_class(std::string sop_class_uid)
Add a SOP Class UID that this SCP supports.
Definition n_get_scp.cpp:36
std::string_view service_name() const noexcept override
Get the service name.
const std::shared_ptr< di::ILogger > & logger() const noexcept
Get the current logger instance.
Definition scp_service.h:93
std::function< network::Result< core::dicom_dataset >( const std::string &sop_class_uid, const std::string &sop_instance_uid, const std::vector< core::dicom_tag > &attribute_tags)> n_get_handler
N-GET handler function type.
Definition n_get_scp.h:51
Base class for DICOM SCP (Service Class Provider) services.