File indexing completed on 2024-04-28 04:37:25

0001 /*
0002     SPDX-FileCopyrightText: 2013 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef SESSIONLOCK_H
0008 #define SESSIONLOCK_H
0009 
0010 #include <interfaces/isessionlock.h>
0011 #include <QLockFile>
0012 
0013 namespace KDevelop {
0014 
0015 struct SessionRunInfo;
0016 struct TryLockSessionResult;
0017 
0018 class SessionLock : public ISessionLock
0019 {
0020 public:
0021     /**
0022      * \copydoc SessionController::tryLockSession
0023      *
0024      * @param doLocking whether to actually try to lock or whether to only get
0025      *                  information about whether the session could be locked
0026      */
0027     static TryLockSessionResult tryLockSession(const QString& sessionId, bool doLocking);
0028 
0029     /**
0030      * \copydoc SessionController::handleLockedSession
0031      */
0032     static QString handleLockedSession( const QString& sessionName,
0033                                         const QString& sessionId,
0034                                         const SessionRunInfo& runInfo );
0035 
0036     QString id() override;
0037 
0038     ~SessionLock() override;
0039 
0040     /**
0041      * Release the lock file and remove the session directory from disk.
0042      */
0043     void removeFromDisk();
0044 
0045 private:
0046     SessionLock(const QString& sessionId, const QSharedPointer<QLockFile>& lockFile);
0047     const QString m_sessionId;
0048     QSharedPointer<QLockFile> m_lockFile;
0049 };
0050 
0051 }
0052 
0053 #endif // SESSIONLOCK_H