cimforreduceloss/testHasttable/nodetoterminal.h

31 lines
858 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef NODETOTERMINAL_H
#define NODETOTERMINAL_H
//一个通过Node检索Terminal的表做成单例形式
#include <QHash>
#include <QString>
#include <QVector>
class NodeToTerminal
{
public:
NodeToTerminal();
~NodeToTerminal();
void add(const QString& key,const QString& value);
bool contains(const QString& key);
QVector<QString> value(const QString& key);
private:
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
{
public:
~CG()
{
if (NodeToTerminal::ht)
delete NodeToTerminal::ht;
}
};
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
static QHash<QString,QVector<QString> > *ht;
};
#endif // NODETOTERMINAL_H