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