prospective fix for crashes induced by an invalidated iterator.
[kdelibs.git] / kded / kbuildservicefactory.h
blobbe8edbd8b85a7cc588bb803f221e7370fec12edc
1 /* This file is part of the KDE project
2 Copyright (C) 1999 David Faure <faure@kde.org>
3 1999 Waldo Bastian <bastian@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef __k_build_service_factory_h__
22 #define __k_build_service_factory_h__
24 #include <QtCore/QStringList>
26 #include <kservicefactory.h>
27 // We export the services to the service group factory!
28 #include "kbuildservicegroupfactory.h"
29 #include <QSet>
30 #include <kserviceoffer.h>
31 class KBuildMimeTypeFactory;
33 /**
34 * Service factory for building ksycoca
35 * @internal
37 class KBuildServiceFactory : public KServiceFactory
39 public:
40 /**
41 * Create factory
43 KBuildServiceFactory( KSycocaFactory *serviceTypeFactory,
44 KBuildMimeTypeFactory *mimeTypeFactory,
45 KBuildServiceGroupFactory *serviceGroupFactory );
47 virtual ~KBuildServiceFactory();
49 /// Reimplemented from KServiceFactory
50 virtual KService::Ptr findServiceByName(const QString &_name);
52 /**
53 * Construct a KService from a config file.
55 virtual KSycocaEntry * createEntry(const QString &file, const char *resource);
57 virtual KService * createEntry( int ) { assert(0); return 0; }
59 /**
60 * Add a new entry.
62 virtual void addEntry(const KSycocaEntry::Ptr& newEntry);
64 /**
65 * Write out service specific index files.
67 virtual void save(QDataStream &str);
69 /**
70 * Write out header information
72 * Don't forget to call the parent first when you override
73 * this function.
75 virtual void saveHeader(QDataStream &str);
77 /**
78 * Returns all resource types for this service factory
80 static QStringList resourceTypes();
82 void populateServiceTypes();
84 private:
85 void saveOfferList(QDataStream &str);
86 void addServiceOffer( const QString& serviceType, const KServiceOffer& offer );
88 QHash<QString, KService::Ptr> m_serviceDict;
89 QSet<KSycocaEntry::Ptr> m_dupeDict;
91 struct ServiceTypeOffersData {
92 QList<KServiceOffer> offers; // service + initial preference + allow as default
93 QSet<KService::Ptr> offerSet; // for quick contains() check
95 QHash<QString, ServiceTypeOffersData> m_serviceTypeData;
97 KSycocaFactory *m_serviceTypeFactory;
98 KBuildMimeTypeFactory *m_mimeTypeFactory;
99 KBuildServiceGroupFactory *m_serviceGroupFactory;
102 #endif