DDraceNetwork Docs
uuid_manager.h
Go to the documentation of this file.
1#ifndef ENGINE_SHARED_UUID_MANAGER_H
2#define ENGINE_SHARED_UUID_MANAGER_H
3
4#include <vector>
5
6enum
7{
8 UUID_MAXSTRSIZE = 37, // 12345678-0123-5678-0123-567890123456
9
12
13 OFFSET_UUID = 1 << 16,
14};
15
16struct CUuid
17{
18 unsigned char m_aData[16];
19
20 bool operator==(const CUuid &Other) const;
21 bool operator!=(const CUuid &Other) const;
22 bool operator<(const CUuid &Other) const;
23};
24
25extern const CUuid UUID_ZEROED;
26
28CUuid CalculateUuid(const char *pName);
29// The buffer length should be at least UUID_MAXSTRSIZE.
30void FormatUuid(CUuid Uuid, char *pBuffer, unsigned BufferLength);
31// Returns nonzero on failure.
32int ParseUuid(CUuid *pUuid, const char *pBuffer);
33
34struct CName
35{
37 const char *m_pName;
38};
39
41{
43 int m_Id;
44
45 bool operator<(const CNameIndexed &Other) const { return m_Uuid < Other.m_Uuid; }
46 bool operator==(const CNameIndexed &Other) const { return m_Uuid == Other.m_Uuid; }
47};
48
49class CPacker;
50class CUnpacker;
51
53{
54 std::vector<CName> m_vNames;
55 std::vector<CNameIndexed> m_vNamesSorted;
56
57public:
58 void RegisterName(int Id, const char *pName);
59 CUuid GetUuid(int Id) const;
60 const char *GetName(int Id) const;
61 int LookupUuid(CUuid Uuid) const;
62 int NumUuids() const;
63
64 int UnpackUuid(CUnpacker *pUnpacker) const;
65 int UnpackUuid(CUnpacker *pUnpacker, CUuid *pOut) const;
66 void PackUuid(int Id, CPacker *pPacker) const;
67
68 void DebugDump() const;
69};
70
72
73#endif // ENGINE_SHARED_UUID_MANAGER_H
Definition: packer.h:7
Definition: packer.h:32
Definition: uuid_manager.h:53
const char * GetName(int Id) const
Definition: uuid_manager.cpp:140
std::vector< CName > m_vNames
Definition: uuid_manager.h:54
void PackUuid(int Id, CPacker *pPacker) const
Definition: uuid_manager.cpp:180
int UnpackUuid(CUnpacker *pUnpacker) const
Definition: uuid_manager.cpp:163
int NumUuids() const
Definition: uuid_manager.cpp:158
int LookupUuid(CUuid Uuid) const
Definition: uuid_manager.cpp:145
std::vector< CNameIndexed > m_vNamesSorted
Definition: uuid_manager.h:55
CUuid GetUuid(int Id) const
Definition: uuid_manager.cpp:135
void DebugDump() const
Definition: uuid_manager.cpp:186
void RegisterName(int Id, const char *pName)
Definition: uuid_manager.cpp:119
Definition: uuid_manager.h:41
int m_Id
Definition: uuid_manager.h:43
bool operator==(const CNameIndexed &Other) const
Definition: uuid_manager.h:46
CUuid m_Uuid
Definition: uuid_manager.h:42
bool operator<(const CNameIndexed &Other) const
Definition: uuid_manager.h:45
Definition: uuid_manager.h:35
CUuid m_Uuid
Definition: uuid_manager.h:36
const char * m_pName
Definition: uuid_manager.h:37
Definition: uuid_manager.h:17
bool operator<(const CUuid &Other) const
Definition: uuid_manager.cpp:104
bool operator!=(const CUuid &Other) const
Definition: uuid_manager.cpp:99
bool operator==(const CUuid &Other) const
Definition: uuid_manager.cpp:94
unsigned char m_aData[16]
Definition: uuid_manager.h:18
void FormatUuid(CUuid Uuid, char *pBuffer, unsigned BufferLength)
Definition: uuid_manager.cpp:60
int ParseUuid(CUuid *pUuid, const char *pBuffer)
Definition: uuid_manager.cpp:69
CUuid RandomUuid()
Definition: uuid_manager.cpp:18
CUuidManager g_UuidManager
Definition: global_uuid_manager.cpp:16
CUuid CalculateUuid(const char *pName)
Definition: uuid_manager.cpp:34
@ OFFSET_UUID
Definition: uuid_manager.h:13
@ UUID_MAXSTRSIZE
Definition: uuid_manager.h:8
@ UUID_INVALID
Definition: uuid_manager.h:10
@ UUID_UNKNOWN
Definition: uuid_manager.h:11
const CUuid UUID_ZEROED
Definition: uuid_manager.cpp:14