2
* eventdb.h - asynchronous I/O event database
3
* Copyright (C) 2001, 2002 Justin Karneges
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34
EDBItem(PsiEvent *, const QString &id, const QString &nextId, const QString &prevId);
37
PsiEvent *event() const;
38
const QString & id() const;
39
const QString & nextId() const;
40
const QString & prevId() const;
43
QString v_id, v_prevId, v_nextId;
47
class EDBResult : public QPtrList<EDBItem>
54
class EDBHandle : public QObject
63
void getLatest(const Jid &, int len);
64
void getOldest(const Jid &, int len);
65
void get(const Jid &jid, const QString &id, int direction, int len);
66
void find(const QString &, const Jid &, const QString &id, int direction);
67
void append(const Jid &, PsiEvent *);
70
const EDBResult *result() const;
71
bool writeSuccess() const;
72
int lastRequestType() const;
82
void edb_resultReady(EDBResult *);
83
void edb_writeFinished(bool);
84
int listeningFor() const;
87
class EDB : public QObject
91
enum { Forward, Backward };
96
int genUniqueId() const;
97
virtual int getLatest(const Jid &, int len)=0;
98
virtual int getOldest(const Jid &, int len)=0;
99
virtual int get(const Jid &jid, const QString &id, int direction, int len)=0;
100
virtual int append(const Jid &, PsiEvent *)=0;
101
virtual int find(const QString &, const Jid &, const QString &id, int direction)=0;
102
void resultReady(int, EDBResult *);
103
void writeFinished(int, bool);
109
friend class EDBHandle;
110
void reg(EDBHandle *);
111
void unreg(EDBHandle *);
113
int op_getLatest(const Jid &, int len);
114
int op_getOldest(const Jid &, int len);
115
int op_get(const Jid &, const QString &id, int direction, int len);
116
int op_find(const QString &, const Jid &, const QString &id, int direction);
117
int op_append(const Jid &, PsiEvent *);
120
class EDBFlatFile : public EDB
127
int getLatest(const Jid &, int len);
128
int getOldest(const Jid &, int len);
129
int get(const Jid &jid, const QString &id, int direction, int len);
130
int find(const QString &, const Jid &, const QString &id, int direction);
131
int append(const Jid &, PsiEvent *);
136
void performRequests();
143
File *findFile(const Jid &) const;
144
File *ensureFile(const Jid &);
147
class EDBFlatFile::File : public QObject
157
bool append(PsiEvent *);
163
void timer_timeout();
176
PsiEvent *lineToEvent(const QString &);
177
QString eventToLine(PsiEvent *);