Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
GuidMgr.h
1// GuidMgr.h: interface for the CGuidMgr class.
2//
3//////////////////////////////////////////////////////////////////////
4
5#ifndef GUIDMGR_CLASS_H
6#define GUIDMGR_CLASS_H
7
8#ifdef _MSC_VER
9#pragma once
10#endif // _MSC_VER
11
12#include "XThreadSync.h"
13
14BEGIN_MOOTOOLS_NAMESPACE
15
16typedef unsigned int GuidValue32;
17typedef longuint GuidValue;
18typedef unsigned int GuidClass;
19
20// This can be both used as a 64 bits GUID generator (with each 64 bits GUID are associated to a 32 bits guid), or use as a only 32 bits GUID generator
21class DLL_TOOLSFUNCTION CGuidMgr
22{
23protected:
24 typedef struct GuidBaseValue
25 {
26 GuidValue defaultValue;
27 GuidValue currentValue;
28 GuidValue32 currentValue32;
29 } GuidBaseValue;
30
31 typedef struct GuidInfo
32 {
33 GuidClass guidClass;
34 GuidValue32 guid32;
35 } GuidInfo;
36
37 mutable CXCriticalSection threadLock;
41 unsigned int flags;
42
43 GuidValue32 MakeGuid32(const GuidValue& guid); // Get a 32 bit GUID from 64 bits GUID
44
45public:
46 typedef enum GuidFlags XEnumType(unsigned int)
47 {
48 GUIDMGR_NONE = 0x00,
49 GUIDMGR_SILENT = 0x100000, // No message in debug
50 } GuidFlags;
51
52 typedef enum DefaultClass XEnumType(GuidClass)
53 {
54 UNDEFINED_CLASS = (GuidClass)-1,
55 DEFAULT_CLASS = 0,
56 } DefaultClass;
57
58 typedef enum DefaultGUID XEnumType(GuidValue)
59 {
60 UNDEFINED_GUID = (GuidValue)-1,
61 DEFAULT_GUID = 0, // CGuidMgr never returns 0, so 0 can be a default guid value for specific purpose
62 } DefaultGUID;
63
64 typedef enum DefaultGUID32 XEnumType(GuidValue32)
65 {
66 UNDEFINED_GUID32 = (GuidValue32)-1,
67 DEFAULT_GUID32 = 0, // CGuidMgr never returns 0, so 0 can be a default guid value for specific purpose
68 BASE_VALUE_GUID32 = 100, // The base value at which guid starts. Value above are supposed to be free
69 } DefaultGUID32;
70
71 CGuidMgr(GuidValue32 baseValue = BASE_VALUE_GUID32);
72 virtual ~CGuidMgr();
73
74 void SetFlags(unsigned int flags, bool set);
75 inline bool IsFlagSet(GuidFlags flag) { return (flags & flag) != 0; }
76
77 unsigned int GetCount();
78 void RemoveAll(); // Remove all GUID
79
80 void SetClassBaseValue(unsigned int classid, GuidValue startvalue);
81 GuidValue GetClassBaseValue(unsigned int classid) const;
82
83 GuidValue GetNewGuid(const GuidValue& guid = UNDEFINED_GUID, unsigned int GuidClass = DEFAULT_CLASS); // Provide a GUID proposition, and return the same GUID, or a different one if already used
84 GuidValue32 GetNewGuid32(const GuidValue32& guid = UNDEFINED_GUID32, unsigned int guidClass = DEFAULT_CLASS); // Provide a GUID proposition, and return the same GUID, or a different one if already used
85 GuidClass GetGuidClass(const GuidValue& guid) const; // Check if a guid exists. Return UNDEFINED_CLASS if does not exists
86 GuidValue32 GetGuid32(const GuidValue& guid) const; // Get a Guid32 bit value from a 64 bits one
87 bool IsGuidExist(const GuidValue& guid) const; // Check if a guid exists.
88 bool IsGuid32Exist(const GuidValue32& guid) const; // Check if a 32 bits guid exists.
89 bool ReleaseGuid(const GuidValue& guid); // The GUID is not used any longer
90 bool ReleaseGuid32(const GuidValue32& guid); // The 32 bits GUID is not used any longer
91};
92
93inline GuidValue GetNewGuid(CGuidMgr& mgr, const GuidValue& guid = CGuidMgr::UNDEFINED_GUID, unsigned int GuidClass = CGuidMgr::DEFAULT_CLASS)
94{
95 return mgr.GetNewGuid(guid, GuidClass);
96}
97
98inline GuidValue32 GetNewGuid32(CGuidMgr& mgr, const GuidValue32& guid = CGuidMgr::UNDEFINED_GUID32, unsigned int GuidClass = CGuidMgr::DEFAULT_CLASS)
99{
100 return mgr.GetNewGuid32(guid, GuidClass);
101}
102
103inline GuidClass GetGuidClass(const CGuidMgr& mgr, const GuidValue& guid)
104{
105 return mgr.GetGuidClass(guid);
106}
107
108inline bool IsGuidExist(const CGuidMgr& mgr, const GuidValue& guid)
109{
110 return mgr.IsGuidExist(guid);
111}
112
113inline bool IsGuid32Exist(const CGuidMgr& mgr, const GuidValue32& guid)
114{
115 return mgr.IsGuid32Exist(guid);
116}
117
118inline bool ReleaseGuid(CGuidMgr& mgr, const GuidValue& guid)
119{
120 return mgr.ReleaseGuid(guid);
121}
122
123inline bool ReleaseGuid32(CGuidMgr& mgr, const GuidValue32& guid)
124{
125 return mgr.ReleaseGuid32(guid);
126}
127
128END_MOOTOOLS_NAMESPACE
129
130#endif // !GUIDMGR_CLASS_H
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition GuidMgr.h:22
Definition XThreadSync.h:20