PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
command_field.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_NETWORK_DIMSE_COMMAND_FIELD_HPP
19#define PACS_NETWORK_DIMSE_COMMAND_FIELD_HPP
20
21#include <cstdint>
22#include <string_view>
23
25
35enum class command_field : uint16_t {
36 // ========================================================================
37 // DIMSE-C Commands (Composite SOP Classes)
38 // ========================================================================
39
41 c_store_rq = 0x0001,
43 c_store_rsp = 0x8001,
44
46 c_get_rq = 0x0010,
48 c_get_rsp = 0x8010,
49
51 c_find_rq = 0x0020,
53 c_find_rsp = 0x8020,
54
56 c_move_rq = 0x0021,
58 c_move_rsp = 0x8021,
59
61 c_echo_rq = 0x0030,
63 c_echo_rsp = 0x8030,
64
66 c_cancel_rq = 0x0FFF,
67
68 // ========================================================================
69 // DIMSE-N Commands (Normalized SOP Classes)
70 // ========================================================================
71
73 n_event_report_rq = 0x0100,
75 n_event_report_rsp = 0x8100,
76
78 n_get_rq = 0x0110,
80 n_get_rsp = 0x8110,
81
83 n_set_rq = 0x0120,
85 n_set_rsp = 0x8120,
86
88 n_action_rq = 0x0130,
90 n_action_rsp = 0x8130,
91
93 n_create_rq = 0x0140,
95 n_create_rsp = 0x8140,
96
98 n_delete_rq = 0x0150,
100 n_delete_rsp = 0x8150,
101};
102
105
111[[nodiscard]] constexpr bool is_request(command_field cmd) noexcept {
112 return (static_cast<uint16_t>(cmd) & 0x8000) == 0;
113}
114
120[[nodiscard]] constexpr bool is_response(command_field cmd) noexcept {
121 return (static_cast<uint16_t>(cmd) & 0x8000) != 0;
122}
123
129[[nodiscard]] constexpr bool is_dimse_c(command_field cmd) noexcept {
130 // Remove response bit (0x8000) and check range
131 const auto value = static_cast<uint16_t>(cmd) & 0x7FFF;
132 return value <= 0x0030 || value == 0x0FFF;
133}
134
140[[nodiscard]] constexpr bool is_dimse_n(command_field cmd) noexcept {
141 // Remove response bit (0x8000) and check range
142 const auto value = static_cast<uint16_t>(cmd) & 0x7FFF;
143 return value >= 0x0100 && value <= 0x0150;
144}
145
152[[nodiscard]] constexpr command_field get_response_command(
153 command_field request) noexcept {
154 return static_cast<command_field>(static_cast<uint16_t>(request) | 0x8000);
155}
156
162[[nodiscard]] constexpr command_field get_request_command(
163 command_field response) noexcept {
164 return static_cast<command_field>(static_cast<uint16_t>(response) & 0x7FFF);
165}
166
172[[nodiscard]] constexpr std::string_view to_string(command_field cmd) noexcept {
173 switch (cmd) {
174 case command_field::c_store_rq: return "C-STORE-RQ";
175 case command_field::c_store_rsp: return "C-STORE-RSP";
176 case command_field::c_get_rq: return "C-GET-RQ";
177 case command_field::c_get_rsp: return "C-GET-RSP";
178 case command_field::c_find_rq: return "C-FIND-RQ";
179 case command_field::c_find_rsp: return "C-FIND-RSP";
180 case command_field::c_move_rq: return "C-MOVE-RQ";
181 case command_field::c_move_rsp: return "C-MOVE-RSP";
182 case command_field::c_echo_rq: return "C-ECHO-RQ";
183 case command_field::c_echo_rsp: return "C-ECHO-RSP";
184 case command_field::c_cancel_rq: return "C-CANCEL-RQ";
185 case command_field::n_event_report_rq: return "N-EVENT-REPORT-RQ";
186 case command_field::n_event_report_rsp: return "N-EVENT-REPORT-RSP";
187 case command_field::n_get_rq: return "N-GET-RQ";
188 case command_field::n_get_rsp: return "N-GET-RSP";
189 case command_field::n_set_rq: return "N-SET-RQ";
190 case command_field::n_set_rsp: return "N-SET-RSP";
191 case command_field::n_action_rq: return "N-ACTION-RQ";
192 case command_field::n_action_rsp: return "N-ACTION-RSP";
193 case command_field::n_create_rq: return "N-CREATE-RQ";
194 case command_field::n_create_rsp: return "N-CREATE-RSP";
195 case command_field::n_delete_rq: return "N-DELETE-RQ";
196 case command_field::n_delete_rsp: return "N-DELETE-RSP";
197 default: return "UNKNOWN";
198 }
199}
200
202
203} // namespace kcenon::pacs::network::dimse
204
205#endif // PACS_NETWORK_DIMSE_COMMAND_FIELD_HPP
constexpr bool is_dimse_c(command_field cmd) noexcept
Check if a command is a DIMSE-C command.
constexpr std::string_view to_string(command_field cmd) noexcept
Convert command field to string representation.
constexpr bool is_response(command_field cmd) noexcept
Check if a command field represents a response.
constexpr bool is_dimse_n(command_field cmd) noexcept
Check if a command is a DIMSE-N command.
constexpr command_field get_request_command(command_field response) noexcept
Get the corresponding request command for a response.
constexpr bool is_request(command_field cmd) noexcept
Check if a command field represents a request.
constexpr command_field get_response_command(command_field request) noexcept
Get the corresponding response command for a request.
command_field
DIMSE command field values.
@ n_get_rq
N-GET Request - Get attribute values.
@ c_cancel_rq
C-CANCEL Request - Cancel pending operation.
@ c_store_rq
C-STORE Request - Store composite SOP instance.
@ n_create_rq
N-CREATE Request - Create SOP instance.
@ n_set_rq
N-SET Request - Set attribute values.
@ c_echo_rq
C-ECHO Request - Verify DICOM connection.
@ c_find_rq
C-FIND Request - Query for matching instances.
@ n_delete_rq
N-DELETE Request - Delete SOP instance.
@ n_event_report_rsp
N-EVENT-REPORT Response.
@ n_event_report_rq
N-EVENT-REPORT Request - Report event notification.
@ c_get_rq
C-GET Request - Retrieve composite SOP instances.
@ c_move_rq
C-MOVE Request - Move composite SOP instances.
@ n_action_rq
N-ACTION Request - Request action.