2depth 추가

git-svn-id: svn://192.168.0.12/source@170 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2015-08-06 09:25:34 +00:00
parent 93a9e55cf4
commit a692dd4066
19 changed files with 2543 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
#include "yalgorithm.h"
#include "ychildrenthread.h"
#include <QDebug>
#include "ymfilterchildren.h"
/*
*class YASingleton
*
@@ -21,10 +22,72 @@ YASingleton::~YASingleton()
{
}
/*
*
* Class YAFactory
*
*/
YAFactory* YAFactory::instance = NULL;
YAFactory::YAFactory()
{
}
YAFactory::~YAFactory()
{
}
YAFactory* YAFactory::getInstance()
{
if(instance == NULL)
instance = new YAFactory();
return instance;
}
YAlgorithm* YAFactory::getYAlgorithm(QMap<QString, QString> mapParam)
{
YAlgorithm* Algorithm;
//qDebug() << "hohoho";
if(mapParam.value("Algorithm").compare("onedepth", Qt::CaseInsensitive) == 0)
{
if(!m_mapAlgorithm.contains("onedepth"))
m_mapAlgorithm.insert("onedepth", new YAlgorithm());
Algorithm = m_mapAlgorithm.value("onedepth");
}
else if(mapParam.value("Algorithm").compare("twodepth", Qt::CaseInsensitive) == 0)
{
if(!m_mapAlgorithm.contains("twodepth"))
m_mapAlgorithm.insert("twodepth", new YTwoDepthAlgorithm() );
Algorithm = m_mapAlgorithm.value("twodepth");
//qDebug() << "two depth";
}
else if(mapParam.value("Algorithm").compare("nxnmatrix", Qt::CaseInsensitive) == 0)
{
if(!m_mapAlgorithm.contains("nxnmatrix"))
m_mapAlgorithm.insert("nxnmatrix", new YAlgorithm());
Algorithm = m_mapAlgorithm.value("nxnmatrix");
}
else if(mapParam.value("Algorithm").compare("basic", Qt::CaseInsensitive) == 0)
{
if(!m_mapAlgorithm.contains("basic"))
m_mapAlgorithm.insert("basic", new YAlgorithm());
Algorithm = m_mapAlgorithm.value("basic");
}
else
{
Algorithm = NULL;
}
return Algorithm;
}
/*
*class YAlgorithm
*
*/
*/
YAlgorithm::YAlgorithm()
{
@@ -36,7 +99,6 @@ YAlgorithm::~YAlgorithm()
}
QMap <QString, int> YAlgorithm::getResult()
{
return m_mapTotalResult;
@@ -93,9 +155,6 @@ QMap <QString, int> YAlgorithm::RankFilter(QMap <QString, int> mapResult)
void YAlgorithm::EmergeThreadResult()
{
for(int i = 0;i < getThreadNumber(); i++)
@@ -179,16 +238,144 @@ void YAlgorithm::Start()
delete[] m_pYMThread;
EmergeThreadResult();
/*
if(!m_mapParam.value("KeywordFilter").isEmpty())
YMFilter* ymfilter = YMFilterFactory::getFilter(m_mapParam);
//qDebug() << "EXEC";
if(ymfilter != NULL)
{
m_mapTotalResult = KeywordFilter(m_mapTotalResult);
ymfilter->setParam(m_mapParam);
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
}
if(!m_mapParam.value("RankFilter").isEmpty())
delete ymfilter;
}
void YTwoDepthAlgorithm::Start()
{
if(m_mapParam.isEmpty())
return;
bool okThread = false;
int nThread = m_mapParam.value("Thread").trimmed().toInt(&okThread);
if(!okThread)
setThreadNumber(1);
else
setThreadNumber(nThread);
QMap<QString, QString>mapParam = m_mapParam;
mapParam["Algorithm"] = "onedepth";
m_pYMThread = new YMorphereThread*[getThreadNumber()];
for(int i = 0; i < getThreadNumber(); i++)
{
m_mapTotalResult = RankFilter(m_mapTotalResult);
m_pYMThread[i] = ThreadFactory::getThread(mapParam);
m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface);
m_pYMThread[i]->setMutex(&mutex);
m_pYMThread[i]->setParam(mapParam);
}
*/
for(int i = 0;i < getThreadNumber(); i++)
{
m_pYMThread[i]->start();
}
for(int i = 0;i < getThreadNumber(); i++)
{
m_pYMThread[i]->wait();
}
m_mapThreadResult = new QMap<QString, int>*[getThreadNumber()];
for(int i = 0; i < getThreadNumber(); i++)
{
m_mapThreadResult[i] = new QMap<QString, int>();
}
for(int i = 0; i < getThreadNumber(); i++)
{
*m_mapThreadResult[i] = m_pYMThread[i]->getResult();
m_pYMThread[i]->clearResult();
}
for(int i = 0;i < getThreadNumber(); i++)
{
delete m_pYMThread[i];
}
delete[] m_pYMThread;
EmergeThreadResult();
YMFilter* ymfilter = YMFilterFactory::getFilter(mapParam);
//qDebug() << "EXEC";
if(ymfilter != NULL)
{
ymfilter->setParam(m_mapParam);
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
}
delete ymfilter;
QList<QString> listKeys = m_mapTotalResult.keys();
QString strKeys;
for(int i = 0; i < listKeys.count(); i++)
{
strKeys += (listKeys.at(i).trimmed() + " ");
}
strKeys = strKeys.trimmed();
m_mapTotalResult.clear();
m_mapParam.insert("OneDepthKeys", strKeys);
m_pDAInterface->reset();
m_pYMThread = new YMorphereThread*[getThreadNumber()];
for(int i = 0; i < getThreadNumber(); i++)
{
m_pYMThread[i] = ThreadFactory::getThread(m_mapParam);
m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface);
m_pYMThread[i]->setMutex(&mutex);
m_pYMThread[i]->setParam(m_mapParam);
}
for(int i = 0;i < getThreadNumber(); i++)
{
m_pYMThread[i]->start();
}
for(int i = 0;i < getThreadNumber(); i++)
{
m_pYMThread[i]->wait();
}
m_mapThreadResult = new QMap<QString, int>*[getThreadNumber()];
for(int i = 0; i < getThreadNumber(); i++)
{
m_mapThreadResult[i] = new QMap<QString, int>();
}
for(int i = 0; i < getThreadNumber(); i++)
{
*m_mapThreadResult[i] = m_pYMThread[i]->getResult();
m_pYMThread[i]->clearResult();
}
for(int i = 0;i < getThreadNumber(); i++)
{
delete m_pYMThread[i];
}
delete[] m_pYMThread;
EmergeThreadResult();
ymfilter = YMFilterFactory::getFilter(m_mapParam);
//qDebug() << "EXEC";
if(ymfilter != NULL)
{
ymfilter->setParam(m_mapParam);
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
}
delete ymfilter;
}