/**
     *\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 (s_pInstance != nullptr)
            {
                //qDebug()<<"goodbye CGarbo";
                delete s_pInstance;
                s_pInstance = nullptr;
            }
        }
    };

private:
    static SelectorManager*  s_pInstance;
    
    SelectorType             m_curSelector;
    QVector<BaseSelector*>   m_vecSelectors;
};

#endif
