Replace #define ... with pragma once

This commit is contained in:
2024-03-10 12:50:35 +01:00
parent 51f32113c0
commit 0010c840d1
33 changed files with 84 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
#ifndef COMMAND_PARSER_H
#define COMMAND_PARSER_H
#pragma once
#include <string>
#include <vector>
#include <tuple>
@@ -17,4 +17,3 @@ namespace platform {
int index;
};
} /* namespace platform */
#endif /* COMMAND_PARSER_H */

View File

@@ -12,7 +12,7 @@
namespace platform {
ManageResults::ManageResults(int numFiles, const std::string& model, const std::string& score, bool complete, bool partial, bool compare) :
numFiles{ numFiles }, complete{ complete }, partial{ partial }, compare{ compare }, results(Results(Paths::results(), model, score, complete, partial))
numFiles{ numFiles }, complete{ complete }, partial{ partial }, compare{ compare }, results(ResultsManager(model, score, complete, partial))
{
indexList = true;
openExcel = false;

View File

@@ -1,7 +1,7 @@
#ifndef MANAGE_RESULTS_H
#define MANAGE_RESULTS_H
#pragma once
#include <xlsxwriter.h>
#include "Results.h"
#include "ResultsManager.h"
namespace platform {
class ManageResults {
@@ -23,9 +23,7 @@ namespace platform {
bool complete;
bool partial;
bool compare;
Results results;
ResultsManager results;
lxw_workbook* workbook;
};
}
#endif /* MANAGE_RESULTS_H */

View File

@@ -1,9 +1,10 @@
#include <algorithm>
#include "Results.h"
#include "common/Paths.h"
#include "ResultsManager.h"
namespace platform {
Results::Results(const std::string& path, const std::string& model, const std::string& score, bool complete, bool partial) :
path(path), model(model), scoreName(score), complete(complete), partial(partial)
ResultsManager::ResultsManager(const std::string& model, const std::string& score, bool complete, bool partial) :
path(Paths::results()), model(model), scoreName(score), complete(complete), partial(partial)
{
load();
if (!files.empty()) {
@@ -12,7 +13,7 @@ namespace platform {
maxModel = 0;
}
}
void Results::load()
void ResultsManager::load()
{
using std::filesystem::directory_iterator;
for (const auto& file : directory_iterator(path)) {
@@ -28,47 +29,47 @@ namespace platform {
}
}
}
void Results::hideResult(int index, const std::string& pathHidden)
void ResultsManager::hideResult(int index, const std::string& pathHidden)
{
auto filename = files.at(index).getFilename();
rename((path + "/" + filename).c_str(), (pathHidden + "/" + filename).c_str());
files.erase(files.begin() + index);
}
void Results::deleteResult(int index)
void ResultsManager::deleteResult(int index)
{
auto filename = files.at(index).getFilename();
remove((path + "/" + filename).c_str());
files.erase(files.begin() + index);
}
int Results::size() const
int ResultsManager::size() const
{
return files.size();
}
void Results::sortDate()
void ResultsManager::sortDate()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getDate() > b.getDate();
});
}
void Results::sortModel()
void ResultsManager::sortModel()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getModel() > b.getModel();
});
}
void Results::sortDuration()
void ResultsManager::sortDuration()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getDuration() > b.getDuration();
});
}
void Results::sortScore()
void ResultsManager::sortScore()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getScore() > b.getScore();
});
}
bool Results::empty() const
bool ResultsManager::empty() const
{
return files.empty();
}

View File

@@ -1,5 +1,5 @@
#ifndef RESULTS_H
#define RESULTS_H
#pragma once
#include <map>
#include <vector>
#include <string>
@@ -7,9 +7,9 @@
#include "main/Result.h"
namespace platform {
using json = nlohmann::json;
class Results {
class ResultsManager {
public:
Results(const std::string& path, const std::string& model, const std::string& score, bool complete, bool partial);
ResultsManager(const std::string& model, const std::string& score, bool complete, bool partial);
void sortDate();
void sortScore();
void sortModel();
@@ -32,5 +32,4 @@ namespace platform {
std::vector<Result> files;
void load(); // Loads the list of results
};
};
#endif
};