Commit db092a87 by Carwyn

Fixes: 1. 同步模块插件化框架上传; 2. 日志插件启动逻辑修正

parent 6773474f
......@@ -6,5 +6,5 @@ StartType=0
[Plugin]
Path=../plugins
Entry=fmp.manager
Entry=
Suffix=.dll
\ No newline at end of file
......@@ -31,12 +31,12 @@ public:
void start()
{
QString entry_plugin = getPluginPath(_entry_plugin);
QPluginLoader fmp_manager_plugin(entry_plugin);
QString manager_plugin_path = getPluginPath("fmp.manager");
QPluginLoader fmp_manager_plugin(manager_plugin_path);
FMPManagerInterface *fmp_manager = qobject_cast<FMPManagerInterface*>(fmp_manager_plugin.instance());
if (!fmp_manager) {
QString msg = "Failed loading plugin:\n";
msg += entry_plugin + "\n";
msg += manager_plugin_path + "\n";
msg += fmp_manager_plugin.errorString();
logMessage(msg , QtServiceBase::Error);
}
......@@ -44,6 +44,8 @@ public:
FMPProps props;
props["cfg_file"] = _setting->fileName();
fmp_manager->Init(props);
//! 启动业务插件
fmp_manager->StartPlugin(_entry_plugin);
}
}
......
......@@ -23,7 +23,7 @@
#include "fmp_logger_p.h"
FMPLogger::FMPLogger(ctkPluginContext *context)
: d_ptr(new FMPLoggerPrivate),
: d_ptr(new FMPLoggerPrivate(this)),
_inited(false),
_ctx(context)
{
......
......@@ -5,6 +5,12 @@
#include <ctkPluginContext.h>
#include <ctkServiceReference.h>
FMPLoggerPrivate::FMPLoggerPrivate(FMPLogger *q)
: q_ptr(q)
{
}
int FMPLoggerPrivate::Init()
{
Q_Q(FMPLogger);
......
......@@ -7,7 +7,7 @@ class FMPLoggerPrivate
{
Q_DECLARE_PUBLIC(FMPLogger)
public:
explicit FMPLoggerPrivate(FMPLogger *q);
int Init();
int Uninit();
int GetMaxFilesize();
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 3
#define VER_BUILD 4
//! Convert version numbers to string
#define _STR(S) #S
......
......@@ -29,6 +29,7 @@ int FMPluginManager::Init(const FMPProps &props)
{
if (_fw_factory) return FMP_SUCCESS;
_fw_props = props;
_fw_factory = new ctkPluginFrameworkFactory(props);
_fw = _fw_factory->getFramework();
......@@ -44,6 +45,7 @@ int FMPluginManager::Init(const FMPProps &props)
StartPlugin("fmp.logger");
StartPlugin("fmp.settings");
StartPlugin("fmp.synchronizer");
}
catch(const ctkPluginException& e) {
qCritical() << e.cause()->what();
......@@ -106,7 +108,8 @@ int FMPluginManager::StartPlugin(const QString &plugin)
if (pluginPath.isEmpty()) throw ctkPluginException("Invalid plugin path");
ctkPluginContext* pc = _fw->getPluginContext();
pc->installPlugin(QUrl::fromLocalFile(pluginPath))->start(ctkPlugin::START_TRANSIENT);
QSharedPointer<ctkPlugin> p = pc->installPlugin(QUrl::fromLocalFile(pluginPath));
if (!p.isNull()) p->start(ctkPlugin::START_TRANSIENT);
}
else {
qWarning() << "Failed to start plugin" << plugin;
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 3
#define VER_BUILD 4
//! Convert version numbers to string
#define _STR(S) #S
......
#include "fmp_synchronizer.h"
#include "fmp_synchronizer_p.h"
FMPSynchronizer::FMPSynchronizer()
FMPSynchronizer::FMPSynchronizer(ctkPluginContext *ctx)
:d_ptr(new FMPSynchronizerPrivate(this))
{
}
#ifndef FMP_SYNCHRONIZER_H
#define FMP_SYNCHRONIZER_H
#include <QObject>
#include "fmp_synchronizer_i.h"
class FMPSynchronizer
class ctkPluginContext;
class FMPSynchronizerPrivate;
class FMPSynchronizer : public QObject, public FMPSyncInterface
{
Q_OBJECT
Q_INTERFACES(FMPSyncInterface)
Q_DECLARE_PRIVATE(FMPSynchronizer)
public:
explicit FMPSynchronizer(ctkPluginContext *ctx);
//! BaseInterface
int Init(const FMPProps &props) { return FMP_SUCCESS; }
int Uninit() { return FMP_SUCCESS; }
int Upgrade() { return 0; }
int Downgrade() { return 0; }
public slots:
void OnUpgraded() {}
public:
FMPSynchronizer();
//! SyncInterface
void Sync() {}
private:
FMPSynchronizerPrivate *d_ptr;
};
#endif // FMP_SYNCHRONIZER_H
......@@ -9,11 +9,16 @@ TEMPLATE = lib
SOURCES += \
fmp_synchronizer.cpp \
fmupdater.cpp
fmupdater.cpp \
fmp_synchronizer_plugin.cpp \
fmp_synchronizer_p.cpp
HEADERS += \
fmp_synchronizer.h \
fmupdater.h
fmupdater.h \
fmp_synchronizer_plugin_p.h \
fmp_synchronizer_i.h \
fmp_synchronizer_p.h
unix {
target.path = /usr/lib
......
#ifndef FMP_SYNCHRONIZER_I_H
#define FMP_SYNCHRONIZER_I_H
#include <fmp_base_i.h>
class FMPSyncInterface : public FMPluginInterface
{
public:
virtual void Sync() = 0;
};
Q_DECLARE_INTERFACE(FMPSyncInterface, "fmp.synchronizer")
#endif // FMP_SYNCHRONIZER_I_H
#include "fmp_synchronizer_p.h"
#ifndef FMP_SYNCHRONIZER_P_H
#define FMP_SYNCHRONIZER_P_H
#include "fmp_synchronizer.h"
class FMPSynchronizerPrivate
{
Q_DECLARE_PUBLIC(FMPSynchronizer)
public:
explicit FMPSynchronizerPrivate(FMPSynchronizer *q) : q_ptr(q) {}
public:
FMPSynchronizer *q_ptr;
};
#endif // FMP_SYNCHRONIZER_P_H
/*=============================================================================
Library: CTK
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=============================================================================*/
#include "fmp_synchronizer_plugin_p.h"
#include "fmp_synchronizer.h"
#include <QtPlugin>
#include <QStringList>
#include <QDebug>
FMPSyncPlugin::FMPSyncPlugin()
: _sync_service(0)
{
}
void FMPSyncPlugin::start(ctkPluginContext* context)
{
_sync_service = new FMPSynchronizer(context);
context->registerService(QStringList("FMPSyncInterface"), _sync_service);
}
void FMPSyncPlugin::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
if (_sync_service)
{
delete _sync_service;
_sync_service = 0;
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2(fmp_synchronizer, FMPSyncPlugin)
#endif
#ifndef FMP_LOGGER_PLUGIN_P_H
#define FMP_LOGGER_PLUGIN_P_H
#include <ctkPluginActivator.h>
class FMPSynchronizer;
class FMPSyncPlugin : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
Q_PLUGIN_METADATA(IID "fmp_synchronizer")
#endif
public:
explicit FMPSyncPlugin();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
FMPSynchronizer* _sync_service;
}; // FMPLoggerPlugin
#endif // FMP_LOGGER_PLUGIN_P_H
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 3
#define VER_BUILD 4
//! Convert version numbers to string
#define _STR(S) #S
......
......@@ -50,6 +50,8 @@ Q_DECLARE_INTERFACE(FMPluginInterface, "com.fm.base")
#define FwServiceRef(Fw, Class) _FwServiceRef(Fw, Class##Interface)
#define _CtxServiceRef(Ctx, Class) Ctx->getServiceReference(#Class)
#define CtxServiceRef(Ctx, Class) _CtxServiceRef(Ctx, Class##Interface)
#define CtxService(Ctx, Ref) Ctx->getService(Ref)
#define FwService(Fw, Ref) Fw->getPluginContext()->getService(Ref)
#endif // FMP_BASE_I_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment