TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ObjectGuid Class Reference

#include <ObjectGuid.h>

Public Types

typedef uint64 LowType
 

Public Member Functions

 ObjectGuid ()
 
std::vector< uint8GetRawValue () const
 
void SetRawValue (std::vector< uint8 > const &guid)
 
void SetRawValue (uint64 high, uint64 low)
 
void Clear ()
 
HighGuid GetHigh () const
 
uint32 GetRealmId () const
 
uint32 GetMapId () const
 
uint32 GetEntry () const
 
LowType GetCounter () const
 
LowType GetMaxCounter () const
 
uint8operator[] (uint32 index)
 
uint8 constoperator[] (uint32 index) const
 
bool IsEmpty () const
 
bool IsCreature () const
 
bool IsPet () const
 
bool IsVehicle () const
 
bool IsCreatureOrPet () const
 
bool IsCreatureOrVehicle () const
 
bool IsAnyTypeCreature () const
 
bool IsPlayer () const
 
bool IsUnit () const
 
bool IsItem () const
 
bool IsGameObject () const
 
bool IsDynamicObject () const
 
bool IsCorpse () const
 
bool IsAreaTrigger () const
 
bool IsMOTransport () const
 
bool IsAnyTypeGameObject () const
 
bool IsParty () const
 
bool IsGuild () const
 
bool IsSceneObject () const
 
bool IsConversation () const
 
TypeID GetTypeId () const
 
bool operator! () const
 
bool operator== (ObjectGuid const &guid) const
 
bool operator!= (ObjectGuid const &guid) const
 
bool operator< (ObjectGuid const &guid) const
 
char constGetTypeName () const
 
std::string ToString () const
 

Static Public Member Functions

template<HighGuid type>
static std::enable_if
< ObjectGuidTraits< type >
::Global, ObjectGuid >::type 
Create (LowType counter)
 
template<HighGuid type>
static std::enable_if
< ObjectGuidTraits< type >
::RealmSpecific, ObjectGuid >
::type 
Create (LowType counter)
 
template<HighGuid type>
static std::enable_if
< ObjectGuidTraits< type >
::MapSpecific, ObjectGuid >
::type 
Create (uint16 mapId, uint32 entry, LowType counter)
 
static LowType GetMaxCounter (HighGuid)
 
static TypeID GetTypeId (HighGuid high)
 
static char constGetTypeName (HighGuid high)
 

Static Public Attributes

static ObjectGuid const Empty = ObjectGuid()
 
static ObjectGuid const TradeItem = ObjectGuid::Create<HighGuid::Uniq>(uint64(10))
 

Private Member Functions

bool HasEntry () const
 
 ObjectGuid (uint64 high, uint64 low)
 
 ObjectGuid (uint32 const &)=delete
 

Static Private Member Functions

static bool HasEntry (HighGuid high)
 
static ObjectGuid Global (HighGuid type, LowType counter)
 
static ObjectGuid RealmSpecific (HighGuid type, LowType counter)
 
static ObjectGuid MapSpecific (HighGuid type, uint8 subType, uint16 mapId, uint32 serverId, uint32 entry, LowType counter)
 

Private Attributes

uint64 _low
 
uint64 _high
 

Friends

TC_GAME_API std::ostream & operator<< (std::ostream &stream, ObjectGuid const &guid)
 
TC_GAME_API ByteBufferoperator<< (ByteBuffer &buf, ObjectGuid const &guid)
 
TC_GAME_API ByteBufferoperator>> (ByteBuffer &buf, ObjectGuid &guid)
 

Member Typedef Documentation

Constructor & Destructor Documentation

ObjectGuid::ObjectGuid ( )
inline
210 : _low(0), _high(0) { }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326

+ Here is the caller graph for this function:

ObjectGuid::ObjectGuid ( uint64  high,
uint64  low 
)
inlineprivate
322 : _low(low), _high(high) { }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
ObjectGuid::ObjectGuid ( uint32 const )
explicitprivatedelete

Member Function Documentation

void ObjectGuid::Clear ( )
inline
215 { _high = 0; _low = 0; }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
template<HighGuid type>
static std::enable_if<ObjectGuidTraits<type>::Global, ObjectGuid>::type ObjectGuid::Create ( LowType  counter)
inlinestatic
202 { return Global(type, counter); }
static ObjectGuid Global(HighGuid type, LowType counter)
Definition: ObjectGuid.cpp:111
template<HighGuid type>
static std::enable_if<ObjectGuidTraits<type>::RealmSpecific, ObjectGuid>::type ObjectGuid::Create ( LowType  counter)
inlinestatic
205 { return RealmSpecific(type, counter); }
static ObjectGuid RealmSpecific(HighGuid type, LowType counter)
Definition: ObjectGuid.cpp:116
template<HighGuid type>
static std::enable_if<ObjectGuidTraits<type>::MapSpecific, ObjectGuid>::type ObjectGuid::Create ( uint16  mapId,
uint32  entry,
LowType  counter 
)
inlinestatic
208 { return MapSpecific(type, 0, mapId, 0, entry, counter); }
static ObjectGuid MapSpecific(HighGuid type, uint8 subType, uint16 mapId, uint32 serverId, uint32 entry, LowType counter)
Definition: ObjectGuid.cpp:121
LowType ObjectGuid::GetCounter ( ) const
inline
221 { return _low & UI64LIT(0x000000FFFFFFFFFF); }
uint64 _low
Definition: ObjectGuid.h:325
#define UI64LIT(N)
Definition: Define.h:138
uint32 ObjectGuid::GetEntry ( ) const
inline
220 { return uint32((_high >> 6) & 0x7FFFFF); }
uint32_t uint32
Definition: g3dmath.h:168
uint64 _high
Definition: ObjectGuid.h:326

+ Here is the caller graph for this function:

HighGuid ObjectGuid::GetHigh ( ) const
inline
217 { return HighGuid((_high >> 58) & 0x3F); }
HighGuid
Definition: ObjectGuid.h:60
uint64 _high
Definition: ObjectGuid.h:326

+ Here is the caller graph for this function:

uint32 ObjectGuid::GetMapId ( ) const
inline
219 { return uint32((_high >> 29) & 0x1FFF); }
uint32_t uint32
Definition: g3dmath.h:168
uint64 _high
Definition: ObjectGuid.h:326
static LowType ObjectGuid::GetMaxCounter ( HighGuid  )
inlinestatic
224  {
225  return UI64LIT(0xFFFFFFFFFF);
226  }
#define UI64LIT(N)
Definition: Define.h:138
LowType ObjectGuid::GetMaxCounter ( ) const
inline
228 { return GetMaxCounter(GetHigh()); }
LowType GetMaxCounter() const
Definition: ObjectGuid.h:228
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< uint8 > ObjectGuid::GetRawValue ( ) const
128 {
129  std::vector<uint8> raw(16);
130  memcpy(raw.data(), this, sizeof(*this));
131  return raw;
132 }

+ Here is the caller graph for this function:

uint32 ObjectGuid::GetRealmId ( ) const
inline
218 { return uint32((_high >> 42) & 0x1FFF); }
uint32_t uint32
Definition: g3dmath.h:168
uint64 _high
Definition: ObjectGuid.h:326
static TypeID ObjectGuid::GetTypeId ( HighGuid  high)
inlinestatic
264  {
265  switch (high)
266  {
267  case HighGuid::Item: return TYPEID_ITEM;
268  case HighGuid::Creature:
269  case HighGuid::Pet:
270  case HighGuid::Vehicle: return TYPEID_UNIT;
271  case HighGuid::Player: return TYPEID_PLAYER;
275  case HighGuid::Corpse: return TYPEID_CORPSE;
279  default: return TYPEID_OBJECT;
280  }
281  }
Definition: ObjectGuid.h:36
Definition: ObjectGuid.h:32
Definition: ObjectGuid.h:37
Definition: ObjectGuid.h:39
Definition: ObjectGuid.h:34
Definition: ObjectGuid.h:29
Definition: ObjectGuid.h:38
Definition: ObjectGuid.h:33
Definition: ObjectGuid.h:35
Definition: ObjectGuid.h:30

+ Here is the caller graph for this function:

TypeID ObjectGuid::GetTypeId ( ) const
inline
283 { return GetTypeId(GetHigh()); }
TypeID GetTypeId() const
Definition: ObjectGuid.h:283
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const * ObjectGuid::GetTypeName ( HighGuid  high)
static
92 {
93  if (high >= HighGuid::Count)
94  return "<unknown>";
95 
96  return Names.Values[uint32(high)];
97 }
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

char const* ObjectGuid::GetTypeName ( ) const
inline
299 { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
char const * GetTypeName() const
Definition: ObjectGuid.h:299
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid ObjectGuid::Global ( HighGuid  type,
LowType  counter 
)
staticprivate
112 {
113  return ObjectGuid(uint64(uint64(type) << 58), counter);
114 }
uint64_t uint64
Definition: g3dmath.h:170
ObjectGuid()
Definition: ObjectGuid.h:210

+ Here is the call graph for this function:

static bool ObjectGuid::HasEntry ( HighGuid  high)
inlinestaticprivate
304  {
305  switch (high)
306  {
308  case HighGuid::Creature:
309  case HighGuid::Pet:
310  case HighGuid::Vehicle:
311  default:
312  return true;
313  }
314  }
bool ObjectGuid::HasEntry ( ) const
inlineprivate
316 { return HasEntry(GetHigh()); }
bool HasEntry() const
Definition: ObjectGuid.h:316
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ObjectGuid::IsAnyTypeCreature ( ) const
inline
248 { return IsCreature() || IsPet() || IsVehicle(); }
bool IsVehicle() const
Definition: ObjectGuid.h:245
bool IsCreature() const
Definition: ObjectGuid.h:243
bool IsPet() const
Definition: ObjectGuid.h:244

+ Here is the caller graph for this function:

bool ObjectGuid::IsAnyTypeGameObject ( ) const
inline
257 { return IsGameObject() || IsMOTransport(); }
bool IsGameObject() const
Definition: ObjectGuid.h:252
bool IsMOTransport() const
Definition: ObjectGuid.h:256

+ Here is the caller graph for this function:

bool ObjectGuid::IsAreaTrigger ( ) const
inline
255 { return GetHigh() == HighGuid::AreaTrigger; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool ObjectGuid::IsConversation ( ) const
inline
261 { return GetHigh() == HighGuid::Conversation; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool ObjectGuid::IsCorpse ( ) const
inline
254 { return GetHigh() == HighGuid::Corpse; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsCreature ( ) const
inline
243 { return GetHigh() == HighGuid::Creature; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool ObjectGuid::IsCreatureOrPet ( ) const
inline
246 { return IsCreature() || IsPet(); }
bool IsCreature() const
Definition: ObjectGuid.h:243
bool IsPet() const
Definition: ObjectGuid.h:244
bool ObjectGuid::IsCreatureOrVehicle ( ) const
inline
247 { return IsCreature() || IsVehicle(); }
bool IsVehicle() const
Definition: ObjectGuid.h:245
bool IsCreature() const
Definition: ObjectGuid.h:243

+ Here is the caller graph for this function:

bool ObjectGuid::IsDynamicObject ( ) const
inline
253 { return GetHigh() == HighGuid::DynamicObject; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool ObjectGuid::IsEmpty ( ) const
inline
242 { return _low == 0 && _high == 0; }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
bool ObjectGuid::IsGameObject ( ) const
inline
252 { return GetHigh() == HighGuid::GameObject; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsGuild ( ) const
inline
259 { return GetHigh() == HighGuid::Guild; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsItem ( ) const
inline
251 { return GetHigh() == HighGuid::Item; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsMOTransport ( ) const
inline
256 { return GetHigh() == HighGuid::Transport; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsParty ( ) const
inline
258 { return GetHigh() == HighGuid::Party; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsPet ( ) const
inline
244 { return GetHigh() == HighGuid::Pet; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

bool ObjectGuid::IsPlayer ( ) const
inline
249 { return !IsEmpty() && GetHigh() == HighGuid::Player; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the caller graph for this function:

bool ObjectGuid::IsSceneObject ( ) const
inline
260 { return GetHigh() == HighGuid::SceneObject; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool ObjectGuid::IsUnit ( ) const
inline
250 { return IsAnyTypeCreature() || IsPlayer(); }
bool IsPlayer() const
Definition: ObjectGuid.h:249
bool IsAnyTypeCreature() const
Definition: ObjectGuid.h:248

+ Here is the caller graph for this function:

bool ObjectGuid::IsVehicle ( ) const
inline
245 { return GetHigh() == HighGuid::Vehicle; }
HighGuid GetHigh() const
Definition: ObjectGuid.h:217

+ Here is the caller graph for this function:

ObjectGuid ObjectGuid::MapSpecific ( HighGuid  type,
uint8  subType,
uint16  mapId,
uint32  serverId,
uint32  entry,
LowType  counter 
)
staticprivate
122 {
123  return ObjectGuid(uint64((uint64(type) << 58) | (uint64(realm.Id.Realm & 0x1FFF) << 42) | (uint64(mapId & 0x1FFF) << 29) | (uint64(entry & 0x7FFFFF) << 6) | (uint64(subType) & 0x3F)),
124  uint64((uint64(serverId & 0xFFFFFF) << 40) | (counter & UI64LIT(0xFFFFFFFFFF))));
125 }
uint32 Realm
Definition: Realm.h:53
Realm realm
Definition: World.cpp:3485
#define UI64LIT(N)
Definition: Define.h:138
uint64_t uint64
Definition: g3dmath.h:170
Battlenet::RealmHandle Id
Definition: Realm.h:86
uint64_t uint64
Definition: Define.h:149
ObjectGuid()
Definition: ObjectGuid.h:210

+ Here is the call graph for this function:

bool ObjectGuid::operator! ( ) const
inline
285 { return IsEmpty(); }
bool IsEmpty() const
Definition: ObjectGuid.h:242
bool ObjectGuid::operator!= ( ObjectGuid const guid) const
inline
287 { return !(*this == guid); }
bool ObjectGuid::operator< ( ObjectGuid const guid) const
inline
289  {
290  if (_high < guid._high)
291  return true;
292  else if (_high > guid._high)
293  return false;
294 
295  return _low < guid._low;
296  }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
bool ObjectGuid::operator== ( ObjectGuid const guid) const
inline
286 { return _low == guid._low && _high == guid._high; }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
uint8& ObjectGuid::operator[] ( uint32  index)
inline
231  {
232  ASSERT(index < sizeof(uint64) * 2);
233  return ((uint8*)&_low)[index];
234  }
uint64 _low
Definition: ObjectGuid.h:325
uint64_t uint64
Definition: Define.h:149
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
uint8 const& ObjectGuid::operator[] ( uint32  index) const
inline
237  {
238  ASSERT(index < sizeof(uint64) * 2);
239  return ((uint8 const*)&_low)[index];
240  }
uint64 _low
Definition: ObjectGuid.h:325
uint64_t uint64
Definition: Define.h:149
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
ObjectGuid ObjectGuid::RealmSpecific ( HighGuid  type,
LowType  counter 
)
staticprivate
117 {
118  return ObjectGuid(uint64(uint64(type) << 58 | uint64(realm.Id.Realm) << 42), counter);
119 }
uint32 Realm
Definition: Realm.h:53
Realm realm
Definition: World.cpp:3485
uint64_t uint64
Definition: g3dmath.h:170
Battlenet::RealmHandle Id
Definition: Realm.h:86
ObjectGuid()
Definition: ObjectGuid.h:210

+ Here is the call graph for this function:

void ObjectGuid::SetRawValue ( std::vector< uint8 > const guid)
135 {
136  ASSERT(guid.size() == sizeof(*this));
137  memcpy(this, guid.data(), sizeof(*this));
138 }
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

void ObjectGuid::SetRawValue ( uint64  high,
uint64  low 
)
inline
214 { _high = high; _low = low; }
uint64 _low
Definition: ObjectGuid.h:325
uint64 _high
Definition: ObjectGuid.h:326
std::string ObjectGuid::ToString ( ) const
100 {
101  std::ostringstream str;
102  str << "GUID Full: 0x" << std::hex << std::uppercase << std::setw(16) << std::setfill('0') << _high << std::setw(16) << _low << std::dec << std::nouppercase;
103  str << " Type: " << GetTypeName();
104  if (HasEntry())
105  str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry();
106 
107  str << " Low: " << GetCounter();
108  return str.str();
109 }
IntFormatSpec< int, TypeSpec<'x'> > hex(int value)
uint64 _low
Definition: ObjectGuid.h:325
char const * GetTypeName() const
Definition: ObjectGuid.h:299
uint32 GetEntry() const
Definition: ObjectGuid.h:220
bool HasEntry() const
Definition: ObjectGuid.h:316
uint64 _high
Definition: ObjectGuid.h:326
bool IsPet() const
Definition: ObjectGuid.h:244
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

Friends And Related Function Documentation

TC_GAME_API std::ostream& operator<< ( std::ostream &  stream,
ObjectGuid const guid 
)
friend
183 {
184  std::ostringstream tmp;
185  tmp << std::hex << std::setw(16) << std::setfill('0') << guid._high << std::setw(16) << std::setfill('0') << guid._low;
186  stream << tmp.str();
187  return stream;
188 }
IntFormatSpec< int, TypeSpec<'x'> > hex(int value)
TC_GAME_API ByteBuffer& operator<< ( ByteBuffer buf,
ObjectGuid const guid 
)
friend
147 {
148  uint8 lowMask = 0;
149  uint8 highMask = 0;
150  buf.FlushBits(); // flush any unwritten bits to make wpos return a meaningful value
151  std::size_t pos = buf.wpos();
152  buf << uint8(lowMask);
153  buf << uint8(highMask);
154 
155  uint8 packed[8];
156  if (size_t packedSize = ByteBuffer::PackUInt64(guid._low, &lowMask, packed))
157  buf.append(packed, packedSize);
158  if (size_t packedSize = ByteBuffer::PackUInt64(guid._high, &highMask, packed))
159  buf.append(packed, packedSize);
160 
161  buf.put(pos, lowMask);
162  buf.put(pos + 1, highMask);
163 
164  return buf;
165 }
void FlushBits()
Definition: ByteBuffer.h:150
size_t wpos() const
Definition: ByteBuffer.h:454
static size_t PackUInt64(uint64 value, uint8 *mask, uint8 *result)
Definition: ByteBuffer.h:660
void put(size_t pos, T value)
Definition: ByteBuffer.h:227
void append(T value)
Definition: ByteBuffer.h:143
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
TC_GAME_API ByteBuffer& operator>> ( ByteBuffer buf,
ObjectGuid guid 
)
friend
168 {
169  uint8 lowMask, highMask;
170  buf >> lowMask >> highMask;
171  buf.ReadPackedUInt64(lowMask, guid._low);
172  buf.ReadPackedUInt64(highMask, guid._high);
173  return buf;
174 }
void ReadPackedUInt64(uint64 &guid)
Definition: ByteBuffer.h:511
uint64 _low
Definition: ObjectGuid.h:325
uint8_t uint8
Definition: Define.h:152
uint64 _high
Definition: ObjectGuid.h:326

Member Data Documentation

uint64 ObjectGuid::_high
private
uint64 ObjectGuid::_low
private
ObjectGuid const ObjectGuid::Empty = ObjectGuid()
static
ObjectGuid const ObjectGuid::TradeItem = ObjectGuid::Create<HighGuid::Uniq>(uint64(10))
static

The documentation for this class was generated from the following files: