summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/threaded/WorkerIDMapper.h
blob: 9b563f5114786ab82049e7c4a976e3b0f1e9495c (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
#ifndef WORKERIDMAPPER_H
#define WORKERIDMAPPER_H

#include "ClientIDMapper.h"
#include "Runtime/Utilities/dynamic_array.h"

template <class T>
class WorkerIDMapper {
public:

	WorkerIDMapper ()
	{
		(*this)[0] = NULL;
	}
	
	T*& operator [] (ClientIDMapper::ClientID cid)
	{
		if (m_IDMapping.size() <= cid)
			m_IDMapping.resize_uninitialized(cid+1);
		return m_IDMapping[cid];
	}
	
private:
	dynamic_array<T*> m_IDMapping;
};

#if ENABLE_GFXDEVICE_REMOTE_PROCESS
#define WorkerIDWrapper(type,val) m_##type##Mapper[val]
#else
#define WorkerIDWrapper(type,val) val
#endif

#endif