PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
scp_service.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_SCP_SERVICE_HPP
19#define PACS_SERVICES_SCP_SERVICE_HPP
20
24
25#include <memory>
26#include <string>
27#include <string_view>
28#include <vector>
29
30namespace kcenon::pacs::services {
31
54public:
55 // =========================================================================
56 // Construction / Destruction
57 // =========================================================================
58
64 explicit scp_service(std::shared_ptr<di::ILogger> logger = nullptr)
65 : logger_(logger ? std::move(logger) : di::null_logger()) {}
66
67 virtual ~scp_service() = default;
68
69 // Non-copyable but movable
70 scp_service(const scp_service&) = delete;
74
75 // =========================================================================
76 // Logger Access
77 // =========================================================================
78
84 void set_logger(std::shared_ptr<di::ILogger> logger) {
85 logger_ = logger ? std::move(logger) : di::null_logger();
86 }
87
93 [[nodiscard]] const std::shared_ptr<di::ILogger>& logger() const noexcept {
94 return logger_;
95 }
96
97 // =========================================================================
98 // Service Interface
99 // =========================================================================
100
106 [[nodiscard]] virtual std::vector<std::string> supported_sop_classes() const = 0;
107
120 uint8_t context_id,
121 const network::dimse::dimse_message& request) = 0;
122
123 // =========================================================================
124 // Service Information
125 // =========================================================================
126
132 [[nodiscard]] virtual std::string_view service_name() const noexcept = 0;
133
140 [[nodiscard]] bool supports_sop_class(std::string_view sop_class_uid) const {
141 const auto classes = supported_sop_classes();
142 for (const auto& uid : classes) {
143 if (uid == sop_class_uid) {
144 return true;
145 }
146 }
147 return false;
148 }
149
150protected:
151 // =========================================================================
152 // Protected Members
153 // =========================================================================
154
156 std::shared_ptr<di::ILogger> logger_;
157};
158
162using scp_service_ptr = std::shared_ptr<scp_service>;
163
164} // namespace kcenon::pacs::services
165
166#endif // PACS_SERVICES_SCP_SERVICE_HPP
DICOM Association management per PS3.8.
virtual network::Result< std::monostate > handle_message(network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request)=0
Handle an incoming DIMSE message.
scp_service(const scp_service &)=delete
scp_service(scp_service &&)=default
const std::shared_ptr< di::ILogger > & logger() const noexcept
Get the current logger instance.
Definition scp_service.h:93
void set_logger(std::shared_ptr< di::ILogger > logger)
Set the logger instance.
Definition scp_service.h:84
scp_service & operator=(scp_service &&)=default
bool supports_sop_class(std::string_view sop_class_uid) const
Check if this service supports a specific SOP Class.
std::shared_ptr< di::ILogger > logger_
Logger instance for service logging.
scp_service(std::shared_ptr< di::ILogger > logger=nullptr)
Construct SCP service with optional logger.
Definition scp_service.h:64
scp_service & operator=(const scp_service &)=delete
virtual std::string_view service_name() const noexcept=0
Get the service name for logging/debugging.
virtual std::vector< std::string > supported_sop_classes() const =0
Get the list of SOP Class UIDs supported by this service.
DIMSE message encoding and decoding.
Logger interface for dependency injection.
std::shared_ptr< ILogger > null_logger()
Get a shared null logger instance.
Definition ilogger.h:271
std::shared_ptr< scp_service > scp_service_ptr
Shared pointer type for SCP services.
std::string_view uid