GizmoBase

gzGuid.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File         : gzGuid.h
00003 // Module       : gzBase
00004 // Description  : Class definition of GUID types
00005 // Author       : Anders Modén      
00006 // Product      : GizmoBase 2.1.1
00007 //      
00008 // Copyright © 2003- Saab Training Systems AB, Sweden
00009 //          
00010 // NOTE:    GizmoBase is a platform abstraction utility layer for C++. It contains 
00011 //          design patterns and C++ solutions for the advanced programmer.
00012 //
00013 //
00014 // Revision History...                          
00015 //                                  
00016 // Who  Date    Description                     
00017 //                                  
00018 // AMO  980819  Created file    
00019 //
00020 //******************************************************************************
00021 
00022 #ifndef __GZ_GUID_H__
00023 #define __GZ_GUID_H__
00024 
00025 #include "gzBasicTypes.h"
00026 #include "gzTime.h"
00027 
00028 class gzString; // Forward decl
00029 class gzMutex;
00030 
00031 //*********************************** GUID *************************************
00032 
00033 class GZ_BASE_EXPORT gzGUIDBytes
00034 {
00035 public:
00036 
00037     gzGUIDBytes(gzUByte b1=0,gzUByte b2=0,gzUByte b3=0,gzUByte b4=0,gzUByte b5=0,gzUByte b6=0,gzUByte b7=0,gzUByte b8=0);
00038 
00039     gzUByte b1,b2,b3,b4,b5,b6,b7,b8;
00040 };
00041 
00042 #ifndef WIN32   // We don't have any built in GUID definition
00043 
00044     typedef struct _GUID
00045     {
00046         gzULong  Data1;
00047         gzUShort Data2;
00048         gzUShort Data3;
00049         gzUByte  Data4[8];
00050     } GUID;
00051 
00052 #endif
00053 
00054 class GZ_BASE_EXPORT gzGUID
00055 {
00056 public:
00057 
00058     // Creation
00059 
00060     gzGUID();
00061     gzGUID(const GUID & guid);
00062     gzGUID(const gzULong data1, const gzUShort data2 = 0, const gzUShort data3 = 0, const gzGUIDBytes & data4 = 0);
00063     gzGUID(const gzString &format);
00064     gzGUID(const gzWideChar *ustring, gzULong len=0);
00065     gzGUID(const gzChar *cstring, gzULong len=0);
00066     gzGUID(const gzULongLong& val1, const gzULongLong& val2);
00067 
00068 
00069     // Casts & Tests
00070 
00071     gzBool operator==(const gzGUID &right) const;
00072     gzBool operator!=(const gzGUID &right) const;
00073     gzBool operator<(const gzGUID &right) const;
00074 
00075     gzBool operator==(const GUID &right) const;
00076     gzBool operator!=(const GUID &right) const;
00077 
00078     operator GUID & ();
00079 
00080     gzGUID &operator=(const GUID &right);
00081 
00082     // Methods
00083 
00084     GUID &      getGUID();
00085     const GUID &getConstGUID() const;
00086     gzVoid      generate(); // Generate a new GUID
00087     gzVoid      reset();    // Generate NULL guid
00088 
00089     gzBool      isNull() const;
00090     gzBool      isStandardDCE() const;
00091     gzBool      isRandomBased() const;
00092     gzBool      isTimeBased() const;
00093     gzBool      isNameBased() const;
00094 
00095     gzTime      getGenerationTime() const;
00096     gzString    asString() const;
00097     gzVoid      getGUID(gzULong& val1, gzULong& val2, gzULong& val3, gzULong& val4) const;
00098     gzVoid      getGUID(gzULongLong& val1, gzULongLong& val2) const;
00099     
00100     gzULong     hash() const;   // If the GUID value <= 32bits (gzULong), the value is returned unchanged.
00101 
00102     static gzGUID   generateGUID(); // Generate a new GUID
00103 
00104 private:
00105 
00106     union
00107     {
00108         GUID guid;
00109 
00110         struct
00111         {
00112             gzULongLong data1;
00113             gzULongLong data2;
00114         } lldata;
00115 
00116         struct
00117         {
00118             gzULong data1;
00119             gzULong data2;
00120             gzULong data3;
00121             gzULong data4;
00122         } ldata;
00123 
00124     } data;
00125 };
00126 
00127 #endif // __GZ_GUID_H__
00128 
00129 
00130 
00131 
00132 
00133 
00134 

Documentation for GizmoBase generated at Wed Feb 20 11:57:53 2008 by   Saab Training Systems AB, ¸ (c) 2003-and beyond