diff options
author | Adam Frisby | 2007-06-29 22:09:52 +0000 |
---|---|---|
committer | Adam Frisby | 2007-06-29 22:09:52 +0000 |
commit | e4df6ea08e75294cf47f7f99ea5a3751f9aa0c8e (patch) | |
tree | 51f33a33410fac3811ab464cc4aa60defe1e32a8 /OpenSim/Framework/General/Types/UUID.cs | |
parent | * Experimental patch: Replaced IPAddress.Any with IPAddress.Parse("0.0.0.0") ... (diff) | |
download | opensim-SC_OLD-e4df6ea08e75294cf47f7f99ea5a3751f9aa0c8e.zip opensim-SC_OLD-e4df6ea08e75294cf47f7f99ea5a3751f9aa0c8e.tar.gz opensim-SC_OLD-e4df6ea08e75294cf47f7f99ea5a3751f9aa0c8e.tar.bz2 opensim-SC_OLD-e4df6ea08e75294cf47f7f99ea5a3751f9aa0c8e.tar.xz |
* Created new "UUID" class to override LLUUID in general. (Unable to inherit from LLUUID, so written as a wrapper + extra functions), 1:1 Feature compatible with LLUUID designed as "Drop In" replacement.
Diffstat (limited to 'OpenSim/Framework/General/Types/UUID.cs')
-rw-r--r-- | OpenSim/Framework/General/Types/UUID.cs | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/OpenSim/Framework/General/Types/UUID.cs b/OpenSim/Framework/General/Types/UUID.cs new file mode 100644 index 0000000..8d47c30 --- /dev/null +++ b/OpenSim/Framework/General/Types/UUID.cs | |||
@@ -0,0 +1,129 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenSim.Framework.Types | ||
7 | { | ||
8 | class UUID | ||
9 | { | ||
10 | public LLUUID llUUID; | ||
11 | |||
12 | public UUID(string uuid) | ||
13 | { | ||
14 | llUUID = new LLUUID(uuid); | ||
15 | } | ||
16 | |||
17 | public UUID(byte[] uuid) | ||
18 | { | ||
19 | llUUID = new LLUUID(uuid, 0); | ||
20 | } | ||
21 | |||
22 | public UUID(byte[] uuid, int offset) | ||
23 | { | ||
24 | llUUID = new LLUUID(uuid, offset); | ||
25 | } | ||
26 | |||
27 | public UUID() | ||
28 | { | ||
29 | llUUID = LLUUID.Zero; | ||
30 | } | ||
31 | |||
32 | public UUID(ulong uuid) | ||
33 | { | ||
34 | llUUID = new LLUUID(uuid); | ||
35 | } | ||
36 | |||
37 | public UUID(UInt32 first, UInt32 second, UInt32 third, UInt32 fourth) | ||
38 | { | ||
39 | byte[] uuid = new byte[16]; | ||
40 | |||
41 | byte[] n = BitConverter.GetBytes(first); | ||
42 | n.CopyTo(uuid, 0); | ||
43 | n = BitConverter.GetBytes(second); | ||
44 | n.CopyTo(uuid, 4); | ||
45 | n = BitConverter.GetBytes(third); | ||
46 | n.CopyTo(uuid, 8); | ||
47 | n = BitConverter.GetBytes(fourth); | ||
48 | n.CopyTo(uuid, 12); | ||
49 | |||
50 | llUUID = new LLUUID(uuid,0); | ||
51 | } | ||
52 | |||
53 | public override string ToString() | ||
54 | { | ||
55 | return llUUID.ToString(); | ||
56 | } | ||
57 | |||
58 | public string ToStringHyphenated() | ||
59 | { | ||
60 | return llUUID.ToStringHyphenated(); | ||
61 | } | ||
62 | |||
63 | public byte[] GetBytes() | ||
64 | { | ||
65 | return llUUID.GetBytes(); | ||
66 | } | ||
67 | |||
68 | public UInt32[] GetInts() | ||
69 | { | ||
70 | UInt32[] ints = new UInt32[4]; | ||
71 | ints[0] = BitConverter.ToUInt32(llUUID.Data, 0); | ||
72 | ints[1] = BitConverter.ToUInt32(llUUID.Data, 4); | ||
73 | ints[2] = BitConverter.ToUInt32(llUUID.Data, 8); | ||
74 | ints[3] = BitConverter.ToUInt32(llUUID.Data, 12); | ||
75 | |||
76 | return ints; | ||
77 | } | ||
78 | |||
79 | public LLUUID GetLLUUID() | ||
80 | { | ||
81 | return llUUID; | ||
82 | } | ||
83 | |||
84 | public uint CRC() | ||
85 | { | ||
86 | return llUUID.CRC(); | ||
87 | } | ||
88 | |||
89 | public override int GetHashCode() | ||
90 | { | ||
91 | return llUUID.GetHashCode(); | ||
92 | } | ||
93 | |||
94 | public void Combine(UUID other) | ||
95 | { | ||
96 | llUUID.Combine(other.GetLLUUID()); | ||
97 | } | ||
98 | |||
99 | public void Combine(LLUUID other) | ||
100 | { | ||
101 | llUUID.Combine(other); | ||
102 | } | ||
103 | |||
104 | public override bool Equals(Object other) | ||
105 | { | ||
106 | return llUUID.Equals(other); | ||
107 | } | ||
108 | |||
109 | public static bool operator ==(UUID a, UUID b) | ||
110 | { | ||
111 | return a.Equals(b); | ||
112 | } | ||
113 | |||
114 | public static bool operator !=(UUID a, UUID b) | ||
115 | { | ||
116 | return !a.Equals(b); | ||
117 | } | ||
118 | |||
119 | public static bool operator ==(UUID a, LLUUID b) | ||
120 | { | ||
121 | return a.Equals(b); | ||
122 | } | ||
123 | |||
124 | public static bool operator !=(UUID a, LLUUID b) | ||
125 | { | ||
126 | return !a.Equals(b); | ||
127 | } | ||
128 | } | ||
129 | } | ||