blob: 905ba4b469c3760b7909d8db78608679b2a020cc (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#ifndef __contact_cache__
#define __contact_cache__
class CContactCache
{
public:
enum { INFOSIZE = 1024 };
private:
struct TContactInfo
{
HANDLE hContact;
float rate;
TCHAR info[INFOSIZE];
bool infoLoaded;
static int cmp(const TContactInfo *p1, const TContactInfo *p2)
{
if (p1->rate > p2->rate) return -1;
if (p1->rate < p2->rate) return 1;
return 0;
}
static int cmp2(const void *a1, const void *a2)
{
return cmp(*(const TContactInfo **)a1, *(const TContactInfo **)a2);
}
TContactInfo()
{
info[0] = info[1] = 0;
infoLoaded = false;
}
void LoadInfo();
};
OBJLIST<TContactInfo> m_cache;
unsigned long m_lastUpdate;
CRITICAL_SECTION m_cs;
HANDLE m_hOnDbEventAdded;
int __cdecl OnDbEventAdded(WPARAM wParam, LPARAM lParam);
float GetEventWeight(unsigned long age);
float GetTimeWeight(unsigned long age);
public:
CContactCache();
~CContactCache();
void Lock() { EnterCriticalSection(&m_cs); }
void Unlock() { LeaveCriticalSection(&m_cs); }
void Rebuild();
HANDLE get(int rate);
float getWeight(int rate);
bool filter(int rate, TCHAR *str);
};
#endif // __contact_cache__
|