parent
53416f8f33
commit
38025aa1fc
|
|
@ -1,8 +1,11 @@
|
||||||
*.pro.user*
|
*.pro.user*
|
||||||
*.bak
|
*.bak
|
||||||
*.orig
|
*.orig
|
||||||
|
*e.Debug
|
||||||
|
*e.Release
|
||||||
|
core/object_script.core.Debug
|
||||||
debug
|
debug
|
||||||
release
|
release
|
||||||
Makefile*
|
Makefile*
|
||||||
testHasttable/*Debug
|
testHasttable/*Debug
|
||||||
testHasttable/*Release
|
testHasttable/*Release
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,14 @@ bool ElementHashtable::goPath()
|
||||||
//找Terminal的东西
|
//找Terminal的东西
|
||||||
Terminal *terminalP=static_cast<Terminal *>(ht[terminal]);
|
Terminal *terminalP=static_cast<Terminal *>(ht[terminal]);
|
||||||
std::cout<<terminalP->getID().toStdString()<<std::endl;
|
std::cout<<terminalP->getID().toStdString()<<std::endl;
|
||||||
// std::cout<<terminalP->getConductingEquipment().toStdString()<<std::endl;
|
QString node;
|
||||||
|
node=terminalP->getConnectivityNode();
|
||||||
|
std::cout<<node.toStdString()<<std::endl;
|
||||||
|
QString anotherTerminal;
|
||||||
|
anotherTerminal=this->nodeToTerminal.value(node);
|
||||||
|
// std::cout<<"anotherTerminal"<<anotherTerminal.toStdString()<<std::endl;
|
||||||
|
Terminal *anotherTerminalP=static_cast<Terminal *>(ht[anotherTerminal]);
|
||||||
|
std::cout<<anotherTerminalP->getConductingEquipment().toStdString()<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include "disconnector.h"
|
#include "disconnector.h"
|
||||||
#include "powertransformer.h"
|
#include "powertransformer.h"
|
||||||
#include "synchronousmachine.h"
|
#include "synchronousmachine.h"
|
||||||
|
#include "nodetoterminal.h"
|
||||||
class ElementHashtable : public QObject
|
class ElementHashtable : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -27,6 +28,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool child(QXmlStreamReader &reader);
|
bool child(QXmlStreamReader &reader);
|
||||||
QHash<QString,BasicElementInfo *> eleHT;
|
QHash<QString,BasicElementInfo *> eleHT;
|
||||||
|
NodeToTerminal nodeToTerminal;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
#include "nodetoterminal.h"
|
#include "nodetoterminal.h"
|
||||||
|
#include <iostream>
|
||||||
QHash<QString,QString> *NodeToTerminal::ht=NULL;
|
QHash<QString,QString> *NodeToTerminal::ht=NULL;
|
||||||
NodeToTerminal::NodeToTerminal()
|
NodeToTerminal::NodeToTerminal()
|
||||||
{
|
{
|
||||||
if(!NodeToTerminal::ht)
|
if(!NodeToTerminal::ht)
|
||||||
{
|
{
|
||||||
|
// std::cout<<"create"<<std::endl;
|
||||||
NodeToTerminal::ht=new QHash<QString,QString>;
|
NodeToTerminal::ht=new QHash<QString,QString>;
|
||||||
|
// std::cout<<this->value("").toStdString()<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,14 +23,24 @@ bool NodeToTerminal::contains(const QString& key)
|
||||||
|
|
||||||
QString NodeToTerminal::value(const QString& key)
|
QString NodeToTerminal::value(const QString& key)
|
||||||
{
|
{
|
||||||
|
// if(NodeToTerminal::ht)
|
||||||
|
// {
|
||||||
|
// //return NodeToTerminal::ht->value(key);
|
||||||
|
// return "not null";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return "null";
|
||||||
|
// }
|
||||||
|
// return "";
|
||||||
return NodeToTerminal::ht->value(key);
|
return NodeToTerminal::ht->value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeToTerminal::~NodeToTerminal()
|
NodeToTerminal::~NodeToTerminal()
|
||||||
{
|
{
|
||||||
if(NodeToTerminal::ht)
|
// if(NodeToTerminal::ht)
|
||||||
{
|
// {
|
||||||
delete NodeToTerminal::ht;
|
// delete NodeToTerminal::ht;
|
||||||
NodeToTerminal::ht=NULL;
|
// NodeToTerminal::ht=NULL;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,23 @@
|
||||||
class NodeToTerminal
|
class NodeToTerminal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NodeToTerminal();
|
NodeToTerminal();
|
||||||
~NodeToTerminal();
|
~NodeToTerminal();
|
||||||
void add(const QString& key,const QString& value);
|
void add(const QString& key,const QString& value);
|
||||||
bool contains(const QString& key);
|
bool contains(const QString& key);
|
||||||
QString value(const QString& key);
|
QString value(const QString& key);
|
||||||
private:
|
private:
|
||||||
static QHash<QString,QString> *ht;
|
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~CG()
|
||||||
|
{
|
||||||
|
if (NodeToTerminal::ht)
|
||||||
|
delete NodeToTerminal::ht;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
||||||
|
static QHash<QString,QString> *ht;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include <iostream>
|
||||||
Terminal::Terminal(QObject *parent):BasicElementInfo(parent)
|
Terminal::Terminal(QObject *parent):BasicElementInfo(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -34,8 +34,14 @@ QString Terminal::getConductingEquipment()
|
||||||
return this->conductingEquipment;
|
return this->conductingEquipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Terminal::getConnectivityNode()
|
||||||
|
{
|
||||||
|
return this->connectivityNode;
|
||||||
|
}
|
||||||
|
|
||||||
bool Terminal::parse(QXmlStreamReader& reader)
|
bool Terminal::parse(QXmlStreamReader& reader)
|
||||||
{
|
{
|
||||||
return this->parseBasicInfo(reader);
|
return this->parseBasicInfo(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public:
|
||||||
explicit Terminal(QObject *parent = 0);
|
explicit Terminal(QObject *parent = 0);
|
||||||
virtual bool parse(QXmlStreamReader& reader);
|
virtual bool parse(QXmlStreamReader& reader);
|
||||||
QString getConductingEquipment();
|
QString getConductingEquipment();
|
||||||
|
QString getConnectivityNode();
|
||||||
protected:
|
protected:
|
||||||
virtual bool derivedParse(QXmlStreamReader& reader);
|
virtual bool derivedParse(QXmlStreamReader& reader);
|
||||||
QString conductingEquipment;
|
QString conductingEquipment;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue