13 #ifndef QmitknnUNetFolderParser_h
14 #define QmitknnUNetFolderParser_h
16 #include <QDirIterator>
70 auto models = GetSubFolderNamesFromNode<T>(m_RootNode);
85 std::shared_ptr<FolderNode> modelNode = GetSubNodeMatchingNameCrietria(modelName, m_RootNode);
86 auto tasks = GetSubFolderNamesFromNode<T>(modelNode);
102 auto models = GetSubFolderNamesFromNode<T>(m_RootNode);
103 foreach (QString model, models)
105 QStringList taskList = getTasksForModel<QStringList>(model);
106 if (taskList.contains(taskName, Qt::CaseInsensitive))
108 modelsForTask << model;
111 return modelsForTask;
121 template <
typename T>
125 auto models = GetSubFolderNamesFromNode<T>(m_RootNode);
126 foreach (QString model, models)
128 allTasks << getTasksForModel<QStringList>(model);
142 template <
typename T>
145 std::shared_ptr<FolderNode> modelNode = GetSubNodeMatchingNameCrietria(modelName, m_RootNode);
146 std::shared_ptr<FolderNode> taskNode = GetSubNodeMatchingNameCrietria(taskName, modelNode);
147 auto tps = GetSubFolderNamesFromNode<T>(taskNode);
162 template <
typename T>
164 const QString &planner,
165 const QString &taskName,
166 const QString &modelName)
168 std::shared_ptr<FolderNode> modelNode = GetSubNodeMatchingNameCrietria(modelName, m_RootNode);
169 std::shared_ptr<FolderNode> taskNode = GetSubNodeMatchingNameCrietria(taskName, modelNode);
170 QString trainerPlanner = trainer + QString(
"__") + planner;
171 std::shared_ptr<FolderNode> tpNode = GetSubNodeMatchingNameCrietria(trainerPlanner, taskNode);
172 auto folds = GetSubFolderNamesFromNode<T>(tpNode);
177 const int m_LEVEL = 4;
178 std::shared_ptr<FolderNode> m_RootNode;
186 std::function<bool(QString)> RuleEngine(
int level);
195 std::shared_ptr<FolderNode> GetSubNodeMatchingNameCrietria(
const QString &queryName, std::shared_ptr<FolderNode> parentNode);
205 template <
typename T>
206 T GetSubFolderNamesFromNode(
const std::shared_ptr<FolderNode> parent)
209 std::vector<std::shared_ptr<FolderNode>> subNodes = parent->
subFolders;
210 for (std::shared_ptr<FolderNode> folder : subNodes)
212 folders.push_back(folder->name);
224 void InitDirs(std::shared_ptr<FolderNode> parent,
int level);
233 void DeleteDirs(std::shared_ptr<FolderNode> parent,
int level);
243 template <
typename T>
244 T FetchFoldersFromDir(
const QString &path, std::function<
bool(QString)> callback)
247 for (QDirIterator it(path, QDir::AllDirs, QDirIterator::NoIteratorFlags); it.hasNext();)
250 if (!it.fileName().startsWith(
'.') && callback(it.filePath()))
252 folders.push_back(it.fileName());