PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
ups_query_scp.h
Go to the documentation of this file.
1
15#ifndef PACS_SERVICES_UPS_QUERY_SCP_HPP
16#define PACS_SERVICES_UPS_QUERY_SCP_HPP
17
18#include "../scp_service.h"
19
20#include <atomic>
21#include <functional>
22
23namespace kcenon::pacs::services {
24
25// =============================================================================
26// SOP Class UID
27// =============================================================================
28
30inline constexpr std::string_view ups_query_find_sop_class_uid =
31 "1.2.840.10008.5.1.4.34.6.4";
32
33// =============================================================================
34// Handler Types
35// =============================================================================
36
53using ups_query_handler = std::function<std::vector<core::dicom_dataset>(
54 const core::dicom_dataset& query_keys,
55 const std::string& calling_ae)>;
56
65using ups_query_cancel_check = std::function<bool()>;
66
67// =============================================================================
68// UPS Query SCP Class
69// =============================================================================
70
106class ups_query_scp final : public scp_service {
107public:
108 // =========================================================================
109 // Construction
110 // =========================================================================
111
117 explicit ups_query_scp(std::shared_ptr<di::ILogger> logger = nullptr);
118
119 ~ups_query_scp() override = default;
120
121 // =========================================================================
122 // Configuration
123 // =========================================================================
124
125 void set_handler(ups_query_handler handler);
126 void set_max_results(size_t max) noexcept;
127 [[nodiscard]] size_t max_results() const noexcept;
129
130 // =========================================================================
131 // scp_service Interface Implementation
132 // =========================================================================
133
134 [[nodiscard]] std::vector<std::string> supported_sop_classes() const override;
135
136 [[nodiscard]] network::Result<std::monostate> handle_message(
137 network::association& assoc,
138 uint8_t context_id,
139 const network::dimse::dimse_message& request) override;
140
141 [[nodiscard]] std::string_view service_name() const noexcept override;
142
143 // =========================================================================
144 // Statistics
145 // =========================================================================
146
147 [[nodiscard]] size_t queries_processed() const noexcept;
148 [[nodiscard]] size_t items_returned() const noexcept;
149
150 void reset_statistics() noexcept;
151
152private:
153 // =========================================================================
154 // Private Implementation
155 // =========================================================================
156
157 [[nodiscard]] network::Result<std::monostate> send_pending_response(
158 network::association& assoc,
159 uint8_t context_id,
160 uint16_t message_id,
161 const core::dicom_dataset& result);
162
163 [[nodiscard]] network::Result<std::monostate> send_final_response(
164 network::association& assoc,
165 uint8_t context_id,
166 uint16_t message_id,
167 network::dimse::status_code status);
168
169 // =========================================================================
170 // Member Variables
171 // =========================================================================
172
175 size_t max_results_{0}; // 0 = unlimited
176 std::atomic<size_t> queries_processed_{0};
177 std::atomic<size_t> items_returned_{0};
178};
179
180} // namespace kcenon::pacs::services
181
182#endif // PACS_SERVICES_UPS_QUERY_SCP_HPP
const std::shared_ptr< di::ILogger > & logger() const noexcept
Get the current logger instance.
Definition scp_service.h:93
UPS Query SCP service for handling workitem C-FIND requests.
std::string_view service_name() const noexcept override
Get the service name for logging/debugging.
network::Result< std::monostate > send_pending_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const core::dicom_dataset &result)
network::Result< std::monostate > send_final_response(network::association &assoc, uint8_t context_id, uint16_t message_id, network::dimse::status_code status)
void set_max_results(size_t max) noexcept
void set_cancel_check(ups_query_cancel_check check)
network::Result< std::monostate > handle_message(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request) override
Handle an incoming DIMSE message.
void set_handler(ups_query_handler handler)
size_t queries_processed() const noexcept
std::vector< std::string > supported_sop_classes() const override
Get the list of SOP Class UIDs supported by this service.
ups_query_scp(std::shared_ptr< di::ILogger > logger=nullptr)
Construct UPS Query SCP with optional logger.
std::atomic< size_t > queries_processed_
std::function< bool()> ups_query_cancel_check
Cancel check function type for UPS queries.
std::function< std::vector< core::dicom_dataset >( const core::dicom_dataset &query_keys, const std::string &calling_ae)> ups_query_handler
UPS query handler function type.
constexpr std::string_view ups_query_find_sop_class_uid
UPS Query Information Model - FIND SOP Class UID (PS3.4 Table CC.2-1)
Base class for DICOM SCP (Service Class Provider) services.