| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "CReasonerEvaluationDirectoryStructureSelectorFactory.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Test { |
| 27 |
|
| 28 |
namespace Evaluation { |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
CReasonerEvaluationDirectoryStructureSelectorFactory::CReasonerEvaluationDirectoryStructureSelectorFactory(const QString& groupDirString, const QString& dirString, const QString& baseEvalName, const QString& baseOutputDir) { |
| 33 |
mDirectoryString = dirString; |
| 34 |
mBaseEvalName = baseEvalName; |
| 35 |
mBaseOutputDir = baseOutputDir; |
| 36 |
mGroupDirString = groupDirString; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
CReasonerEvaluationGroupRequestSelector* CReasonerEvaluationDirectoryStructureSelectorFactory::getSelectors(CReasonerEvaluationGroupRequestSelector* prevSelector) { |
| 41 |
if (!mDirectoryString.endsWith("/")) { |
| 42 |
mDirectoryString += QString("/"); |
| 43 |
} |
| 44 |
QList<CReasonerEvaluationStringMatchGroupSelector*> selList; |
| 45 |
CReasonerEvaluationGroupRequestSelector* selectors = getSelectors(nullptr,mDirectoryString,selList); |
| 46 |
if (selectors) { |
| 47 |
selectors = selectors->append(prevSelector); |
| 48 |
} else { |
| 49 |
selectors = prevSelector; |
| 50 |
} |
| 51 |
return selectors; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
CReasonerEvaluationGroupRequestSelector* CReasonerEvaluationDirectoryStructureSelectorFactory::getSelectors(CReasonerEvaluationGroupRequestSelector* prevSelector, const QString& dirString, const QList<CReasonerEvaluationStringMatchGroupSelector*>& subDirAddList) { |
| 56 |
CReasonerEvaluationGroupRequestSelector* selectors = prevSelector; |
| 57 |
|
| 58 |
QDir directory(dirString); |
| 59 |
QStringList subDirStringList = directory.entryList(QDir::Dirs); |
| 60 |
QStringList fileStringList = directory.entryList(QDir::Files); |
| 61 |
|
| 62 |
QString dirGroupString = dirString; |
| 63 |
dirGroupString.replace(mGroupDirString,""); |
| 64 |
|
| 65 |
QList<CReasonerEvaluationStringMatchGroupSelector*> tmpSubDirAddList(subDirAddList); |
| 66 |
|
| 67 |
if (subDirStringList.count() > 3 || fileStringList.count() > 0) { |
| 68 |
CReasonerEvaluationStringMatchGroupSelector* tmpSelector = new CReasonerEvaluationStringMatchGroupSelector(); |
| 69 |
QString selectorName(mBaseEvalName+" :: "+dirGroupString); |
| 70 |
//if (selectorName.endsWith("/")) { |
| 71 |
// selectorName = selectorName.remove(selectorName.count()-1,1); |
| 72 |
//} |
| 73 |
//selectorName = selectorName.replace("/"," :: "); |
| 74 |
tmpSelector->setNameString(selectorName); |
| 75 |
tmpSelector->setOutputString(mBaseOutputDir+dirGroupString); |
| 76 |
selectors = tmpSelector->append(selectors); |
| 77 |
tmpSubDirAddList.append(tmpSelector); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
foreach (CReasonerEvaluationStringMatchGroupSelector* selector, tmpSubDirAddList) { |
| 82 |
selector->addGroupString(dirGroupString); |
| 83 |
} |
| 84 |
foreach (QString subDir, subDirStringList) { |
| 85 |
if (subDir != ".." && subDir != ".") { |
| 86 |
selectors = getSelectors(selectors,dirString+subDir+"/",tmpSubDirAddList); |
| 87 |
} |
| 88 |
} |
| 89 |
return selectors; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
}; // end namespace Evaluation |
| 94 |
|
| 95 |
}; // end namespace Test |
| 96 |
|
| 97 |
}; // end namespace Konclude |