KService

ksycocaentry.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1999 Waldo Bastian <[email protected]>
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 
21 class 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  */
32 class KSERVICE_EXPORT KSycocaEntry : public QSharedData
33 {
34 public:
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  */
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  * Returns the requested property. Some often used properties
91  * have convenience access functions like exec(),
92  * serviceTypes etc.
93  *
94  * @param name the name of the property
95  * @return the property, or invalid if not found
96  */
97  QVariant property(const QString &name) const;
98 
99  /**
100  * Returns the list of all properties that this service can have.
101  * That means, that some of these properties may be empty.
102  * @return the list of supported properties
103  */
104  QStringList propertyNames() const;
105 
106  /**
107  * Sets whether or not this service is deleted
108  */
109  void setDeleted(bool deleted);
110 
111  /**
112  * @returns true, if this is a separator
113  */
114  bool isSeparator() const;
115 
116 protected:
117  KSERVICE_NO_EXPORT explicit KSycocaEntry(KSycocaEntryPrivate &d);
118  std::unique_ptr<KSycocaEntryPrivate> const d_ptr;
119 
120 private:
121  // All these need access to offset()
122  friend class KSycocaFactory;
123  friend class KBuildServiceFactory;
124  friend class KServiceFactory;
125  friend class KMimeTypeTrader;
126  friend class KServiceTypeTrader;
127  friend class KService;
128  friend class KSycocaDict;
129  friend class KSycocaDictTest;
130 
131  /**
132  * @internal
133  * @return the position of the entry in the sycoca file
134  */
135  int offset() const;
136  // exported for KSycocaDictTest
137 
138  Q_DISABLE_COPY(KSycocaEntry)
139 
140  Q_DECLARE_PRIVATE(KSycocaEntry)
141 };
142 
143 #endif
QExplicitlySharedDataPointer< KSycocaEntry > Ptr
A shared data pointer for KSycocaEntry.
Definition: ksycocaentry.h:54
Base class for all Sycoca entries.
Definition: ksycocaentry.h:32
QList< Ptr > List
A list of shared data pointers for KSycocaEntry.
Definition: ksycocaentry.h:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:55:39 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.