NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
fileadapter.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2020 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef FILEADAPTER_HPP
20#define FILEADAPTER_HPP
21
22#include "../io/file.hpp"
23#include "../io/filesystem.hpp"
24#include "../settings.hpp"
25
26#include <string>
27
28class Memory;
29
30namespace NumeRe
31{
38 class FileAdapter : public FileSystem
39 {
40 protected:
41 std::string sOutputFile;
42 std::string sPrefix;
43 std::string sSavePath;
44 std::string sDataFile;
47
48 std::string getDate();
49 void condenseDataSet(Memory* _mem);
50 virtual bool saveLayer(std::string _sFileName, const std::string& _sCache, unsigned short nPrecision) = 0;
51
52 public:
54 virtual ~FileAdapter() {}
55
56 FileHeaderInfo openFile(std::string _sFile, bool loadToCache = false, bool overrideTarget = false, int _nHeadline = 0, const std::string& sTargetTable = "");
57 bool saveFile(const std::string& sTable, std::string _sFileName, unsigned short nPrecision = 7);
58 std::string getDataFileName(const std::string& sTable) const;
59 std::string getDataFileNameShort() const;
60 std::string getOutputFileName() const;
61 void setSavePath(const std::string& _sPath);
62 void setPrefix(const std::string& _sPrefix);
63 void setbLoadEmptyCols(bool _bLoadEmptyCols);
64 void setbLoadEmptyColsInNextFile(bool _bLoadEmptyCols);
65 std::string generateFileName(const std::string& sExtension = ".ndat");
66 virtual void melt(Memory* _mem, const std::string& sTable, bool overrideTarget = false) = 0;
67 };
68}
69
70#endif // FILEADAPTER_HPP
71
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
This class represents a single table in memory, or a - so to say - single memory page to be handled b...
Definition: memory.hpp:68
This class represents the file input and output adapter for the MemoryManager class,...
Definition: fileadapter.hpp:39
std::string getDataFileName(const std::string &sTable) const
This member function will return the file name of the selected table. Will default to the table name.
std::string getDate()
This private member function will return the current date as a timestamp for the file name.
Definition: fileadapter.cpp:50
std::string getOutputFileName() const
This member function will return the output file name, which was used for saving the last table.
FileAdapter()
FileAdapted default constructor.
Definition: fileadapter.cpp:31
void setbLoadEmptyColsInNextFile(bool _bLoadEmptyCols)
Set, whether empty columns shall be loaded in the next file.
std::string sOutputFile
Definition: fileadapter.hpp:41
FileHeaderInfo openFile(std::string _sFile, bool loadToCache=false, bool overrideTarget=false, int _nHeadline=0, const std::string &sTargetTable="")
This member function loads the contents of the selected file to a new Memory class instance....
virtual bool saveLayer(std::string _sFileName, const std::string &_sCache, unsigned short nPrecision)=0
std::string sPrefix
Definition: fileadapter.hpp:42
bool saveFile(const std::string &sTable, std::string _sFileName, unsigned short nPrecision=7)
This member function wraps the saving functionality of the Memory class. The passed filename is evalu...
void setSavePath(const std::string &_sPath)
This function may be used to update the target saving path of this class.
virtual ~FileAdapter()
Definition: fileadapter.hpp:54
virtual void melt(Memory *_mem, const std::string &sTable, bool overrideTarget=false)=0
std::string getDataFileNameShort() const
This member function will return a shortened version of the data file name, where each "/Path/" strin...
void setbLoadEmptyCols(bool _bLoadEmptyCols)
Set, whether empty columns shall be loaded.
std::string sDataFile
Definition: fileadapter.hpp:44
void condenseDataSet(Memory *_mem)
This member function will condense the data set in the passed Memory instance, i.e....
Definition: fileadapter.cpp:66
void setPrefix(const std::string &_sPrefix)
This function is used to set a file prefix for the saving file name.
std::string generateFileName(const std::string &sExtension=".ndat")
This member function creates a file name from the file prefix and the time stamp.
std::string sSavePath
Definition: fileadapter.hpp:43
This structure wraps all necessary meta information of a single file.
Definition: file.hpp:41