1.修复小bug
2.增加Node到Terminal的映射。 Signed-off-by: facat@lab.com <facat@lab.com>
This commit is contained in:
parent
a27b938085
commit
53416f8f33
|
|
@ -4,3 +4,5 @@
|
|||
debug
|
||||
release
|
||||
Makefile*
|
||||
testHasttable/*Debug
|
||||
testHasttable/*Release
|
||||
|
|
@ -33,18 +33,28 @@ bool BasicElementInfo::parseBasicInfo(QXmlStreamReader &reader)
|
|||
QStringRef id;
|
||||
elementName=reader.name();
|
||||
this->name=elementName.toString();
|
||||
this->id=id.toString();
|
||||
qDebug()<<reader.name()<<"\n";
|
||||
if(reader.attributes().hasAttribute("rdf:ID"))
|
||||
{
|
||||
qDebug()<<reader.attributes().value("rdf:ID")<<"\n";
|
||||
id=reader.attributes().value("rdf:ID");
|
||||
this->id=id.toString();
|
||||
}
|
||||
|
||||
// if(elementName.toString()=="Terminal")
|
||||
// {
|
||||
// if(reader.attributes().hasAttribute("rdf:ID"))
|
||||
// {
|
||||
// std::cout<<this->id.toStdString()<<std::endl;
|
||||
// std::cout<<"get id"<<std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout<<"no ID"<<std::endl;
|
||||
// }
|
||||
// }
|
||||
while(!reader.atEnd() && !reader.hasError())
|
||||
{
|
||||
reader.readNext();
|
||||
elementName=reader.name();
|
||||
this->derivedParse(reader);
|
||||
if(reader.isEndElement() && reader.name()==elementName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,16 +7,23 @@ BusbarSection::BusbarSection(QObject *parent):BasicElementInfo(parent)
|
|||
|
||||
bool BusbarSection::derivedParse(QXmlStreamReader& reader)
|
||||
{
|
||||
// std::cout<<reader.name().toString().toStdString()<<std::endl;
|
||||
if("ConductingEquipment.Terminals"==reader.name() && reader.attributes().hasAttribute("rdf:resource"))
|
||||
{
|
||||
QString terminal;
|
||||
terminal=reader.attributes().value("rdf:resource").toString();
|
||||
this->terminal=terminal.replace("#","").leftRef(-1).toString();//返回整个字符串的Ref
|
||||
qDebug()<<"got "<<"ConductingEquipment.Terminals "<<this->terminal<<"\n";
|
||||
// std::cout<<"ConductingEquipment.Terminals"<<this->terminal.toStdString()<<std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BusbarSection::getTerminal()
|
||||
{
|
||||
return this->terminal;
|
||||
}
|
||||
|
||||
bool BusbarSection::parse(QXmlStreamReader& reader)
|
||||
{
|
||||
// std::cout<<"BusbarSection"<<std::endl;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class BusbarSection:public BasicElementInfo
|
|||
public:
|
||||
explicit BusbarSection(QObject *parent = 0);
|
||||
virtual bool parse(QXmlStreamReader& reader);
|
||||
QString getTerminal();
|
||||
protected:
|
||||
QString terminal;
|
||||
virtual bool derivedParse(QXmlStreamReader& reader);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,13 @@ bool ElementHashtable::goPath()
|
|||
BasicElementInfo *p=ht[*ite];
|
||||
if(p->getName()=="BusbarSection")
|
||||
{
|
||||
std::cout<<"BusbarSection"<<"\n";
|
||||
// std::cout<<"BusbarSection"<<"\n";
|
||||
BusbarSection *foo=static_cast<BusbarSection *>(p);
|
||||
QString terminal=foo->getTerminal();
|
||||
//找Terminal的东西
|
||||
Terminal *terminalP=static_cast<Terminal *>(ht[terminal]);
|
||||
std::cout<<terminalP->getID().toStdString()<<std::endl;
|
||||
// std::cout<<terminalP->getConductingEquipment().toStdString()<<std::endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
#include "nodetoterminal.h"
|
||||
QHash<QString,QString> *NodeToTerminal::ht=NULL;
|
||||
NodeToTerminal::NodeToTerminal()
|
||||
{
|
||||
if(!NodeToTerminal::ht)
|
||||
{
|
||||
NodeToTerminal::ht=new QHash<QString,QString>;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeToTerminal::add(const QString& key,const QString& value)
|
||||
{
|
||||
(*NodeToTerminal::ht)[key]=value;
|
||||
}
|
||||
|
||||
bool NodeToTerminal::contains(const QString& key)
|
||||
{
|
||||
return NodeToTerminal::ht->contains(key);
|
||||
}
|
||||
|
||||
QString NodeToTerminal::value(const QString& key)
|
||||
{
|
||||
return NodeToTerminal::ht->value(key);
|
||||
}
|
||||
|
||||
NodeToTerminal::~NodeToTerminal()
|
||||
{
|
||||
if(NodeToTerminal::ht)
|
||||
{
|
||||
delete NodeToTerminal::ht;
|
||||
NodeToTerminal::ht=NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef NODETOTERMINAL_H
|
||||
#define NODETOTERMINAL_H
|
||||
//一个通过Node检索Terminal的表,做成单例形式
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
class NodeToTerminal
|
||||
{
|
||||
public:
|
||||
explicit NodeToTerminal();
|
||||
~NodeToTerminal();
|
||||
void add(const QString& key,const QString& value);
|
||||
bool contains(const QString& key);
|
||||
QString value(const QString& key);
|
||||
private:
|
||||
static QHash<QString,QString> *ht;
|
||||
|
||||
|
||||
};
|
||||
#endif // NODETOTERMINAL_H
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
INPUT(
|
||||
./debug/main.o
|
||||
./debug/elementhashtable.o
|
||||
./debug/subcontrolarea.o
|
||||
./debug/BasicElementInfo.o
|
||||
./debug/regexextract.o
|
||||
./debug/busbarsection.o
|
||||
./debug/terminal.o
|
||||
./debug/aclinesegment.o
|
||||
./debug/breaker.o
|
||||
./debug/compensator.o
|
||||
./debug/disconnector.o
|
||||
./debug/powertransformer.o
|
||||
./debug/synchronousmachine.o
|
||||
./debug/moc_elementhashtable.o
|
||||
./debug/moc_BasicElementInfo.o
|
||||
);
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
INPUT(
|
||||
./release/main.o
|
||||
./release/elementhashtable.o
|
||||
./release/subcontrolarea.o
|
||||
./release/BasicElementInfo.o
|
||||
./release/regexextract.o
|
||||
./release/busbarsection.o
|
||||
./release/terminal.o
|
||||
./release/aclinesegment.o
|
||||
./release/breaker.o
|
||||
./release/compensator.o
|
||||
./release/disconnector.o
|
||||
./release/powertransformer.o
|
||||
./release/synchronousmachine.o
|
||||
./release/moc_elementhashtable.o
|
||||
./release/moc_BasicElementInfo.o
|
||||
);
|
||||
|
|
@ -4,6 +4,8 @@ Terminal::Terminal(QObject *parent):BasicElementInfo(parent)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Terminal::derivedParse(QXmlStreamReader& reader)
|
||||
{
|
||||
if("Terminal.ConnectivityNode"==reader.name() && reader.attributes().hasAttribute("rdf:resource"))
|
||||
|
|
@ -12,6 +14,8 @@ bool Terminal::derivedParse(QXmlStreamReader& reader)
|
|||
cn=reader.attributes().value("rdf:resource").toString();
|
||||
this->connectivityNode=cn.replace("#","").leftRef(-1).toString();//返回整个字符串的Ref
|
||||
qDebug()<<"got "<<"Terminal.ConnectivityNode "<<this->connectivityNode<<"\n";
|
||||
NodeToTerminal nt;
|
||||
nt.add(this->connectivityNode,this->id);
|
||||
}
|
||||
|
||||
if("Terminal.ConductingEquipment"==reader.name() && reader.attributes().hasAttribute("rdf:resource"))
|
||||
|
|
@ -24,6 +28,13 @@ bool Terminal::derivedParse(QXmlStreamReader& reader)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString Terminal::getConductingEquipment()
|
||||
{
|
||||
return this->conductingEquipment;
|
||||
}
|
||||
|
||||
|
||||
bool Terminal::parse(QXmlStreamReader& reader)
|
||||
{
|
||||
return this->parseBasicInfo(reader);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
#define TERMINAL_H
|
||||
#include <QXmlStreamReader>
|
||||
#include "BasicElementInfo.h"
|
||||
#include "nodetoterminal.h"
|
||||
class Terminal:public BasicElementInfo
|
||||
{
|
||||
public:
|
||||
explicit Terminal(QObject *parent = 0);
|
||||
virtual bool parse(QXmlStreamReader& reader);
|
||||
QString getConductingEquipment();
|
||||
protected:
|
||||
virtual bool derivedParse(QXmlStreamReader& reader);
|
||||
QString conductingEquipment;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ SOURCES += main.cpp \
|
|||
compensator.cpp \
|
||||
disconnector.cpp \
|
||||
powertransformer.cpp \
|
||||
synchronousmachine.cpp
|
||||
synchronousmachine.cpp \
|
||||
nodetoterminal.cpp
|
||||
|
||||
HEADERS += \
|
||||
elementhashtable.h \
|
||||
|
|
@ -42,7 +43,8 @@ HEADERS += \
|
|||
compensator.h \
|
||||
disconnector.h \
|
||||
powertransformer.h \
|
||||
synchronousmachine.h
|
||||
synchronousmachine.h \
|
||||
nodetoterminal.h
|
||||
|
||||
#release{
|
||||
DEFINES += QT_NO_DEBUG_OUTPUT
|
||||
|
|
|
|||
Loading…
Reference in New Issue