summaryrefslogtreecommitdiff
path: root/plugins/Db3x/src/dbintf3x.h
blob: eaeb80b16766f2345230b34ab2191ec09a44c7ef (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
62
63
64
65
66
67
68
69
70
71
72
73
74
/*

Miranda NG: the free IM client for Microsoft* Windows*

Copyright 2012-13 Miranda NG project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include <m_db_int.h>

#include "..\..\Db3x_mmap\src\database.h"
#include "..\..\Db3x_mmap\src\dbintf.h"

#define CACHESECTIONSIZE   4096
#define CACHESECTIONCOUNT  32

#define SETTINGSGROUPOFSCOUNT    32

struct CDb3x : public CDb3Base
{
	CDb3x(const TCHAR* tszFileName);
	~CDb3x();

	__inline HANDLE getFile() const { return m_hDbFile; }

protected:
	virtual	DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName);
	virtual	void InvalidateSettingsGroupOfsCacheEntry(DWORD ofsSettingsGroup);

	virtual	void  DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
	virtual	PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail);
	virtual	void  DBWrite(DWORD ofs, PVOID pData, int bytes);
	virtual	void  DBFill(DWORD ofs, int bytes);
	virtual	void  DBFlush(int setting);
	virtual	int   InitCache(void);

	PBYTE m_pDbCache;
	DWORD m_lastUseCounter;

	struct DBCacheSectionInfo
	{
		DWORD ofsBase;
		DWORD lastUsed;
	} 
	cacheSectionInfo[CACHESECTIONCOUNT];

	int nextSGOCacheEntry;
	struct SettingsGroupOfsCacheEntry {
		DWORD ofsContact;
		DWORD ofsModuleName;
		DWORD ofsSettingsGroup;
	}
	settingsGroupOfsCache[SETTINGSGROUPOFSCOUNT];

	int  FindSectionForOffset(const DWORD ofs);
	int  FindLRUSection(void);
	void LoadSection(const int i,DWORD ofs);
	void MoveSection(int *sectId,int dest);
};