-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFEUniqueID.h
More file actions
69 lines (59 loc) · 1.76 KB
/
FEUniqueID.h
File metadata and controls
69 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#include <string>
#include <unordered_map>
#include <chrono>
#include <time.h>
#include <random>
#include "FEBasicApplicationAPI.h"
#include "VersionInfo/FE_BASIC_APPLICATION_Version.h"
#include "VersionInfo/FEVersionInfo.h"
#define SINGLETON_PUBLIC_PART(CLASS_NAME) \
static CLASS_NAME& GetInstance() \
{ \
static CLASS_NAME* Instance = nullptr; \
if (!Instance) \
Instance = new CLASS_NAME(); \
return *Instance; \
} \
\
static CLASS_NAME* GetInstancePointer() \
{ \
return &GetInstance(); \
}
#define SINGLETON_PRIVATE_PART(CLASS_NAME) \
CLASS_NAME(); \
~CLASS_NAME(); \
CLASS_NAME(const CLASS_NAME &); \
void operator= (const CLASS_NAME &);
#define FE_MAP_TO_STR_VECTOR(map) \
std::vector<std::string> result; \
auto iterator = map.begin(); \
while (iterator != map.end()) \
{ \
result.push_back(iterator->first); \
iterator++; \
} \
\
return result;
namespace FocalEngine
{
class FEBASICAPPLICATION_API FEUniqueID
{
SINGLETON_PRIVATE_PART(FEUniqueID)
std::string GetUniqueID();
public:
SINGLETON_PUBLIC_PART(FEUniqueID)
// This function can produce ID's that are "unique" with very rare collisions.
// For most purposes it can be considered unique.
// ID is a 24 long string.
std::string GetUniqueHexID();
};
#ifdef FEBASICAPPLICATION_SHARED
extern "C" __declspec(dllexport) void* GetUniqueID();
#define UNIQUE_ID (*static_cast<FEUniqueID*>(GetUniqueID()))
#else
#define UNIQUE_ID FEUniqueID::GetInstance()
#endif
}