diff --git a/.gitignore b/.gitignore index b5a843c..0f397a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ *.pro.user* *.bak *.orig +*e.Debug +*e.Release +core/object_script.core.Debug debug release Makefile* testHasttable/*Debug -testHasttable/*Release \ No newline at end of file +testHasttable/*Release diff --git a/testHasttable/elementhashtable.cpp b/testHasttable/elementhashtable.cpp index 1fd8ed1..c4b742d 100644 --- a/testHasttable/elementhashtable.cpp +++ b/testHasttable/elementhashtable.cpp @@ -84,7 +84,14 @@ bool ElementHashtable::goPath() //找Terminal的东西 Terminal *terminalP=static_cast(ht[terminal]); std::cout<getID().toStdString()<getConductingEquipment().toStdString()<getConnectivityNode(); + std::cout<nodeToTerminal.value(node); +// std::cout<<"anotherTerminal"<(ht[anotherTerminal]); + std::cout<getConductingEquipment().toStdString()< eleHT; + NodeToTerminal nodeToTerminal; signals: public slots: diff --git a/testHasttable/nodetoterminal.cpp b/testHasttable/nodetoterminal.cpp index bfc37bf..ace622f 100644 --- a/testHasttable/nodetoterminal.cpp +++ b/testHasttable/nodetoterminal.cpp @@ -1,10 +1,13 @@ #include "nodetoterminal.h" +#include QHash *NodeToTerminal::ht=NULL; NodeToTerminal::NodeToTerminal() { if(!NodeToTerminal::ht) { +// std::cout<<"create"<; +// std::cout<value("").toStdString()<value(key); +// return "not null"; +// } +// else +// { +// return "null"; +// } +// return ""; return NodeToTerminal::ht->value(key); } NodeToTerminal::~NodeToTerminal() { - if(NodeToTerminal::ht) - { - delete NodeToTerminal::ht; - NodeToTerminal::ht=NULL; - } +// if(NodeToTerminal::ht) +// { +// delete NodeToTerminal::ht; +// NodeToTerminal::ht=NULL; +// } } diff --git a/testHasttable/nodetoterminal.h b/testHasttable/nodetoterminal.h index 32e0a41..bea771c 100644 --- a/testHasttable/nodetoterminal.h +++ b/testHasttable/nodetoterminal.h @@ -6,13 +6,23 @@ class NodeToTerminal { public: - explicit NodeToTerminal(); + NodeToTerminal(); ~NodeToTerminal(); void add(const QString& key,const QString& value); bool contains(const QString& key); QString value(const QString& key); private: - static QHash *ht; + class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例 + { + public: + ~CG() + { + if (NodeToTerminal::ht) + delete NodeToTerminal::ht; + } + }; + static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数 + static QHash *ht; }; diff --git a/testHasttable/terminal.cpp b/testHasttable/terminal.cpp index 079f080..11fc48c 100644 --- a/testHasttable/terminal.cpp +++ b/testHasttable/terminal.cpp @@ -1,5 +1,5 @@ #include "terminal.h" - +#include Terminal::Terminal(QObject *parent):BasicElementInfo(parent) { } @@ -34,8 +34,14 @@ QString Terminal::getConductingEquipment() return this->conductingEquipment; } +QString Terminal::getConnectivityNode() +{ + return this->connectivityNode; +} bool Terminal::parse(QXmlStreamReader& reader) { return this->parseBasicInfo(reader); } + + diff --git a/testHasttable/terminal.h b/testHasttable/terminal.h index f7f0227..4586295 100644 --- a/testHasttable/terminal.h +++ b/testHasttable/terminal.h @@ -9,6 +9,7 @@ public: explicit Terminal(QObject *parent = 0); virtual bool parse(QXmlStreamReader& reader); QString getConductingEquipment(); + QString getConnectivityNode(); protected: virtual bool derivedParse(QXmlStreamReader& reader); QString conductingEquipment;