8 std::tuple<std::vector<Particle>, std::optional<SimulationParams>>
FileInputHandler::readFile(
const std::filesystem::path& input_file_path,
9 bool fresh,
bool allow_recursion) {
10 if (!std::filesystem::exists(input_file_path)) {
11 Logger::logger->error(
"Error: file '{}' does not exist.", input_file_path.string());
15 std::string file_extension = input_file_path.extension().string();
18 Logger::logger->error(
"Error: file extension '{}' is not supported.", file_extension);
22 std::unique_ptr<FileReader> file_reader;
24 if (file_extension ==
".xml") {
25 file_reader = std::make_unique<XMLFileReader>(fresh, allow_recursion);
27 Logger::logger->error(
"Error: file extension '{}' is not supported.", file_extension);
32 auto [particles, config] = file_reader->readFile(input_file_path);
33 Logger::logger->info(
"Loaded {} particles from file {}", particles.size(), input_file_path.string());
34 return std::make_tuple(particles, config);
36 Logger::logger->error(
"Error: file '{}' is not a valid {} file.", input_file_path.string(), file_extension);
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.