-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServerWindowMap.H
58 lines (47 loc) · 1.48 KB
/
ServerWindowMap.H
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
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _tag_ServerWindowMap_Entity {
HWND hWnd;
SockServ *pSrv;
} CLASSMAPENTITY, *LPCLASSMAPENTITY;
typedef struct _tag_ServerWindowMap_Entities {
CLASSMAPENTITY *Collection;
int Count;
} CLASSMAPENTITIES, *LPCLASSMAPENTITIES;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ServerWindowMap {
private:
CLASSMAPENTITIES Entities;
public:
ServerWindowMap()
{
Entities.Count = 0;
Entities.Collection = NULL;
}
~ServerWindowMap()
{
if(Entities.Count > 0)
{
free(Entities.Collection);
}
Entities.Count = 0;
}
void Upsert(HWND hWnd, SockServ *pSrv)
{
Entities.Count++;
Entities.Collection = (CLASSMAPENTITY*) realloc(Entities.Collection, sizeof(CLASSMAPENTITY) * Entities.Count);
Entities.Collection[Entities.Count - 1].hWnd = hWnd;
Entities.Collection[Entities.Count - 1].pSrv = pSrv;
}
SockServ *At(HWND hWnd)
{
for(int i = 0; i < Entities.Count; i++)
{
if(Entities.Collection[i].hWnd == hWnd)
{
return Entities.Collection[i].pSrv;
}
}
return NULL;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////