PowerDesignerX/include/util/selectorManager.h

61 lines
1.6 KiB
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.

/**
*\file selectorManager.h
*
*\brief 所有的selector管理类,采用单例模式
* 每个selector只需实例一个对象根据具体要实现的内容进行创建和选择
*\author dsc
*/
#ifndef SELECTORMANAGER_H
#define SELECTORMANAGER_H
#include <QObject>
#include "baseSelector.h"
#include "global.h"
class SelectorManager : public QObject
{
Q_OBJECT
public:
SelectorManager(QObject *parent = 0);
~SelectorManager();
public:
static SelectorManager* getInstance();
void setWorkingSelector(SelectorType s) { m_curSelector=s; }
BaseSelector* getWorkingSelector(); //根据操作方式获取selector
void setDrawGraphicsItem(GraphicsItemType);
public slots:
void onSignal_setWorkingSelector(SelectorType);
private:
/*
程序在结束的时候,系统会自动析构所有的全局变量,系统也会析构掉所有的类的静态成员变量,
所以可以在单例类中定义一个这样的静态成员变量,它唯一的工作就是在析构函数中删除单例类的实例
*/
class CGarbo //它的唯一函数就是在析构函数中删除vsBaseData的实例
{
public:
CGarbo() {};
~CGarbo()
{
if (m_pInstance != nullptr)
{
//qDebug()<<"goodbye CGarbo";
delete m_pInstance;
m_pInstance = nullptr;
}
}
};
private:
static SelectorManager* m_pInstance;
SelectorType m_curSelector;
QVector<BaseSelector*> m_vecSelectors;
};
#endif