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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/* This file is part of the KDE libraries
* Copyright (C) 1999 Waldo Bastian <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation;
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef __tdesycocafactory_h__
#define __tdesycocafactory_h__
#include "tdesycocatype.h"
#include "tdesycocaentry.h"
#include <tqdict.h>
#include <tqptrlist.h>
class KSycoca;
class TQStringList;
class TQString;
class KSycocaDict;
class KSycocaResourceList;
typedef TQDict<KSycocaEntry::Ptr> KSycocaEntryDict;
/**
* @internal
* Base class for sycoca factories
*/
class TDECORE_EXPORT KSycocaFactory
{
public:
virtual KSycocaFactoryId factoryId() const = 0;
protected: // virtual class
/**
* Create a factory which can be used to lookup from/create a database
* (depending on KSycoca::isBuilding())
*/
KSycocaFactory( KSycocaFactoryId factory_id );
public:
virtual ~KSycocaFactory();
/**
* @return the position of the factory in the sycoca file
*/
int offset() { return mOffset; }
/**
* @return the dict, for special use by KBuildSycoca
*/
KSycocaEntryDict * entryDict() { return m_entryDict; }
/**
* Construct an entry from a config file.
* To be implemented in the real factories.
*/
virtual KSycocaEntry *createEntry(const TQString &file, const char *resource) = 0;
/**
* Add an entry
*/
virtual void addEntry(KSycocaEntry *newEntry, const char *resource);
/**
* Remove an entry
* Not very fast, use with care. O(N)
*/
void removeEntry(KSycocaEntry *newEntry);
/**
* Read an entry from the database
*/
virtual KSycocaEntry *createEntry(int offset)=0;
/**
* Get a list of all entries from the database.
*/
KSycocaEntry::List allEntries();
/**
* Saves all entries it maintains as well as index files
* for these entries to the stream 'str'.
*
* Also sets mOffset to the starting position.
*
* The stream is positioned at the end of the last index.
*
* Don't forget to call the parent first when you override
* this function.
*/
virtual void save(TQDataStream &str);
/**
* Writes out a header to the stream 'str'.
* The baseclass positions the stream correctly.
*
* Don't forget to call the parent first when you override
* this function.
*/
virtual void saveHeader(TQDataStream &str);
/**
* @return the resources for which this factory is responsible.
*/
virtual const KSycocaResourceList * resourceList() const { return m_resourceList; }
private:
int mOffset;
protected:
int m_sycocaDictOffset;
int m_beginEntryOffset;
int m_endEntryOffset;
TQDataStream *m_str;
KSycocaResourceList *m_resourceList;
KSycocaEntryDict *m_entryDict;
KSycocaDict *m_sycocaDict;
protected:
virtual void virtual_hook( int id, void* data );
};
/** This, instead of a typedef, allows to declare "class ..." in header files
* @internal
*/
class TDECORE_EXPORT KSycocaFactoryList : public TQPtrList<KSycocaFactory>
{
public:
KSycocaFactoryList() { }
};
#endif
|