UID generation classes¶
Introduction¶
This section describes the classes and methods used to generate new UID (unique identifiers) to be used as instance UIDs.
The following classes are described in this chapter:
C++ class |
Objective-C/Swift class |
Description |
---|---|---|
Stored a complete DICOM structure |
||
Stores a single DICOM tag |
||
Identifies a tag |
||
Read data from a tag |

Class diagram of the UID generators related classes¶
Imebra supplies two generators that are able to produce UIDs that can be used as SOP instances UID:
SerialNumberUIDGenerator, to be used when the software has a mean to know its own serial number
RandomUIDGenerator, to be used when the software is not able to retrieve its own serial number
In any case, the developer must acquire a root UID from the ISO authority.
Because the UID generators maintain an internal state which is necessary to generate unique IDs, the generators should be allocated once when the program starts and then reused for the generation of every new UID. UIDGeneratorFactory helps retrieving the generators allocated when the software started: register the allocated generators in the UIDGeneratorFactory when the software starts and then get them from the factory when a new UID is needed.
Factory¶
UIDGeneratorFactory¶
C++¶
-
class
UIDGeneratorFactory
¶ The UIDGeneratorFactory class manages a global collection of DICOM UID generators.
In order to generate different UIDs, the UID generators maintain an internal state that must be preserved between UID generations. Ideally, UID generators should be allocated when the application starts and should be reused every time a new UID is needed.
The UIDGeneratorFactory class helps with the reuse of the allocated generators.
Public Static Functions
-
static void
registerUIDGenerator
(const std::string &name, const BaseUIDGenerator &uidGenerator)¶ Register an UID generator.
UID generators should be registered when the application starts.
Registered UID generators can be retrieved using getUIDGenerator() or getDefaultUIDGenerator().
- Parameters
name
: the name under which the UID generator is registereduidGenerator
: the UID generator to register
-
static BaseUIDGenerator
getUIDGenerator
(const std::string &name)¶ Retrieved a registered UID generator.
- Return
the requested UID generator
- Exceptions
NonRegisteredUIDGenerator
: if the requested UID generator was not register via registerUIDGenerator().
- Parameters
name
: the name of the generator to retrieve
-
static BaseUIDGenerator
getDefaultUIDGenerator
()¶ Retrieve the first UID generator registered in the factory.
- Return
the first registered UID generator
- Exceptions
NonRegisteredUIDGenerator
: if no UID generator was not register via registerUIDGenerator().
-
static void
Objective-C/Swift¶
-
class
ImebraUIDGeneratorFactory
: public NSObject¶ ImebraUIDGeneratorFactory manages a global collection of DICOM UID generators.
In order to generate different UIDs, the UID generators maintain an internal state that must be preserved between UID generations. Ideally, UID generators should be allocated when the application starts and should be reused every time a new UID is needed.
ImebraUIDGeneratorFactory helps with the reuse of the allocated generators.
Public Static Functions
-
void ImebraUIDGeneratorFactory::registerUIDGenerator:generator:error:(NSString * name, ImebraBaseUIDGenerator * pGenerator, NSError ** pError)
Register an UID generator.
UID generators should be registered when the application starts.
Registered UID generators can be retrieved using getUIDGenerator() or getDefaultUIDGenerator().
- Parameters
name
: the name under which the UID generator is registeredpGGenerator
: the UID generator to register
-
ImebraBaseUIDGenerator* ImebraUIDGeneratorFactory::getUIDGenerator:error:(NSString * name, NSError ** pError)
Retrieved a registered UID generator.
- Return
the requested UID generator
- Exceptions
ImebraNonRegisteredUIDGenerator
: if the requested UID generator was not register via registerUIDGenerator().
- Parameters
name
: the name of the generator to retrieve
-
ImebraBaseUIDGenerator* ImebraUIDGeneratorFactory::getDefaultUIDGenerator:(NSError ** pError)
Retrieve the first UID generator registered in the factory.
- Return
the first registered UID generator
- Exceptions
ImebraNonRegisteredUIDGenerator
: if no UID generator was not register via registerUIDGenerator().
-
Generators¶
BaseUIDGenerator¶
C++¶
-
class
BaseUIDGenerator
¶ Base class for the DICOM UID generators.
Subclassed by imebra::RandomUIDGenerator, imebra::SerialNumberUIDGenerator
Public Functions
-
BaseUIDGenerator
(const BaseUIDGenerator &source)¶ Copy constructor.
- Parameters
source
: source UID generator
-
std::string
getUID
()¶ Generates a new UID.
- Return
a new UID.
-
Objective-C/Swift¶
-
class
ImebraBaseUIDGenerator
: public NSObject¶ Base class for the DICOM UID generators.
Subclassed by ImebraRandomUIDGenerator, ImebraSerialNumberUIDGenerator
Public Functions
-
NSString *
getUID
()¶ Generates a new UID.
- Return
a new UID.
-
NSString *
SerialNumberUIDGenerator¶
C++¶
-
class
SerialNumberUIDGenerator
: public imebra::BaseUIDGenerator¶ An UID generator that uses the model serial number to create unique UIDs.
The uniqueness of the generated UIDs is guaranteed by the fact that the machine serial number is correctly set.
Public Functions
-
SerialNumberUIDGenerator
(const std::string &root, std::uint32_t departmentId, std::uint32_t modelId, std::uint32_t serialNumber)¶ Constructor.
- Parameters
root
: the root UID assigned to the companydepartmentId
: department ID (assigned by the company)modelId
: model ID (assigned by the department)serialNumber
: the model serial number (assigned by the department)
-
SerialNumberUIDGenerator
(const SerialNumberUIDGenerator &source)¶ Copy constructor.
- Parameters
source
: source SerialNumberUIDGenerator object
-
Objective-C/Swift¶
-
class
ImebraSerialNumberUIDGenerator
: public ImebraBaseUIDGenerator¶ An UID generator that uses the model serial number to create unique UIDs.
The uniqueness of the generated UIDs is guaranteed by the fact that the machine serial number is correctly set.
Public Functions
-
id ImebraSerialNumberUIDGenerator::initWithRoot:departmentId:modelId:serialNumber:(NSString * root, unsigned int departmentId, unsigned int modelId, unsigned int serialNumber)
Constructor.
- Parameters
root
: the root UID assigned to the companydepartmentId
: department ID (assigned by the company)modelId
: model ID (assigned by the department)serialNumber
: the model serial number (assigned by the department)
-
RandomUIDGenerator¶
C++¶
-
class
RandomUIDGenerator
: public imebra::BaseUIDGenerator¶ An UID generator that uses a random number to generate unique UIDs.
The uniqueness of the generated UIDs is guaranteed by the fact that the machine generates a long random number during the UID generator initialization.
Public Functions
-
RandomUIDGenerator
(const std::string &root, std::uint32_t departmentId, std::uint32_t modelId)¶ Constructor.
- Parameters
root
: the root UID assigned to the companydepartmentId
: department ID (assigned by the company)modelId
: model ID (assigned by the department)
-
RandomUIDGenerator
(const RandomUIDGenerator &source)¶ Copy constructor.
- Parameters
source
: source RandomUIDGenerator object
-
Objective-C/Swift¶
-
class
ImebraRandomUIDGenerator
: public ImebraBaseUIDGenerator¶ An UID generator that uses a random number to generate unique UIDs.
The uniqueness of the generated UIDs is guaranteed by the fact that the machine generates a long random number during the UID generator initialization.
Public Functions
-
id ImebraRandomUIDGenerator::initWithRoot:departmentId:modelId:(NSString * root, unsigned int departmentId, unsigned int modelId)
Constructor.
- Parameters
root
: the root UID assigned to the companydepartmentId
: department ID (assigned by the company)modelId
: model ID (assigned by the department)
-