PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
storage_status.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_STORAGE_STATUS_HPP
19#define PACS_SERVICES_STORAGE_STATUS_HPP
20
21#include <cstdint>
22#include <string_view>
23
24namespace kcenon::pacs::services {
25
33enum class storage_status : uint16_t {
35 success = 0x0000,
36
39
42
44 elements_discarded = 0xB006,
45
48
50 out_of_resources = 0xA700,
51
54
57
59 cannot_understand = 0xC000,
60
62 storage_error = 0xC001
63};
64
70[[nodiscard]] constexpr bool is_success(storage_status status) noexcept {
71 return status == storage_status::success;
72}
73
79[[nodiscard]] constexpr bool is_warning(storage_status status) noexcept {
80 const auto value = static_cast<uint16_t>(status);
81 return (value & 0xF000) == 0xB000;
82}
83
89[[nodiscard]] constexpr bool is_failure(storage_status status) noexcept {
90 const auto value = static_cast<uint16_t>(status);
91 const auto high_nibble = (value & 0xF000) >> 12;
92 return high_nibble == 0xA || high_nibble == 0xC ||
93 (value >= 0x0100 && value <= 0x01FF);
94}
95
101[[nodiscard]] constexpr std::string_view to_string(storage_status status) noexcept {
102 switch (status) {
104 return "Success";
106 return "Warning: Coercion of data elements";
108 return "Warning: Data set does not match SOP class";
110 return "Warning: Elements discarded";
112 return "Failure: Duplicate SOP instance";
114 return "Failure: Out of resources";
116 return "Failure: Out of resources - Unable to store";
118 return "Failure: Data set does not match SOP class";
120 return "Failure: Cannot understand";
122 return "Failure: Storage error";
123 default:
124 return "Unknown status";
125 }
126}
127
133[[nodiscard]] constexpr uint16_t to_status_code(storage_status status) noexcept {
134 return static_cast<uint16_t>(status);
135}
136
137} // namespace kcenon::pacs::services
138
139#endif // PACS_SERVICES_STORAGE_STATUS_HPP
constexpr bool is_failure(storage_status status) noexcept
Check if the status indicates a failure.
constexpr bool is_success(storage_status status) noexcept
Check if the status indicates success.
storage_status
Storage operation status codes.
@ elements_discarded
Warning: Elements discarded (0xB006)
@ storage_error
Failure: Unable to process - storage error (0xC001)
@ data_set_does_not_match_sop_class
Failure: Data set does not match SOP class (0xA900)
@ data_set_does_not_match_sop_class_warning
Warning: Data set does not match SOP class (0xB007)
@ success
Success - image stored successfully (0x0000)
@ out_of_resources
Failure: Out of resources (0xA700)
@ cannot_understand
Failure: Cannot understand - processing failure (0xC000)
@ duplicate_sop_instance
Failure: Duplicate SOP instance - already exists (0x0111)
@ out_of_resources_unable_to_store
Failure: Out of resources - Unable to store (0xA701)
@ coercion_of_data_elements
Warning: Coercion of data elements (0xB000)
constexpr bool is_warning(storage_status status) noexcept
Check if the status indicates a warning.
auto to_string(mpps_status status) -> std::string_view
Convert mpps_status to DICOM string representation.
Definition mpps_scp.h:60
constexpr uint16_t to_status_code(storage_status status) noexcept
Convert storage_status to DIMSE status_code.