00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 Module: $URL$ 00005 00006 Copyright (c) 2006-2010 Mathieu Malaterre 00007 All rights reserved. 00008 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 #ifndef GDCMUIDGENERATOR_H 00016 #define GDCMUIDGENERATOR_H 00017 00018 #include "gdcmTypes.h" 00019 00020 namespace gdcm 00021 { 00022 00030 class GDCM_EXPORT UIDGenerator 00031 { 00032 public: 00034 UIDGenerator():Unique() {} 00035 00036 // Function to override the GDCM root with a user one: 00037 // WARNING: This need to be a valid root, otherwise call will fail 00038 // Implementation note. According to DICOM standard PS 3.5, Section 9 : 00039 // Unique Identifiers (UIDs), we have: 00040 /* 00041 ... 00042 The <org root> portion of the UID uniquely identifies an organization, (i.e., manufacturer, research 00043 organization, NEMA, etc.), and is composed of a number of numeric components as defined by ISO 8824. 00044 The <suffix> portion of the UID is also composed of a number of numeric components, and shall be 00045 unique within the scope of the <org root>. This implies that the organization identified in the <org root> is 00046 responsible for guaranteeing <suffix> uniqueness by providing registration policies. These policies shall 00047 guarantee <suffix> uniqueness for all UID's created by that organization. Unlike the <org root>, which may 00048 be common for UID's in an organization, the <suffix> shall take different unique values between different 00049 UID's that identify different objects. 00050 ... 00051 */ 00057 static void SetRoot(const char * root); 00058 static const char *GetRoot(); 00059 00066 const char* Generate(); 00067 00070 static bool IsValid(const char *uid); 00071 00073 static const char *GetGDCMUID(); // who would want that in the public API ?? 00074 00075 protected: 00076 static bool GenerateUUID(unsigned char *uuid_data); 00077 const char* Generate2(); 00078 00079 private: 00080 static const char GDCM_UID[]; 00081 static std::string Root; 00082 static std::string EncodedHardwareAddress; 00083 std::string Unique; // Buffer 00084 }; 00085 00086 00087 } // end namespace gdcm 00088 00089 #endif //GDCMUIDGENERATOR_H