class gpr::io::FileManager

Overview

Responsible for generic IO operations. More…

#include <FileManager.h>
 
class FileManager {
public:
    // construction
 
    FileManager();
    virtual ~FileManager();
 
    // methods
 
    void readInputFile(const std::string file_name, gpr::InputParameters& parameters);
 
    template <typename T>
    void readDataFile(const std::string file_name, std::map<std::string, T*>& data);
 
    template <typename T>
    bool readFromPlainFile(const std::string file_name, T& field);
 
    template <typename T>
    bool writePlainFile(const std::string file_name, const T& field, std::ios::openmode mode);
 
    bool writeXYZFile(const std::string file_name, const gpr::Coord& field, std::ios::openmode mode);
};

Detailed Documentation

Responsible for generic IO operations.

Methods

void readInputFile(const std::string file_name, gpr::InputParameters& parameters)

Read data from the input file and populates structure of parameters. The input file may have empty lines and in-line comments that should start with “%” character. The values should be assigned to variable using the assignment operator “=”.

Parameters:

file_name

Name of the input file.

parameters

Structure of parameters

template <typename T>
void readDataFile(const std::string file_name, std::map<std::string, T*>& data)

Read data file. The method reads data file written in ASCII format. The values of data should point to fields that supposed to be populated. The keys in data should have names of fields from the data file.

Note

Template T should be of type Coord or Field.

Parameters:

file_name

Name of the data file.

data

Map of fields names and pointers to the fields objects.

template <typename T>
bool readFromPlainFile(const std::string file_name, T& field)

Read plain ASCII data file. This function reads data line-by-line from a plain text file. No memory allocation and no range chacks are invoked during the execution of the function.

Warning

field should be pre-allocated!

Parameters:

file_name

File name

field

2D field of data

Returns:

EXIT_SUCCESS or EXIT_FAILURE codes