Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ServiceThread.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ServiceThread.h"
4#include <QLoggingCategory>
5
6Q_DECLARE_LOGGING_CATEGORY(Service)
7
8CServiceThread::CServiceThread(CPluginService *pPlugin, QObject *parent)
9 : QThread(parent),
10 m_pPlugin(pPlugin)
11{
12}
13
14CServiceThread::~CServiceThread()
15{
16 qDebug(Service) << "CServiceThread::~CServiceThread()";
17}
18
19void CServiceThread::run()
20{
21 CService* pService = m_pPlugin->NewService();
22 if(!pService)
23 {
24 qCritical(Service) << "GetService fail";
25 return;
26 }
27 qInfo(Service) << "The service" << m_pPlugin->Name() << "is start";
28
29 int nRet = pService->Init();
30 if(nRet)
31 {
32 qWarning(Service) << "The service" << m_pPlugin->Name() << "initial fail";
33 return;
34 }
35
36 exec();
37
38 qInfo(Service) << "The service" << m_pPlugin->Name() << "is stop";
39
40 pService->Clean();
41 pService->deleteLater();
42}
The service plugin interface.
virtual CService * NewService()=0
New service.
virtual const QString Name() const =0
This name must be the same as the project name (${PROJECT_NAME}).
The service interface.
Definition Service.h:38
virtual int Init()
Load parameters, support non-Qt event loop.
Definition Service.cpp:24