blob: 4156701c1fd3523a85c81fa0f5578c113f0c5cee (
plain)
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
|
#ifndef CLIENTIDMAPPER_H
#define CLIENTIDMAPPER_H
#include "Runtime/Utilities/dynamic_array.h"
#include "Runtime/GfxDevice/GfxDevice.h"
#if ENABLE_GFXDEVICE_REMOTE_PROCESS
#define ClientIDWrapper(type) ClientIDMapper::ClientID
#define ClientIDWrapperHandle(type) ClientIDMapper::ClientID
#else
#define ClientIDWrapper(type) type*
#define ClientIDWrapperHandle(type) type
#endif
class ClientIDMapper {
public:
typedef UInt32 ClientID;
ClientIDMapper() :
m_HighestAllocatedID(0)
{
}
ClientID CreateID()
{
if (m_FreeIDs.empty())
return ++m_HighestAllocatedID;
else
{
ClientID retval = m_FreeIDs.back();
m_FreeIDs.pop_back();
return retval;
}
}
void FreeID(ClientID cid)
{
m_FreeIDs.push_back(cid);
}
private:
ClientID m_HighestAllocatedID;
dynamic_array<ClientID> m_FreeIDs;
};
#endif
|