parent
b47cd22185
commit
618c9c8a2d
@ -0,0 +1,15 @@
|
|||||||
|
[language]
|
||||||
|
select=Chinese
|
||||||
|
|
||||||
|
[COM]
|
||||||
|
Port=COM3
|
||||||
|
Baute=115200
|
||||||
|
|
||||||
|
[CheckThread]
|
||||||
|
days=7
|
||||||
|
days_dir=30
|
||||||
|
Enable=false
|
||||||
|
spacesize=10
|
||||||
|
|
||||||
|
[TrigDetector]
|
||||||
|
FilterTime=10
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef _H_LP_SINGLETON_BASE_H_
|
||||||
|
#define _H_LP_SINGLETON_BASE_H_
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class lp_singleton_base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static T* instance()
|
||||||
|
{
|
||||||
|
T *sin = s_this.load(std::memory_order_acquire);
|
||||||
|
|
||||||
|
if (!sin) {
|
||||||
|
std::lock_guard<std::mutex> locker(s_mutex);
|
||||||
|
sin = s_this.load(std::memory_order_relaxed);
|
||||||
|
if (!sin) {
|
||||||
|
sin = new T;
|
||||||
|
s_this.store(sin, std::memory_order_release);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void uninstance()
|
||||||
|
{
|
||||||
|
T *sin = s_this.load(std::memory_order_relaxed);
|
||||||
|
if (sin) {
|
||||||
|
std::lock_guard<std::mutex> locker(s_mutex);
|
||||||
|
delete sin;
|
||||||
|
sin = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
lp_singleton_base() = default;
|
||||||
|
virtual ~lp_singleton_base() = default;
|
||||||
|
private:
|
||||||
|
lp_singleton_base(const T&) = delete;
|
||||||
|
T& operator=(const T&) = delete;
|
||||||
|
|
||||||
|
static std::atomic<T*> s_this;
|
||||||
|
static std::mutex s_mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
std::atomic<T*> lp_singleton_base<T>::s_this;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
std::mutex lp_singleton_base<T>::s_mutex;
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
#include "lpSysConfig.h"
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QApplication>
|
||||||
|
lpSysConfig::lpSysConfig(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
m_AppPath = QApplication::applicationDirPath();
|
||||||
|
m_CfgPath = m_AppPath + QString("//user//systemConfig.ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
lpSysConfig::~lpSysConfig()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void lpSysConfig::readConfig()
|
||||||
|
{
|
||||||
|
QSettings setting(m_CfgPath, QSettings::IniFormat);
|
||||||
|
m_CurLanguage = setting.value("language/select", "Chinese").toString();
|
||||||
|
m_ComName = setting.value("COM/Port", "COM3").toString();
|
||||||
|
m_Baut = setting.value("COM/Baute", 115200).toInt();
|
||||||
|
|
||||||
|
m_CheckFileDays = setting.value("CheckThread/days", 7).toInt();
|
||||||
|
m_CheckDirDays = setting.value("CheckThread/days_dir", 30).toInt();
|
||||||
|
m_CheckEnable = setting.value("CheckThread/Enable", false).toBool();
|
||||||
|
m_MinSpaceSizeG = setting.value("CheckThread/spacesize", 10).toInt();//G
|
||||||
|
|
||||||
|
m_TrigerFilter = setting.value("TrigDetector/FilterTime", 10).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lpSysConfig::writeConfig()
|
||||||
|
{
|
||||||
|
QSettings setting(m_CfgPath, QSettings::IniFormat);
|
||||||
|
setting.setValue("language/select", m_CurLanguage);
|
||||||
|
setting.setValue("COM/Port", m_ComName);
|
||||||
|
setting.setValue("COM/Baute", m_Baut);
|
||||||
|
|
||||||
|
setting.setValue("CheckThread/days", m_CheckFileDays);
|
||||||
|
setting.setValue("CheckThread/days_dir", m_CheckDirDays);
|
||||||
|
setting.setValue("CheckThread/Enable", m_CheckEnable);
|
||||||
|
setting.setValue("CheckThread/spacesize", m_MinSpaceSizeG);//G
|
||||||
|
|
||||||
|
setting.setValue("TrigDetector/FilterTime", m_TrigerFilter);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue