1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#ifndef KSYCOCAENTRY_H
9#define KSYCOCAENTRY_H
10
11#include <kservice_export.h>
12#include <ksycocatype.h>
13
14#include <QDataStream>
15#include <QExplicitlySharedDataPointer>
16#include <QStringList>
17#include <QVariant>
18
19#include <memory>
20
21class KSycocaEntryPrivate;
22
23/**
24 * Base class for all Sycoca entries.
25 *
26 * You can't create an instance of KSycocaEntry, but it provides
27 * the common functionality for servicetypes and services.
28 *
29 * @internal
30 * @see http://techbase.kde.org/Development/Architecture/KDE3/System_Configuration_Cache
31 */
32class KSERVICE_EXPORT KSycocaEntry : public QSharedData
33{
34public:
35 /*
36 * constructs a invalid KSycocaEntry object
37 */
38 KSycocaEntry();
39
40 virtual ~KSycocaEntry();
41
42 /**
43 * Returns true if this sycoca entry is of the given type.
44 */
45 bool isType(KSycocaType t) const;
46 /**
47 * internal
48 */
49 KSycocaType sycocaType() const;
50
51 /**
52 * A shared data pointer for KSycocaEntry.
53 */
54 typedef QExplicitlySharedDataPointer<KSycocaEntry> Ptr;
55 /**
56 * A list of shared data pointers for KSycocaEntry.
57 */
58 typedef QList<Ptr> List;
59
60 /**
61 * @return the name of this entry
62 */
63 QString name() const;
64
65 /**
66 * @return the path of this entry
67 * The path can be absolute or relative.
68 * The corresponding factory should know relative to what.
69 */
70 QString entryPath() const;
71
72 /**
73 * @return the unique ID for this entry
74 * In practice, this is storageId() for KService and name() for everything else.
75 * \since 4.2.1
76 */
77 QString storageId() const;
78
79 /**
80 * @return true if valid
81 */
82 bool isValid() const;
83
84 /**
85 * @return true if deleted
86 */
87 bool isDeleted() const;
88
89 /**
90 * Sets whether or not this service is deleted
91 */
92 void setDeleted(bool deleted);
93
94 /**
95 * @returns true, if this is a separator
96 */
97 bool isSeparator() const;
98
99protected:
100 KSERVICE_NO_EXPORT explicit KSycocaEntry(KSycocaEntryPrivate &d);
101 std::unique_ptr<KSycocaEntryPrivate> const d_ptr;
102
103private:
104 // All these need access to offset()
105 friend class KSycocaFactory;
106 friend class KBuildServiceFactory;
107 friend class KServiceFactory;
108 friend class KService;
109 friend class KSycocaDict;
110 friend class KSycocaDictTest;
111
112 /**
113 * @internal
114 * @return the position of the entry in the sycoca file
115 */
116 KSERVICE_NO_EXPORT int offset() const;
117
118 Q_DISABLE_COPY(KSycocaEntry)
119
120 Q_DECLARE_PRIVATE(KSycocaEntry)
121};
122
123#endif
124

source code of kservice/src/sycoca/ksycocaentry.h