PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
private_tag_registry.cpp
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
11
12namespace kcenon::pacs::core {
13
15 static private_tag_registry registry;
16 return registry;
17}
18
19auto private_tag_registry::register_tag(std::string_view creator_id,
20 const private_tag_definition& definition)
21 -> bool {
22 std::unique_lock lock(mutex_);
23 auto key = key_type{std::string{creator_id}, definition.element_offset};
24 auto [it, inserted] = definitions_.try_emplace(std::move(key), definition);
25 return inserted;
26}
27
29 std::string_view creator_id,
30 std::span<const private_tag_definition> definitions) -> size_t {
31 std::unique_lock lock(mutex_);
32 size_t count = 0;
33
34 for (const auto& def : definitions) {
35 auto key = key_type{std::string{creator_id}, def.element_offset};
36 auto [it, inserted] = definitions_.try_emplace(std::move(key), def);
37 if (inserted) {
38 ++count;
39 }
40 }
41
42 return count;
43}
44
45auto private_tag_registry::find(std::string_view creator_id,
46 uint8_t element_offset) const
47 -> std::optional<private_tag_definition> {
48 std::shared_lock lock(mutex_);
49 auto key = key_type{std::string{creator_id}, element_offset};
50 auto it = definitions_.find(key);
51 if (it == definitions_.end()) {
52 return std::nullopt;
53 }
54 return it->second;
55}
56
57auto private_tag_registry::size() const -> size_t {
58 std::shared_lock lock(mutex_);
59 return definitions_.size();
60}
61
63 std::unique_lock lock(mutex_);
64 definitions_.clear();
65}
66
67} // namespace kcenon::pacs::core
std::map< key_type, private_tag_definition > definitions_
Storage for registered definitions.
auto register_vendor(std::string_view creator_id, std::span< const private_tag_definition > definitions) -> size_t
Register a complete vendor dictionary (batch registration)
void clear()
Clear all registered definitions.
auto find(std::string_view creator_id, uint8_t element_offset) const -> std::optional< private_tag_definition >
Look up a private tag definition by creator ID and element offset.
auto register_tag(std::string_view creator_id, const private_tag_definition &definition) -> bool
Register a single vendor-specific private tag definition.
static auto instance() -> private_tag_registry &
Get the singleton instance.
auto size() const -> size_t
Get the number of registered definitions.
std::pair< std::string, uint8_t > key_type
Key type: (creator_id, element_offset)
std::shared_mutex mutex_
Mutex for thread-safe access.
Registry of vendor-specific private tag definitions.
Definition of a vendor-specific private tag.