Commit 001bcfee by Carwyn

1.设置模块独立项目上传

parent 44b2accd
#include "fmp_settings.h"
#include <QSettings>
#include <fmp_logger_i.h>
#include <ctkServiceReference.h>
#include <ctkPluginContext.h>
#include <QDebug>
/**
* @brief The FMPSettings class
*/
FMPSettings::FMPSettings(ctkPluginContext *context)
: d_ptr(new FMPSettingsPrivate(context))
{
StartService();
}
int FMPSettings::StartService()
{
return d_func()->DoStartService();
}
int FMPSettings::StopService()
{
return d_func()->DoStopService();
}
int FMPSettings::PostEvent(const QString &topic, const FMPProps &pps)
{
return FMP_SUCCESS;
}
QVariant FMPSettings::GetValue(const QString &k, QVariant default_val)
{
Q_D(FMPSettings);
return d->GetValue(k, default_val);
}
bool FMPSettings::SetValue(const QString &k, QVariant v)
{
Q_D(FMPSettings);
return d->SetValue(k, v);
}
/**
***************************************************************
*/
FMPSettingsPrivate::FMPSettingsPrivate(ctkPluginContext *ctx)
: _ctx(ctx),
_sets(0)
{
}
int FMPSettingsPrivate::DoStartService()
{
if (!_sets) {
_sets = new QSettings(_ctx->getProperty(FMP_PROPKEY_CFG).toString(), QSettings::IniFormat);
}
return FMP_SUCCESS;
}
int FMPSettingsPrivate::DoStopService()
{
if (_sets) {
delete _sets;
_sets = 0;
}
return FMP_SUCCESS;
}
QVariant FMPSettingsPrivate::GetValue(const QString &k, QVariant default_val)
{
return _sets->value(k, default_val);
}
bool FMPSettingsPrivate::SetValue(const QString &k, QVariant v)
{
_sets->setValue(k, v);
return (_sets->value(k) == v);
}
#ifndef FMP_SETTINGS_H
#define FMP_SETTINGS_H
#include "fmp_settings_i.h"
class ctkPluginContext;
class FMPSettingsPrivate;
/**
* @brief The FMPSettings class
*/
class FMPSettings : public QObject, public FMPSettingsInterface
{
Q_OBJECT
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPSettingsInterface)
Q_DECLARE_PRIVATE(FMPSettings)
public:
explicit FMPSettings(ctkPluginContext *context);
//! BaseInterface
int StartService();
int StopService();
protected:
int PostEvent(const QString &topic, const FMPProps &pps = FMPProps());
//! SettingsInterface
public:
QVariant GetValue(const QString &k, QVariant default_val);
bool SetValue(const QString&k, QVariant v);
private:
FMPSettingsPrivate *d_ptr;
};
class QSettings;
/**
* @brief The FMPSettingsPrivate class
*/
class FMPSettingsPrivate
{
Q_DECLARE_PUBLIC(FMPSettings)
public:
explicit FMPSettingsPrivate(ctkPluginContext *ctx);
int DoStartService();
int DoStopService();
QVariant GetValue(const QString &k, QVariant default_val);
bool SetValue(const QString&k, QVariant v);
public:
FMPSettings *q_ptr;
ctkPluginContext *_ctx;
QSettings *_sets;
};
#endif // FMP_SETTINGS_H
#-------------------------------------------------
#
# Project created by QtCreator 2017-01-11T15:59:15
#
#-------------------------------------------------
QT -= gui
TEMPLATE = lib
SOURCES += fmp_settings.cpp \
fmp_settings_plugin.cpp
HEADERS += fmp_settings.h \
fmp_settings_i.h \
fmp_settings_plugin_p.h \
fmp_settings_def.h
unix {
target.path = /usr/lib
INSTALLS += target
}
#Target name
VER = $$system($$PWD/../fmprc.bat $$TARGET)
ORIGIN_TARGET = $$TARGET
TARGET = $${TARGET}_$${VER}
#Header path
INCLUDEPATH += $$PWD/../include/ctk \
+= $$PWD/../include/interface \
#Library path
LIBS += -L$$PWD/../lib
CONFIG(debug, debug|release) {
#Linking library
LIBS += -lCTKCored -lCTKPluginFrameworkd
#Destination path
DESTDIR = $$PWD/../debug/plugins
} else {
LIBS += -lCTKCore -lCTKPluginFramework
DESTDIR = $$PWD/../release/plugins
}
#
RESOURCES += \
res/$${ORIGIN_TARGET}.qrc
win32 {
RC_FILE += res/$${ORIGIN_TARGET}.rc
system($$PWD/../fmprc.bat $$PWD/version.h $$ORIGIN_TARGET)
}
else {
system($$PWD/../fmprc.sh $$PWD/version.h $$ORIGIN_TARGET)
}
#ifndef FMP_SETTINGS_DEF_H
#define FMP_SETTINGS_DEF_H
//! 插件全局属性
#define FMP_PROPKEY_PLUGINPATH "FMPPath"
#define FMP_PROPKEY_CFG "FMPConfig"
#define FMP_PROPKEY_ENTRY "FMPEntry"
#define FMP_PROPKEY_PID "PMPPid"
//! 配置文件 Key
#define FMP_INIKEY_SERVICENAME "Service/Name"
#define FMP_INIKEY_SERVICEDESC "Service/Desc"
#define FMP_INIKEY_SERVICESTARTTYPE "Service/StartType"
#define FMP_INIKEY_ENTRYSERVICE "Plugin/EntryService"
#define FMP_INIKEY_PLUGINPATH "Plugin/Path"
#define FMP_INIKEY_LOGPATH "Log/Path"
#define FMP_INIKEY_LOGSIZE "Log/Size"
#define FMP_INIKEY_LOGLEVEL "Log/Level"
#define FMP_INIKEY_LOGINSERVER "Home/Server"
#define FMP_INIKEY_LOGINSTOREID "Home/StoreId"
#define FMP_INIKEY_LOGINPARTNERID "Home/PartnerId"
#define FMP_INIKEY_HOMEANIMATION "Home/Animation"
#define FMP_INIKEY_HOMEPOSITION "Home/Position"
#define FMP_INIKEY_SYNCNTERVAL "Syncer/Interval"
#endif // FMP_SETTINGS_DEF_H
#ifndef FMP_SETTINGS_I_H
#define FMP_SETTINGS_I_H
#include <QVariant>
#include <fmp_plugin_i.h>
#include "fmp_settings_def.h"
/**
* 非业务插件,必须继承自 BaseInterface
* @brief The FMPSettingsInterface class
*/
class FMPSettingsInterface : public FMPBaseInterface
{
public:
virtual QVariant GetValue(const QString& k, QVariant default_val = QVariant()) = 0;
virtual bool SetValue(const QString&k, QVariant v) = 0;
bool GetBool(const QString& k) { return GetValue(k).toBool(); }
int GetInt(const QString& k) { return GetValue(k).toInt(); }
uint GetUInt(const QString& k) { return GetValue(k).toUInt(); }
qint64 GetLong(const QString& k) { return GetValue(k).toLongLong(); }
quint64 GetULongLong(const QString& k) { return GetValue(k).toULongLong(); }
QByteArray GetBytes(const QString& k) { return GetValue(k).toByteArray(); }
QString GetString(const QString& k) { return GetValue(k).toString(); }
};
Q_DECLARE_INTERFACE(FMPSettingsInterface, "com.fmp.settings")
#endif // FMP_SETTINGS_I_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_settings.h"
#include "fmp_settings_plugin_p.h"
#include <QtPlugin>
#include <QStringList>
#include <QDebug>
FMPSettingsPlugin::FMPSettingsPlugin()
: _sets_service(0)
{
}
void FMPSettingsPlugin::start(ctkPluginContext* context)
{
_sets_service = new FMPSettings(context);
context->registerService<FMPSettingsInterface>(_sets_service);
}
void FMPSettingsPlugin::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
if (_sets_service)
{
delete _sets_service;
_sets_service = 0;
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2(com_fmp_settings, FMPSettingsPlugin)
#endif
#ifndef FMP_SETTINGS_PLUGIN_P_H
#define FMP_SETTINGS_PLUGIN_P_H
#include <ctkPluginActivator.h>
class FMPSettings;
class FMPSettingsPlugin : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
Q_PLUGIN_METADATA(IID "com_fmp_settings")
#endif
public:
explicit FMPSettingsPlugin();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
FMPSettings* _sets_service;
}; // FMPSettingsPlugin
#endif // FMP_SETTINGS_PLUGIN_P_H
Plugin-SymbolicName: fmp.settings
Plugin-Version: 0.1.0
Plugin-Name: fmp.settings
Plugin-Copyright: Freemud Ltd. Copyright (C) 2014-2017
Plugin-Vendor: Freemud
<RCC>
<qresource prefix="/fmp.settings/META-INF">
<file>MANIFEST.MF</file>
</qresource>
</RCC>
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by fmproxy_service.rc
// ¶һĬֵ
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
#ifndef _VERSION_H_
#define _VERSION_H_
#define VER_MAJOR 0
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 35
//! Convert version numbers to string
#define _STR(S) #S
#define STR(S) _STR(S)
#define _MAK_VER(maj, min, rev, build) STR(##maj.##min.##rev.##build\0)
#define MAK_VER(maj, min, rev, build) _MAK_VER(maj, min, rev, build)
//! Resource version infomation
#define RES_FILE_VER VER_MAJOR,VER_MINOR,VER_REVISION,VER_BUILD
#define RES_PRODUCT_VER VER_MAJOR,VER_MINOR,VER_REVISION,VER_BUILD
#define RES_STR_FILE_VER MAK_VER(VER_MAJOR, VER_MINOR, VER_REVISION, VER_BUILD)
#define RES_STR_PRODUCT_VER MAK_VER(VER_MAJOR, VER_MINOR, VER_REVISION, VER_BUILD)
#define RES_COMPANY_NAME "上海非码网络科技有限公司\0"
#define RES_COPYRIGHT "Freemud Ltd. Copyright (C) 2014-2017\0"
#define RES_FILE_DESC "fmp.settings\0"
#define RES_INTER_NAME "fmp.settings\0"
#define RES_FILE_NAME "fmp.settings\0"
#define RES_PRODUCT_NAME "fmp.settings\0"
#define RES_FILE_EXT "*\0"
#endif //!_VERSION_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