1.给Singleton的模板加了点功能。
2.添加了处理DG的功能。 Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
67
testHasttable/dgmapping.cpp
Normal file
67
testHasttable/dgmapping.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "dgmapping.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
DGMapping::DGMapping()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DGMapping::~DGMapping()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DGMapping::load(const QString &filePath)
|
||||
{
|
||||
//格式
|
||||
//序号,名称,容量,所属Substation的ID
|
||||
QFile file(filePath);
|
||||
QString line;
|
||||
QStringList sep;
|
||||
if(file.open(QFile::ReadOnly))
|
||||
{
|
||||
QTextStream reader(&file);
|
||||
while(!reader.atEnd())
|
||||
{
|
||||
line=reader.readLine().trimmed();
|
||||
if(line.length()==0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sep=line.split(',');
|
||||
if(sep.length()<4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString name=sep.at(1);
|
||||
double capacity=sep.at(2).toDouble();
|
||||
QString attachedSubID=sep.at(3);
|
||||
QSharedPointer<DGInfo> t(new DGInfo);
|
||||
t->setName(name);
|
||||
t->setCapacity(capacity);
|
||||
t->setAttchedSubstaitonID(attachedSubID);
|
||||
QVector<QSharedPointer<DGInfo> >& vec=this->ht.get(attachedSubID);
|
||||
vec.push_back(t);
|
||||
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// QStringList keys;
|
||||
// keys=this->ht.keys();
|
||||
// foreach(QString k,keys)
|
||||
// {
|
||||
// std::cout<<this->ht.get(k).at(0)->getAttchedSubstaitonID().toStdString()<<std::endl;
|
||||
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user