Molecular Dynamics Simulation  1.0
Public Member Functions | Private Attributes | List of all members
XMLFileReader Class Reference

Class to read particle and simulation data from a '.xml' file. More...

#include <XMLFileReader.h>

Inheritance diagram for XMLFileReader:
Inheritance graph
Collaboration diagram for XMLFileReader:
Collaboration graph

Public Member Functions

 XMLFileReader (bool fresh, bool allow_recursion=true)
 
std::tuple< std::vector< Particle >, std::optional< SimulationParams > > readFile (const std::filesystem::path &filepath) const override
 Reads particle data from a '.xml' file and returns a vector of particles Other simulation parameters are returned as an optional SimulationParams object. More...
 
- Public Member Functions inherited from FileReader
virtual ~FileReader ()=default
 virtual destructor for correct cleanup of derived classes More...
 

Private Attributes

bool fresh
 
bool allow_recursion
 

Detailed Description

Class to read particle and simulation data from a '.xml' file.

Definition at line 10 of file XMLFileReader.h.

Constructor & Destructor Documentation

◆ XMLFileReader()

XMLFileReader::XMLFileReader ( bool  fresh,
bool  allow_recursion = true 
)
inlineexplicit

Definition at line 16 of file XMLFileReader.h.

Member Function Documentation

◆ readFile()

std::tuple< std::vector< Particle >, std::optional< SimulationParams > > XMLFileReader::readFile ( const std::filesystem::path &  filepath) const
overridevirtual

Reads particle data from a '.xml' file and returns a vector of particles Other simulation parameters are returned as an optional SimulationParams object.

Parameters
filepathPath to the file to read

Implements FileReader.

Definition at line 304 of file XMLFileReader.cpp.

304  {
305  try {
306  auto config = configuration(filepath);
307 
308  return prepareParticles(filepath, *config, fresh, allow_recursion);
309  } catch (const xml_schema::exception& e) {
310  std::stringstream error_message;
311  error_message << "Error: could not parse file '" << filepath << "'.\n";
312  error_message << e << std::endl;
313  throw FileFormatException(error_message.str());
314  }
315 }
std::tuple< std::vector< Particle >, SimulationParams > prepareParticles(std::filesystem::path curr_file_path, ConfigurationType &config, bool fresh, bool allow_recursion, std::filesystem::path output_base_path="", int depth=0)

Member Data Documentation

◆ allow_recursion

bool XMLFileReader::allow_recursion
private

Definition at line 13 of file XMLFileReader.h.

◆ fresh

bool XMLFileReader::fresh
private

Definition at line 12 of file XMLFileReader.h.


The documentation for this class was generated from the following files: