1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __k_service_type_factory_h__
21#define __k_service_type_factory_h__
22
23#include <assert.h>
24
25#include <QtCore/QStringList>
26
27#include "ksycocafactory.h"
28#include "kservicetype.h"
29
30class KSycoca;
31
32class KServiceType;
33
34/**
35 * @internal
36 * A sycoca factory for service types
37 * It loads the service types from parsing directories (e.g. servicetypes/)
38 * but can also create service types from data streams or single config files
39 * @see KServiceType
40 *
41 * Exported for kbuildsycoca, but not installed.
42 */
43class KDECORE_EXPORT KServiceTypeFactory : public KSycocaFactory
44{
45 K_SYCOCAFACTORY( KST_KServiceTypeFactory )
46public:
47 /**
48 * Create factory
49 */
50 KServiceTypeFactory();
51
52 virtual ~KServiceTypeFactory();
53
54 /**
55 * Not meant to be called at this level
56 */
57 virtual KSycocaEntry *createEntry(const QString &, const char *) const
58 { assert(0); return 0; }
59
60 /**
61 * Find a service type in the database file (allocates it)
62 * Overloaded by KBuildServiceTypeFactory to return a memory one.
63 */
64 virtual KServiceType::Ptr findServiceTypeByName(const QString &_name);
65
66 /**
67 * Find a the property type of a named property.
68 */
69 QVariant::Type findPropertyTypeByName(const QString &_name);
70
71 /**
72 * @return all servicetypes
73 * Slow and memory consuming, avoid using
74 */
75 KServiceType::List allServiceTypes();
76
77 /**
78 * @return the unique servicetype factory, creating it if necessary
79 */
80 static KServiceTypeFactory * self();
81
82protected:
83 virtual KServiceType *createEntry(int offset) const;
84
85 // protected for KBuildServiceTypeFactory
86 QMap<QString,int> m_propertyTypeDict;
87
88protected:
89 virtual void virtual_hook( int id, void* data );
90private:
91 class KServiceTypeFactoryPrivate* d;
92};
93
94#endif
95