21#ifndef PACS_NETWORK_V2_DICOM_SERVER_V2_HPP
22#define PACS_NETWORK_V2_DICOM_SERVER_V2_HPP
31#include <condition_variable>
38#include <unordered_map>
43class i_protocol_server;
122 using clock = std::chrono::steady_clock;
128 std::function<void(
const std::string& session_id,
129 const std::string& calling_ae,
130 const std::string& called_ae)>;
134 std::function<void(
const std::string& session_id,
bool graceful)>;
221 [[nodiscard]]
bool is_running() const noexcept;
282 [[nodiscard]] std::shared_ptr<security::access_control_manager>
310 const std::vector<uint8_t>& data);
Bridges network_system sessions with DICOM protocol handling.
DICOM server using network_system's messaging_server for connection management.
void on_network_error(std::string_view session_id, std::error_code ec)
Handle network error.
server_config config_
Server configuration.
std::mutex acl_mutex_
Access control mutex.
void report_error(const std::string &error)
Report error through callback.
dicom_server_v2(const server_config &config)
Construct server with configuration.
std::atomic< bool > running_
Running flag.
server_statistics get_statistics() const
Get server statistics.
std::vector< services::scp_service_ptr > services_
Registered SCP services.
void on_error(error_callback callback)
Set callback for error events.
association_closed_callback on_closed_cb_
Association closed callback.
const server_config & config() const noexcept
Get server configuration.
std::shared_ptr< security::access_control_manager > access_control_
Access control manager for RBAC.
void create_handler(std::shared_ptr< kcenon::network::interfaces::i_session > session)
Create and register a new handler for a session.
std::unordered_map< std::string, std::shared_ptr< dicom_association_handler > > handlers_
Active association handlers (keyed by session ID)
void on_receive(std::string_view session_id, const std::vector< uint8_t > &data)
Handle receive data (forwarded to handler)
dicom_server_v2(dicom_server_v2 &&)=delete
std::shared_ptr< kcenon::network::interfaces::i_protocol_server > server_
network_system's protocol server (via tcp_facade)
bool is_running() const noexcept
Check if server is running.
void register_service(services::scp_service_ptr service)
Register an SCP service.
dicom_server_v2 & operator=(const dicom_server_v2 &)=delete
dicom_association_handler::service_map build_service_map() const
Build service map from registered services.
void on_association_established(association_established_callback callback)
Set callback for association established events.
std::mutex stats_mutex_
Statistics mutex.
std::function< void(const std::string &session_id, bool graceful)> association_closed_callback
Callback type for association closed events.
association_established_callback on_established_cb_
Association established callback.
void wait_for_shutdown()
Wait for server shutdown.
std::mutex services_mutex_
Service mutex (protects services_ and sop_class_to_service_)
void check_idle_timeouts()
Check for idle timeouts on handlers.
std::map< std::string, services::scp_service * > sop_class_to_service_
Map from SOP Class UID to service (non-owning pointers)
std::function< void(const std::string &session_id, const std::string &calling_ae, const std::string &called_ae)> association_established_callback
Callback type for association established events.
~dicom_server_v2()
Destructor (stops server if running)
std::function< void(const std::string &error)> error_callback
Callback type for error events.
std::shared_ptr< dicom_association_handler > find_handler(const std::string &session_id) const
Find handler by session ID.
void remove_handler(const std::string &session_id)
Remove handler by session ID.
std::mutex callback_mutex_
Callback mutex.
void on_association_closed(association_closed_callback callback)
Set callback for association closed events.
void set_access_control(std::shared_ptr< security::access_control_manager > acm)
Set the access control manager for RBAC.
dicom_server_v2(const dicom_server_v2 &)=delete
error_callback on_error_cb_
Error callback.
void stop(duration timeout=std::chrono::seconds{30})
Stop the server gracefully.
size_t active_associations() const noexcept
Get number of active associations.
std::mutex handlers_mutex_
Handler mutex (protects handlers_ map)
bool is_access_control_enabled() const noexcept
Check if access control is enabled.
void on_disconnection(std::string_view session_id)
Handle disconnection notification.
std::chrono::steady_clock clock
Result< std::monostate > start()
Start the server.
void set_access_control_enabled(bool enabled)
Enable or disable access control enforcement.
std::mutex shutdown_mutex_
Shutdown mutex.
clock::time_point time_point
dicom_server_v2 & operator=(dicom_server_v2 &&)=delete
std::atomic< bool > access_control_enabled_
Whether access control is enabled.
std::chrono::milliseconds duration
std::vector< std::string > supported_sop_classes() const
Get list of supported SOP Class UIDs.
std::shared_ptr< security::access_control_manager > get_access_control() const noexcept
Get the access control manager.
void on_connection(std::shared_ptr< kcenon::network::interfaces::i_session > session)
Handle new connection from server.
server_statistics stats_
Server statistics.
std::condition_variable shutdown_cv_
Shutdown condition variable.
DICOM association handler for network_system integration.
std::function< void(const std::string &session_id, bool graceful)> association_closed_callback
Callback type for association closed events.
std::function< void(const std::string &session_id, const std::string &calling_ae, const std::string &called_ae)> association_established_callback
Callback type for association established events.
std::shared_ptr< scp_service > scp_service_ptr
Shared pointer type for SCP services.
Base class for DICOM SCP (Service Class Provider) services.
DICOM Server configuration structures.
Statistics for server monitoring.