PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::dcm_modify::uid_mapper Class Reference

UID mapping for consistent anonymization across related instances. More...

#include <anonymizer.h>

Collaboration diagram for kcenon::pacs::dcm_modify::uid_mapper:
Collaboration graph

Public Member Functions

std::string map (const std::string &original_uid)
 Get or create a replacement UID for the original UID.
 
void clear ()
 Clear all mappings.
 

Private Member Functions

std::string generate_uid ()
 

Private Attributes

std::map< std::string, std::string > mapping_
 

Static Private Attributes

static constexpr const char * uid_root_ = "1.2.826.0.1.3680043.8.1055.2"
 

Detailed Description

UID mapping for consistent anonymization across related instances.

Definition at line 31 of file anonymizer.h.

Member Function Documentation

◆ clear()

void kcenon::pacs::dcm_modify::uid_mapper::clear ( )
inline

Clear all mappings.

Definition at line 52 of file anonymizer.h.

52 {
53 mapping_.clear();
54 }
std::map< std::string, std::string > mapping_
Definition anonymizer.h:67

References mapping_.

◆ generate_uid()

std::string kcenon::pacs::dcm_modify::uid_mapper::generate_uid ( )
inlineprivate

Definition at line 57 of file anonymizer.h.

57 {
58 static std::atomic<uint64_t> counter{0};
59 auto now = std::chrono::system_clock::now();
60 auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(
61 now.time_since_epoch()).count();
62
63 return std::string(uid_root_) + "." + std::to_string(timestamp) + "." +
64 std::to_string(++counter);
65 }
static constexpr const char * uid_root_
Definition anonymizer.h:68
@ counter
Monotonic increasing value.

References uid_root_.

Referenced by map().

Here is the caller graph for this function:

◆ map()

std::string kcenon::pacs::dcm_modify::uid_mapper::map ( const std::string & original_uid)
inline

Get or create a replacement UID for the original UID.

Parameters
original_uidThe original UID to map
Returns
The replacement UID (consistent for same original)

Definition at line 38 of file anonymizer.h.

38 {
39 auto it = mapping_.find(original_uid);
40 if (it != mapping_.end()) {
41 return it->second;
42 }
43
44 auto new_uid = generate_uid();
45 mapping_[original_uid] = new_uid;
46 return new_uid;
47 }

References generate_uid(), and mapping_.

Referenced by kcenon::pacs::dcm_modify::anonymizer::anonymize_uids().

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

Member Data Documentation

◆ mapping_

std::map<std::string, std::string> kcenon::pacs::dcm_modify::uid_mapper::mapping_
private

Definition at line 67 of file anonymizer.h.

Referenced by clear(), and map().

◆ uid_root_

const char* kcenon::pacs::dcm_modify::uid_mapper::uid_root_ = "1.2.826.0.1.3680043.8.1055.2"
staticconstexprprivate

Definition at line 68 of file anonymizer.h.

Referenced by generate_uid().


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