diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2023-07-09 17:36:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-09 17:36:03 +0200 |
| commit | ef94aee28464039672b277243a0181ae93550d6c (patch) | |
| tree | 0575a68af5f154e9d6d0738edbaefb16a11d6f5c /src/multiprocess.h | |
| parent | 7d6cb8528d20e36a4cee822263865ee2f7f32481 (diff) | |
| parent | 3de050e9c03e553f7ae3f780f6bd080a30ae123e (diff) | |
Merge pull request #1839 from Holt59/ci/initial-gh-action-for-build
Clang-Format + Github Workflow
Diffstat (limited to 'src/multiprocess.h')
| -rw-r--r-- | src/multiprocess.h | 132 |
1 files changed, 62 insertions, 70 deletions
diff --git a/src/multiprocess.h b/src/multiprocess.h index 810e63d2..3c641faa 100644 --- a/src/multiprocess.h +++ b/src/multiprocess.h @@ -1,70 +1,62 @@ -#ifndef MODORGANIZER_MOMULTIPROCESS_INCLUDED
-#define MODORGANIZER_MOMULTIPROCESS_INCLUDED
-
-#include <QObject>
-#include <QSharedMemory>
-#include <QLocalServer>
-
-
-/**
- * used to ensure only a single process of Mod Organizer is started and to
- * allow ephemeral processes to send messages to the primary (visible) one.
- * This way, other processes can start a download in the primary one
- **/
-class MOMultiProcess : public QObject
-{
- Q_OBJECT
-
-public:
- // `allowMultiple`: if another process is running, run this one
- // disconnected from the shared memory
- explicit MOMultiProcess(bool allowMultiple, QObject *parent = 0);
-
- /**
- * @return true if this process's job is to forward data to the primary
- * process through shared memory
- **/
- bool ephemeral() const
- {
- return m_Ephemeral;
- }
-
- // returns true if this is not the primary process, but was allowed because
- // of the AllowMultiple flag
- //
- bool secondary() const
- {
- return !m_Ephemeral && !m_OwnsSM;
- }
-
- /**
- * send a message to the primary process. This can be used to transmit download urls
- *
- * @param message message to send
- **/
- void sendMessage(const QString &message);
-
-signals:
-
- /**
- * @brief emitted when an ephemeral process has sent a message (to us)
- *
- * @param message the message we received
- **/
- void messageSent(const QString &message);
-
-public slots:
-
-private slots:
-
- void receiveMessage();
-
-private:
- bool m_Ephemeral;
- bool m_OwnsSM;
- QSharedMemory m_SharedMem;
- QLocalServer m_Server;
-
-};
-
-#endif // MODORGANIZER_MOMULTIPROCESS_INCLUDED
+#ifndef MODORGANIZER_MOMULTIPROCESS_INCLUDED +#define MODORGANIZER_MOMULTIPROCESS_INCLUDED + +#include <QLocalServer> +#include <QObject> +#include <QSharedMemory> + +/** + * used to ensure only a single process of Mod Organizer is started and to + * allow ephemeral processes to send messages to the primary (visible) one. + * This way, other processes can start a download in the primary one + **/ +class MOMultiProcess : public QObject +{ + Q_OBJECT + +public: + // `allowMultiple`: if another process is running, run this one + // disconnected from the shared memory + explicit MOMultiProcess(bool allowMultiple, QObject* parent = 0); + + /** + * @return true if this process's job is to forward data to the primary + * process through shared memory + **/ + bool ephemeral() const { return m_Ephemeral; } + + // returns true if this is not the primary process, but was allowed because + // of the AllowMultiple flag + // + bool secondary() const { return !m_Ephemeral && !m_OwnsSM; } + + /** + * send a message to the primary process. This can be used to transmit download urls + * + * @param message message to send + **/ + void sendMessage(const QString& message); + +signals: + + /** + * @brief emitted when an ephemeral process has sent a message (to us) + * + * @param message the message we received + **/ + void messageSent(const QString& message); + +public slots: + +private slots: + + void receiveMessage(); + +private: + bool m_Ephemeral; + bool m_OwnsSM; + QSharedMemory m_SharedMem; + QLocalServer m_Server; +}; + +#endif // MODORGANIZER_MOMULTIPROCESS_INCLUDED |
