Molecular Dynamics Simulation  1.0
Enumerations | Functions
OutputFormats.h File Reference
#include <map>
#include <string>
Include dependency graph for OutputFormats.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  OutputFormat { VTU , XYZ , CHKPT }
 Enum class to specify the output format. More...
 

Functions

const std::map< std::string, OutputFormatget_supported_output_formats ()
 Returns a mappping of supported output formats. More...
 
OutputFormat convertToOutputFormat (const std::string &output_format)
 Converts a string to an OutputFormat. More...
 

Enumeration Type Documentation

◆ OutputFormat

enum OutputFormat
strong

Enum class to specify the output format.

Enumerator
VTU 
XYZ 
CHKPT 

Definition at line 9 of file OutputFormats.h.

Function Documentation

◆ convertToOutputFormat()

OutputFormat convertToOutputFormat ( const std::string &  output_format)

Converts a string to an OutputFormat.

Parameters
output_formatThe string to convert
Returns
OutputFormat The converted OutputFormat

Definition at line 9 of file OutputFormats.cpp.

9  {
10  auto supported = get_supported_output_formats();
11 
12  if (!supported.contains(output_format)) {
13  auto supported_formats = std::string();
14  for (auto& [name, format] : supported) {
15  supported_formats += name + ", ";
16  }
17 
18  Logger::logger->error("Invalid output format given: {}. Supported output formats are: {}", output_format, supported_formats);
19  throw std::runtime_error("Invalid output format given");
20  }
21 
22  return supported[output_format];
23 }
const std::map< std::string, OutputFormat > get_supported_output_formats()
Returns a mappping of supported output formats.
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35

◆ get_supported_output_formats()

const std::map<std::string, OutputFormat> get_supported_output_formats ( )

Returns a mappping of supported output formats.

Returns
std::map<std::string,OutputFormat> Mapping of supported output formats

Definition at line 5 of file OutputFormats.cpp.

5  {
6  return {{"vtu", OutputFormat::VTU}, {"xyz", OutputFormat::XYZ}, {"chkpt", OutputFormat::CHKPT}};
7 }