PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
remote_node.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
31#pragma once
32
33#include <chrono>
34#include <cstdint>
35#include <functional>
36#include <optional>
37#include <string>
38#include <string_view>
39
40namespace kcenon::pacs::client {
41
42// =============================================================================
43// Node Status
44// =============================================================================
45
51enum class node_status {
52 unknown,
53 online,
54 offline,
55 error,
57};
58
64[[nodiscard]] constexpr const char* to_string(node_status status) noexcept {
65 switch (status) {
66 case node_status::unknown: return "unknown";
67 case node_status::online: return "online";
68 case node_status::offline: return "offline";
69 case node_status::error: return "error";
70 case node_status::verifying: return "verifying";
71 default: return "unknown";
72 }
73}
74
80[[nodiscard]] inline node_status node_status_from_string(std::string_view str) noexcept {
81 if (str == "online") return node_status::online;
82 if (str == "offline") return node_status::offline;
83 if (str == "error") return node_status::error;
84 if (str == "verifying") return node_status::verifying;
86}
87
88// =============================================================================
89// TLS Configuration
90// =============================================================================
91
95struct tls_config {
96 std::string cert_path;
97 std::string key_path;
98 std::string ca_path;
99
104 [[nodiscard]] bool is_configured() const noexcept {
105 return !cert_path.empty();
106 }
107};
108
109// =============================================================================
110// Remote Node
111// =============================================================================
112
131 // =========================================================================
132 // Identification
133 // =========================================================================
134
135 std::string node_id;
136 std::string name;
137 std::string ae_title;
138 std::string host;
139 uint16_t port{104};
140
141 // =========================================================================
142 // Supported Services
143 // =========================================================================
144
145 bool supports_find{true};
146 bool supports_move{true};
147 bool supports_get{false};
148 bool supports_store{true};
149 bool supports_worklist{false};
150
151 // =========================================================================
152 // Connection Settings
153 // =========================================================================
154
155 std::chrono::seconds connection_timeout{30};
156 std::chrono::seconds dimse_timeout{60};
158
159 // =========================================================================
160 // TLS Settings (Optional)
161 // =========================================================================
162
163 std::optional<tls_config> tls;
164
165 // =========================================================================
166 // Runtime Status
167 // =========================================================================
168
170 std::chrono::system_clock::time_point last_verified;
171 std::chrono::system_clock::time_point last_error;
172 std::string last_error_message;
173
174 // =========================================================================
175 // Database Fields
176 // =========================================================================
177
178 int64_t pk{0};
179 std::chrono::system_clock::time_point created_at;
180 std::chrono::system_clock::time_point updated_at;
181
182 // =========================================================================
183 // Convenience Methods
184 // =========================================================================
185
189 [[nodiscard]] bool supports_query_retrieve() const noexcept {
191 }
192
196 [[nodiscard]] bool is_online() const noexcept {
197 return status == node_status::online;
198 }
199
203 [[nodiscard]] bool has_tls() const noexcept {
204 return tls.has_value() && tls->is_configured();
205 }
206
210 [[nodiscard]] std::string address() const {
211 return host + ":" + std::to_string(port);
212 }
213};
214
215// =============================================================================
216// Status Callback
217// =============================================================================
218
227using node_status_callback = std::function<void(std::string_view node_id, node_status status)>;
228
229// =============================================================================
230// Node Statistics
231// =============================================================================
232
243 std::chrono::milliseconds avg_response_time{0};
244 std::chrono::milliseconds min_response_time{0};
245 std::chrono::milliseconds max_response_time{0};
246 std::chrono::system_clock::time_point last_activity;
247};
248
249// =============================================================================
250// Node Manager Configuration
251// =============================================================================
252
258 std::chrono::seconds health_check_interval{60};
259
262
264 std::chrono::seconds pool_connection_ttl{300};
265
268
270 std::string local_ae_title{"PACS_CLIENT"};
271};
272
273} // namespace kcenon::pacs::client
node_status
Status of a remote PACS node.
Definition remote_node.h:51
@ verifying
Verification in progress.
@ offline
Node is not responding.
@ online
Node is responding to C-ECHO.
@ unknown
Status not yet determined.
@ error
Node returned an error.
node_status node_status_from_string(std::string_view str) noexcept
Parse node_status from string.
Definition remote_node.h:80
constexpr const char * to_string(job_type type) noexcept
Convert job_type to string representation.
Definition job_types.h:54
std::function< void(std::string_view node_id, node_status status)> node_status_callback
Callback function type for node status changes.
Configuration for the remote node manager.
size_t max_pool_connections_per_node
Maximum pooled connections per node.
std::string local_ae_title
Our AE Title for outgoing associations.
std::chrono::seconds health_check_interval
Interval between automatic health checks.
bool auto_start_health_check
Start health check automatically on construction.
std::chrono::seconds pool_connection_ttl
Time-to-live for pooled connections.
Statistics for a remote node.
std::chrono::milliseconds max_response_time
Maximum response time.
size_t active_connections
Currently active connections.
size_t total_connections
Total connections made.
size_t successful_operations
Successful DIMSE operations.
std::chrono::milliseconds min_response_time
Minimum response time.
std::chrono::milliseconds avg_response_time
Average response time.
std::chrono::system_clock::time_point last_activity
Last activity time.
size_t failed_operations
Failed DIMSE operations.
bool supports_store
C-STORE support (Send)
std::chrono::system_clock::time_point updated_at
Last update timestamp.
bool is_online() const noexcept
Check if node is currently reachable.
int64_t pk
Primary key (0 if not persisted)
node_status status
Current connectivity status.
std::optional< tls_config > tls
TLS configuration (if secure)
std::string ae_title
DICOM Application Entity Title.
std::string name
Human-readable display name.
uint16_t port
DICOM port (default: 104)
std::chrono::system_clock::time_point last_verified
Last successful verification.
std::string node_id
Unique identifier for this node.
bool supports_move
C-MOVE support (Retrieve)
std::chrono::system_clock::time_point last_error
Last error time.
size_t max_associations
Max concurrent associations.
bool supports_worklist
Modality Worklist support.
std::string last_error_message
Last error description.
bool supports_get
C-GET support (alternative retrieve)
std::string address() const
Get connection address string (host:port)
bool supports_find
C-FIND support (Query)
bool supports_query_retrieve() const noexcept
Check if node supports any query/retrieve operation.
bool has_tls() const noexcept
Check if TLS is enabled for this node.
std::chrono::seconds dimse_timeout
DIMSE operation timeout.
std::chrono::system_clock::time_point created_at
Creation timestamp.
std::string host
IP address or hostname.
std::chrono::seconds connection_timeout
TCP connection timeout.
TLS configuration for secure DICOM connections.
Definition remote_node.h:95
std::string ca_path
Path to CA certificate.
Definition remote_node.h:98
bool is_configured() const noexcept
Check if TLS is configured.
std::string cert_path
Path to client certificate.
Definition remote_node.h:96
std::string key_path
Path to private key.
Definition remote_node.h:97