把LoadMapping中的几个表做出单例。
Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
parent
56da69b835
commit
372e24400b
|
|
@ -1,13 +1,23 @@
|
||||||
#include "loadmapping.h"
|
#include "loadmapping.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
QHash<QString,QVector<double> > *LoadMapping::ht=NULL;
|
QHash<QString,QVector<QSharedPointer<LoadInfo> > > *LoadMapping::loads=NULL;
|
||||||
|
QHash<QString,QSharedPointer<LoadInfo> > *LoadMapping::loadsToLoadInfo=NULL;
|
||||||
LoadMapping::LoadMapping()
|
LoadMapping::LoadMapping()
|
||||||
{
|
{
|
||||||
if(!LoadMapping::ht)
|
// if(!LoadMapping::ht)
|
||||||
|
// {
|
||||||
|
// LoadMapping::ht=new QHash<QString,QVector<double> >;
|
||||||
|
// }
|
||||||
|
if(!LoadMapping::loads)
|
||||||
{
|
{
|
||||||
LoadMapping::ht=new QHash<QString,QVector<double> >;
|
LoadMapping::loads=new QHash<QString,QVector<QSharedPointer<LoadInfo> > >;
|
||||||
}
|
}
|
||||||
|
if(!LoadMapping::loadsToLoadInfo)
|
||||||
|
{
|
||||||
|
LoadMapping::loadsToLoadInfo=new QHash<QString,QSharedPointer<LoadInfo> >;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,10 +26,15 @@ LoadMapping::~LoadMapping()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadMapping::broadcastUpdateByTime(const QTime& time)
|
||||||
|
{
|
||||||
|
// this->ht
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile)
|
bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(LoadMapping::ht->keys().length()>0)
|
if(LoadMapping::loadsToLoadInfo->keys().length()>0)
|
||||||
{
|
{
|
||||||
return true;//只执行一次
|
return true;//只执行一次
|
||||||
}
|
}
|
||||||
|
|
@ -81,12 +96,12 @@ bool LoadMapping::readLoads(const QString &dir)
|
||||||
std::cout<<"ignore "<<fileName.toLocal8Bit().data()<<std::endl;
|
std::cout<<"ignore "<<fileName.toLocal8Bit().data()<<std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!this->loadsToLoadInfo.contains(fileName))
|
if(!this->loadsToLoadInfo->contains(fileName))
|
||||||
{
|
{
|
||||||
std::cout<<filePath.toLocal8Bit().data()<<" no match."<<std::endl;
|
std::cout<<filePath.toLocal8Bit().data()<<" no match."<<std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QSharedPointer<LoadInfo> loadInfo=this->loadsToLoadInfo[fileName];
|
QSharedPointer<LoadInfo> loadInfo=(*this->loadsToLoadInfo)[fileName];
|
||||||
loadInfo->setLoadPath(filePath);
|
loadInfo->setLoadPath(filePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -136,9 +151,9 @@ bool LoadMapping::readMatch(const QString& dir)
|
||||||
QSharedPointer<LoadInfo> t(new LoadInfo);
|
QSharedPointer<LoadInfo> t(new LoadInfo);
|
||||||
t->setLoadName(sep.at(i));
|
t->setLoadName(sep.at(i));
|
||||||
loads.push_back(t);
|
loads.push_back(t);
|
||||||
this->loadsToLoadInfo[sep.at(i)]=t;
|
(*this->loadsToLoadInfo)[sep.at(i)]=t;
|
||||||
}
|
}
|
||||||
this->loads[SFDid]=loads;
|
(*this->loads)[SFDid]=loads;
|
||||||
|
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
#include "recursedir.h"
|
#include "recursedir.h"
|
||||||
#include "loadinfo.h"
|
#include "loadinfo.h"
|
||||||
|
|
@ -21,6 +23,7 @@ class LoadMapping
|
||||||
public:
|
public:
|
||||||
LoadMapping();
|
LoadMapping();
|
||||||
~LoadMapping();
|
~LoadMapping();
|
||||||
|
bool broadcastUpdateByTime(const QTime& time);
|
||||||
bool load(const QString& loadDir, const QString &matchdDir, const QString &exceptionFile);
|
bool load(const QString& loadDir, const QString &matchdDir, const QString &exceptionFile);
|
||||||
bool readLoads(const QString& dir);
|
bool readLoads(const QString& dir);
|
||||||
bool readMatch(const QString& dir);
|
bool readMatch(const QString& dir);
|
||||||
|
|
@ -30,14 +33,16 @@ private:
|
||||||
public:
|
public:
|
||||||
~CG()
|
~CG()
|
||||||
{
|
{
|
||||||
if (LoadMapping::ht)
|
if (LoadMapping::loadsToLoadInfo)
|
||||||
delete LoadMapping::ht;
|
delete LoadMapping::loadsToLoadInfo;
|
||||||
|
if (LoadMapping::loads)
|
||||||
|
delete LoadMapping::loads;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
||||||
static QHash<QString,QVector<double> > *ht;
|
// static QHash<QString,QVector<double> > *ht;//
|
||||||
QHash<QString,QVector<QSharedPointer<LoadInfo> > > loads;
|
static QHash<QString,QVector<QSharedPointer<LoadInfo> > > *loads;//保存的是一个Substation下面的所有负荷信息
|
||||||
QHash<QString,QSharedPointer<LoadInfo> > loadsToLoadInfo;
|
static QHash<QString,QSharedPointer<LoadInfo> > *loadsToLoadInfo;
|
||||||
LoadMatchException loadMatchException;
|
LoadMatchException loadMatchException;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue