mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
eliminated DaemonQTImpl singleton
This commit is contained in:
parent
f76c04b7a6
commit
4fc80fd366
3 changed files with 174 additions and 89 deletions
|
@ -3,27 +3,19 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
class Worker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void startDaemon();
|
||||
void restartDaemon();
|
||||
void stopDaemon();
|
||||
|
||||
signals:
|
||||
void resultReady();
|
||||
};
|
||||
|
||||
class DaemonQTImpl
|
||||
{
|
||||
public:
|
||||
|
||||
DaemonQTImpl ();
|
||||
~DaemonQTImpl ();
|
||||
|
||||
typedef void (*runningChangedCallback)();
|
||||
|
||||
/**
|
||||
|
@ -32,24 +24,51 @@ namespace qt
|
|||
* @param argv
|
||||
* @return success
|
||||
*/
|
||||
bool static init(int argc, char* argv[]);
|
||||
void static deinit();
|
||||
void static start();
|
||||
void static stop();
|
||||
void static restart();
|
||||
void static setRunningCallback(runningChangedCallback cb);
|
||||
bool static isRunning();
|
||||
bool init(int argc, char* argv[]);
|
||||
void deinit();
|
||||
void start();
|
||||
void stop();
|
||||
void restart();
|
||||
void setRunningCallback(runningChangedCallback cb);
|
||||
bool isRunning();
|
||||
private:
|
||||
void static setRunning(bool running);
|
||||
void setRunning(bool running);
|
||||
private:
|
||||
QMutex* mutex;
|
||||
bool m_IsRunning;
|
||||
runningChangedCallback m_RunningChangedCallback;
|
||||
};
|
||||
|
||||
class Worker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Worker (DaemonQTImpl& daemon);
|
||||
|
||||
private:
|
||||
|
||||
DaemonQTImpl& m_Daemon;
|
||||
|
||||
public slots:
|
||||
void startDaemon();
|
||||
void restartDaemon();
|
||||
void stopDaemon();
|
||||
|
||||
signals:
|
||||
void resultReady();
|
||||
};
|
||||
|
||||
class Controller : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QThread workerThread;
|
||||
public:
|
||||
Controller();
|
||||
Controller(DaemonQTImpl& daemon);
|
||||
~Controller();
|
||||
private:
|
||||
DaemonQTImpl& m_Daemon;
|
||||
|
||||
public slots:
|
||||
void handleResults(){}
|
||||
signals:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue