PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::services::n_get_scp Class Referencefinal

#include <n_get_scp.h>

Inheritance diagram for kcenon::pacs::services::n_get_scp:
Inheritance graph
Collaboration diagram for kcenon::pacs::services::n_get_scp:
Collaboration graph

Public Member Functions

 n_get_scp (std::shared_ptr< di::ILogger > logger=nullptr)
 Construct N-GET SCP with optional logger.
 
 ~n_get_scp () override=default
 
void set_handler (n_get_handler handler)
 Set the N-GET handler function.
 
void add_supported_sop_class (std::string sop_class_uid)
 Add a SOP Class UID that this SCP supports.
 
std::vector< std::string > supported_sop_classes () const override
 Get supported SOP Class UIDs.
 
network::Result< std::monostate > handle_message (network::association &assoc, uint8_t context_id, const network::dimse::dimse_message &request) override
 Handle an incoming N-GET-RQ message.
 
std::string_view service_name () const noexcept override
 Get the service name.
 
size_t gets_processed () const noexcept
 Get total number of N-GET requests processed.
 
void reset_statistics () noexcept
 Reset statistics counters.
 
- Public Member Functions inherited from kcenon::pacs::services::scp_service
 scp_service (std::shared_ptr< di::ILogger > logger=nullptr)
 Construct SCP service with optional logger.
 
virtual ~scp_service ()=default
 
 scp_service (const scp_service &)=delete
 
scp_serviceoperator= (const scp_service &)=delete
 
 scp_service (scp_service &&)=default
 
scp_serviceoperator= (scp_service &&)=default
 
void set_logger (std::shared_ptr< di::ILogger > logger)
 Set the logger instance.
 
const std::shared_ptr< di::ILogger > & logger () const noexcept
 Get the current logger instance.
 
bool supports_sop_class (std::string_view sop_class_uid) const
 Check if this service supports a specific SOP Class.
 

Private Member Functions

network::Result< std::monostate > send_n_get_response (network::association &assoc, uint8_t context_id, uint16_t message_id, const std::string &sop_class_uid, const std::string &sop_instance_uid, network::dimse::status_code status, core::dicom_dataset *dataset=nullptr)
 Send N-GET response.
 

Private Attributes

n_get_handler handler_
 
std::vector< std::string > supported_sop_classes_
 
std::atomic< size_t > gets_processed_ {0}
 

Additional Inherited Members

- Protected Attributes inherited from kcenon::pacs::services::scp_service
std::shared_ptr< di::ILoggerlogger_
 Logger instance for service logging.
 

Detailed Description

Definition at line 105 of file n_get_scp.h.

Constructor & Destructor Documentation

◆ n_get_scp()

kcenon::pacs::services::n_get_scp::n_get_scp ( std::shared_ptr< di::ILogger > logger = nullptr)
explicit

Construct N-GET SCP with optional logger.

Parameters
loggerLogger instance (nullptr uses null_logger)

Definition at line 25 of file n_get_scp.cpp.

26 : scp_service(std::move(logger)) {}
const std::shared_ptr< di::ILogger > & logger() const noexcept
Get the current logger instance.
Definition scp_service.h:93
scp_service(std::shared_ptr< di::ILogger > logger=nullptr)
Construct SCP service with optional logger.
Definition scp_service.h:64

◆ ~n_get_scp()

kcenon::pacs::services::n_get_scp::~n_get_scp ( )
overridedefault

Member Function Documentation

◆ add_supported_sop_class()

void kcenon::pacs::services::n_get_scp::add_supported_sop_class ( std::string sop_class_uid)

Add a SOP Class UID that this SCP supports.

N-GET can be used with multiple SOP Classes (e.g., MPPS, Printer). By default, no SOP Classes are registered. Call this method to add supported SOP Classes.

Parameters
sop_class_uidThe SOP Class UID to support

Definition at line 36 of file n_get_scp.cpp.

36 {
37 supported_sop_classes_.push_back(std::move(sop_class_uid));
38}
std::vector< std::string > supported_sop_classes_
Definition n_get_scp.h:212

References supported_sop_classes_.

◆ gets_processed()

size_t kcenon::pacs::services::n_get_scp::gets_processed ( ) const
nodiscardnoexcept

Get total number of N-GET requests processed.

Definition at line 131 of file n_get_scp.cpp.

131 {
132 return gets_processed_.load();
133}
std::atomic< size_t > gets_processed_
Definition n_get_scp.h:214

References gets_processed_.

◆ handle_message()

network::Result< std::monostate > kcenon::pacs::services::n_get_scp::handle_message ( network::association & assoc,
uint8_t context_id,
const network::dimse::dimse_message & request )
nodiscardoverridevirtual

Handle an incoming N-GET-RQ message.

Parameters
assocThe association on which the message was received
context_idThe presentation context ID
requestThe incoming N-GET-RQ message
Returns
Success or error

Implements kcenon::pacs::services::scp_service.

Definition at line 48 of file n_get_scp.cpp.

51 {
52
53 using namespace network::dimse;
54
55 // Verify command type is N-GET-RQ
56 if (request.command() != command_field::n_get_rq) {
59 "Unexpected command for N-GET SCP: " +
60 std::string(to_string(request.command())));
61 }
62
63 // Verify we have a handler configured
64 if (!handler_) {
67 "No N-GET handler configured");
68 }
69
70 // Extract Requested SOP Class UID
71 auto sop_class_uid = request.requested_sop_class_uid();
72 if (sop_class_uid.empty()) {
74 assoc, context_id, request.message_id(),
75 "", "", status_error_missing_attribute);
76 }
77
78 // Verify the SOP Class is supported
79 if (!supports_sop_class(sop_class_uid)) {
81 assoc, context_id, request.message_id(),
82 sop_class_uid, "", status_refused_sop_class_not_supported);
83 }
84
85 // Extract Requested SOP Instance UID
86 auto sop_instance_uid = request.requested_sop_instance_uid();
87 if (sop_instance_uid.empty()) {
89 assoc, context_id, request.message_id(),
90 sop_class_uid, "", status_error_missing_attribute);
91 }
92
93 // Extract Attribute Identifier List (empty = all attributes)
94 auto attribute_tags = request.attribute_identifier_list();
95
96 logger_->debug("N-GET request for instance: " + sop_instance_uid +
97 " (attributes requested: " +
98 (attribute_tags.empty() ? "all" :
99 std::to_string(attribute_tags.size())) + ")");
100
101 // Call the handler to retrieve attributes
102 auto result = handler_(sop_class_uid, sop_instance_uid, attribute_tags);
103 if (result.is_err()) {
104 logger_->warn("N-GET handler failed for instance: " + sop_instance_uid +
105 " - " + result.error().message);
106 return send_n_get_response(
107 assoc, context_id, request.message_id(),
108 sop_class_uid, sop_instance_uid,
109 status_error_invalid_object_instance);
110 }
111
112 // Update statistics
114
115 // Send success response with dataset
116 auto dataset = std::move(result.value());
117 return send_n_get_response(
118 assoc, context_id, request.message_id(),
119 sop_class_uid, sop_instance_uid,
120 status_success, &dataset);
121}
network::Result< std::monostate > send_n_get_response(network::association &assoc, uint8_t context_id, uint16_t message_id, const std::string &sop_class_uid, const std::string &sop_instance_uid, network::dimse::status_code status, core::dicom_dataset *dataset=nullptr)
Send N-GET response.
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.
constexpr dicom_tag sop_instance_uid
SOP Instance UID.
constexpr dicom_tag sop_class_uid
SOP Class UID.
constexpr int n_get_handler_not_set
Definition result.h:190
constexpr int n_get_unexpected_command
Definition result.h:191
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
Definition mpps_scp.h:60
VoidResult pacs_void_error(int code, const std::string &message, const std::string &details="")
Create a PACS void error result.
Definition result.h:249

References kcenon::pacs::network::dimse::dimse_message::attribute_identifier_list(), kcenon::pacs::network::dimse::dimse_message::command(), gets_processed_, handler_, kcenon::pacs::services::scp_service::logger_, kcenon::pacs::network::dimse::dimse_message::message_id(), kcenon::pacs::error_codes::n_get_handler_not_set, kcenon::pacs::error_codes::n_get_unexpected_command, kcenon::pacs::pacs_void_error(), kcenon::pacs::network::dimse::dimse_message::requested_sop_class_uid(), kcenon::pacs::network::dimse::dimse_message::requested_sop_instance_uid(), send_n_get_response(), kcenon::pacs::services::scp_service::supports_sop_class(), and kcenon::pacs::services::to_string().

Here is the call graph for this function:

◆ reset_statistics()

void kcenon::pacs::services::n_get_scp::reset_statistics ( )
noexcept

Reset statistics counters.

Definition at line 135 of file n_get_scp.cpp.

135 {
136 gets_processed_ = 0;
137}

References gets_processed_.

◆ send_n_get_response()

network::Result< std::monostate > kcenon::pacs::services::n_get_scp::send_n_get_response ( network::association & assoc,
uint8_t context_id,
uint16_t message_id,
const std::string & sop_class_uid,
const std::string & sop_instance_uid,
network::dimse::status_code status,
core::dicom_dataset * dataset = nullptr )
nodiscardprivate

Send N-GET response.

Definition at line 143 of file n_get_scp.cpp.

150 {
151
152 using namespace network::dimse;
153
154 // Create N-GET response using factory function
155 auto response = make_n_get_rsp(
156 message_id, sop_class_uid, sop_instance_uid, status);
157
158 // Attach dataset if provided (successful responses include attributes)
159 if (dataset != nullptr) {
160 response.set_dataset(std::move(*dataset));
161 }
162
163 // Send the response
164 return assoc.send_dimse(context_id, response);
165}

References kcenon::pacs::network::association::send_dimse().

Referenced by handle_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ service_name()

std::string_view kcenon::pacs::services::n_get_scp::service_name ( ) const
nodiscardoverridevirtualnoexcept

Get the service name.

Returns
"N-GET SCP"

Implements kcenon::pacs::services::scp_service.

Definition at line 123 of file n_get_scp.cpp.

123 {
124 return "N-GET SCP";
125}

◆ set_handler()

void kcenon::pacs::services::n_get_scp::set_handler ( n_get_handler handler)

Set the N-GET handler function.

The handler is called for each N-GET request to retrieve attributes from a managed SOP Instance.

Parameters
handlerThe N-GET handler function

Definition at line 32 of file n_get_scp.cpp.

32 {
33 handler_ = std::move(handler);
34}

References handler_.

◆ supported_sop_classes()

std::vector< std::string > kcenon::pacs::services::n_get_scp::supported_sop_classes ( ) const
nodiscardoverridevirtual

Get supported SOP Class UIDs.

Returns
Vector of registered SOP Class UIDs

Implements kcenon::pacs::services::scp_service.

Definition at line 44 of file n_get_scp.cpp.

44 {
46}

References supported_sop_classes_.

Member Data Documentation

◆ gets_processed_

std::atomic<size_t> kcenon::pacs::services::n_get_scp::gets_processed_ {0}
private

Definition at line 214 of file n_get_scp.h.

214{0};

Referenced by gets_processed(), handle_message(), and reset_statistics().

◆ handler_

n_get_handler kcenon::pacs::services::n_get_scp::handler_
private

Definition at line 211 of file n_get_scp.h.

Referenced by handle_message(), and set_handler().

◆ supported_sop_classes_

std::vector<std::string> kcenon::pacs::services::n_get_scp::supported_sop_classes_
private

Definition at line 212 of file n_get_scp.h.

Referenced by add_supported_sop_class(), and supported_sop_classes().


The documentation for this class was generated from the following files: