#ifndef YALGORITHM
#define YALGORITHM
#include <QMutex>
#include <QMap>
#include <QString>
#include "dataalgorithm_interface.h"
#include "ymorpherethread.h"
class YAlgorithm{
protected:
    QMutex mutex;
    QMap <QString, int> m_mapTotalResult;
    QMap <QString, QString> m_mapParam;
    QMap <QString, int>** m_mapThreadResult;
    DataAlgorithmInterface* m_pDAInterface;
    int m_nThread;
    YMorphereThread** m_pYMThread;

protected:
    void setThreadNumber(int nThread);
    QMap <QString, int> KeywordFilter(QMap <QString, int> mapResult);
    QMap <QString, int> RankFilter(QMap <QString, int> mapResult);

public:
    YAlgorithm();
    ~YAlgorithm();
    QMap <QString, int> getResult();
    void setParam(QMap <QString, QString> mapParam);
    QMutex *getMutex();
    void setDataAlgorithmInterface(DataAlgorithmInterface* pDAInterface);
    void clearParam();
    void clearResult();
    void init();
    void EmergeThreadResult();

    int getThreadNumber();
    virtual void Start();
};

class YASingleton
{
private:
    static YAlgorithm* algorithm;
    YASingleton();
    ~YASingleton();

public:
    static YAlgorithm* getInstance();


};

class YAFactory
{
private:
    QMap<QString, YAlgorithm*> m_mapAlgorithm;
    static YAFactory* instance;
    YAFactory();
    ~YAFactory();

public:
    static YAFactory* getInstance();
    YAlgorithm* getYAlgorithm(QMap<QString, QString> mapParam);
};

class YTwoDepthAlgorithm:public YAlgorithm
{
public:
    void Start();
};

class YTwoDepthAAlgorithm:public YAlgorithm
{
public:
    void Start();
};


class YPlatformAlgorithm:public YAlgorithm
{
public:
    void Start();
};


#endif // YALGORITHM

