MeVisLab Toolbox Reference
|
Class to generate unique ids, valid to be used in a DICOM environment. More...
#include <DCMTree_UIDGenerator.h>
Static Public Member Functions | |
static void | initialize (const std::string &iso_root_uid=std::string(), const std::string &replacementMac=std::string()) |
Function to be called exactly once before any other function is called. | |
static void | initialize (std::string iso_root_uid, std::string systemtype, std::string softwaretype, std::string replacementMac=std::string()) |
Overload to keep old code working, systemtype and softwaretype are not used any more. | |
static std::string | uid () |
create a new uid | |
static bool | isInitialized () |
return true if class is initialized | |
static void | setMaxCounterPerSecond (int value) |
This method allows to overwrite how many uids can be created per second. | |
static int | getMaxCounterPerSecond () |
Get the used max counter per seconds. | |
static std::string | hashUID (const std::string &uid) |
Get a uid that is basically a hash of the argument uid (with an appropriate prefix). | |
Class to generate unique ids, valid to be used in a DICOM environment.
The created UIDs have the following form: 'iso_root_uid'.'mac of the system'.'process id'.'seconds since epoch'.'counter'
The uids are unique even in a multi-threaded environment The mac of the system has to be unique of course.
Known problem of the implementation: If an application is started multiple times in the same second AND gets the same process id again, it is possible to get the same UID again.
The implementation allows the time of the computer to be changed to the past and will adapt the time to not reuse timestamps that were already used.
Definition at line 40 of file DCMTree_UIDGenerator.h.
Get the used max counter per seconds.
Get a uid that is basically a hash of the argument uid (with an appropriate prefix).
The same
The input can be basically be any string, since SHA1 is applied on the bytes, so you can also append/prepend a "salt" value to the input uid if required.
The prefix is the iso_root_uid given in the initialize function (or DCMTree_MeVis_UidPrefix if omitted), plus DCMTree_MeVis_UidHashedUid from the file DCMTree_MeVisDicomTags.h.
The result is filled up up to the allowed limit of 64 characters with digits from the hash value of input uid. For the default prefix this represents about 112 bits from the hash value.
|
static |
Function to be called exactly once before any other function is called.
This function sets some predefined values, especially the _prefix part of the UIDs up to the 'process id'
iso_root_uid | specifies the iso root id without a trailing dot. If the string is empty, the DCMTree_MeVis_UidPrefix uid is used. |
replacementMac | optional parameter. If a replacementMac is provided it will be used in the _prefix; otherwise the MAC adress is determined with the getMac() function. A replacementMac is especially useful if the getMac() cannot guarantee to return a unique MAC which could be the case if VMWare is installed (which installs its own virtual adapters) |
|
static |
Overload to keep old code working, systemtype and softwaretype are not used any more.
return true if class is initialized
This method allows to overwrite how many uids can be created per second.
This should mainly be used for testing purposes. Also resets counter to 0.
|
static |
create a new uid