PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
dicom_dictionary.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
19#pragma once
20
21#include "dicom_tag.h"
22#include "tag_info.h"
23
24#include <mutex>
25#include <optional>
26#include <shared_mutex>
27#include <span>
28#include <string_view>
29#include <unordered_map>
30#include <vector>
31
32namespace kcenon::pacs::core {
33
66public:
73 [[nodiscard]] static auto instance() -> dicom_dictionary&;
74
75 // Non-copyable and non-movable (singleton)
78 auto operator=(const dicom_dictionary&) -> dicom_dictionary& = delete;
80
89 [[nodiscard]] auto find(dicom_tag tag) const -> std::optional<tag_info>;
90
99 [[nodiscard]] auto find_by_keyword(std::string_view keyword) const
100 -> std::optional<tag_info>;
101
107 [[nodiscard]] auto contains(dicom_tag tag) const -> bool;
108
114 [[nodiscard]] auto contains_keyword(std::string_view keyword) const -> bool;
115
122 [[nodiscard]] auto validate_vm(dicom_tag tag, uint32_t count) const -> bool;
123
129 [[nodiscard]] auto get_vr(dicom_tag tag) const -> uint16_t;
130
139 auto register_private_tag(const tag_info& info) -> bool;
140
145 [[nodiscard]] auto size() const -> size_t;
146
151 [[nodiscard]] auto standard_tag_count() const -> size_t;
152
157 [[nodiscard]] auto private_tag_count() const -> size_t;
158
164 [[nodiscard]] auto get_tags_in_group(uint16_t group) const
165 -> std::vector<tag_info>;
166
167private:
172
177
179 std::unordered_map<dicom_tag, tag_info> tag_map_;
180
182 std::unordered_map<std::string_view, dicom_tag> keyword_map_;
183
186
188 mutable std::shared_mutex mutex_;
189};
190
191} // namespace kcenon::pacs::core
192
std::unordered_map< std::string_view, dicom_tag > keyword_map_
Hash map for O(1) lookup by keyword.
auto find_by_keyword(std::string_view keyword) const -> std::optional< tag_info >
Find tag metadata by keyword.
auto operator=(dicom_dictionary &&) -> dicom_dictionary &=delete
auto operator=(const dicom_dictionary &) -> dicom_dictionary &=delete
std::shared_mutex mutex_
Mutex for thread-safe private tag registration.
auto get_tags_in_group(uint16_t group) const -> std::vector< tag_info >
Get all tags in a specific group.
auto contains(dicom_tag tag) const -> bool
Check if a tag exists in the dictionary.
dicom_dictionary(dicom_dictionary &&)=delete
auto find(dicom_tag tag) const -> std::optional< tag_info >
Find tag metadata by DICOM tag.
void initialize_standard_tags()
Initialize the dictionary with standard PS3.6 tags.
dicom_dictionary(const dicom_dictionary &)=delete
auto size() const -> size_t
Get the total number of tags in the dictionary.
static auto instance() -> dicom_dictionary &
Get the singleton instance.
auto get_vr(dicom_tag tag) const -> uint16_t
Get the VR type for a tag.
auto validate_vm(dicom_tag tag, uint32_t count) const -> bool
Validate that a value count is valid for a tag's VM.
size_t standard_count_
Count of standard tags (vs private)
std::unordered_map< dicom_tag, tag_info > tag_map_
Hash map for O(1) lookup by tag.
auto register_private_tag(const tag_info &info) -> bool
Register a private tag at runtime.
auto private_tag_count() const -> size_t
Get the number of registered private tags.
auto contains_keyword(std::string_view keyword) const -> bool
Check if a keyword exists in the dictionary.
auto standard_tag_count() const -> size_t
Get the number of standard (non-private) tags.
DICOM Tag representation (Group, Element pairs)
DICOM tag metadata information structure.