![]() |
NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class represents the file input and output adapter for the MemoryManager class, separating memory management from file handling. More...
#include <fileadapter.hpp>
Public Member Functions | |
FileAdapter () | |
FileAdapted default constructor. More... | |
virtual | ~FileAdapter () |
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. This instance is either appended to the already existing instances or melted with an existing one, if the existing one has the same name. More... | |
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 evaluated here and a generic one is generated, if necessary. More... | |
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. More... | |
std::string | getDataFileNameShort () const |
This member function will return a shortened version of the data file name, where each "/Path/" string part is transformed to "/../". More... | |
std::string | getOutputFileName () const |
This member function will return the output file name, which was used for saving the last table. More... | |
void | setSavePath (const std::string &_sPath) |
This function may be used to update the target saving path of this class. More... | |
void | setPrefix (const std::string &_sPrefix) |
This function is used to set a file prefix for the saving file name. More... | |
void | setbLoadEmptyCols (bool _bLoadEmptyCols) |
Set, whether empty columns shall be loaded. More... | |
void | setbLoadEmptyColsInNextFile (bool _bLoadEmptyCols) |
Set, whether empty columns shall be loaded in the next file. More... | |
std::string | generateFileName (const std::string &sExtension=".ndat") |
This member function creates a file name from the file prefix and the time stamp. More... | |
virtual void | melt (Memory *_mem, const std::string &sTable, bool overrideTarget=false)=0 |
![]() | |
FileSystem () | |
Default constructor. More... | |
FileSystem & | assign (const FileSystem &_fSys) |
Assignment member function to copy the settings from another FileSystem instance. More... | |
std::string | ValidFileName (std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const |
This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension. More... | |
std::string | ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const |
This member function evaluates, whether the passed foldername is a valid foldername. More... | |
std::string | ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const |
This member function validizes the passed file name and creates the needed folders on-the-fly. More... | |
int | setPath (std::string _sPath, bool bMkDir, std::string _sExePath) |
This member function may be used to set the preferred file path of the current FileSystem instance. More... | |
void | createRevisionsFolder () |
This member function creates the hidden revisions folders for the version control system. More... | |
std::string | getPath () const |
Returns the default path of this FileSystem instance. More... | |
std::vector< std::string > | getFileParts (const std::string &sFilePath) const |
This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More... | |
FileInfo | getFileInfo (const std::string &sFilePath) const |
Return the file information about the passed file path. More... | |
void | setTokens (std::string _sTokens) |
This member function may be used to update the path placeholders of the current FileSystem instance. More... | |
bool | isFile (const std::string &_sPath) const |
This function determines, whether a path name indicates a file or a folder. More... | |
void | initializeFromKernel () |
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More... | |
void | setProgramPath (std::string _sExePath) |
std::string | getProgramPath () const |
void | declareFileType (const std::string &sFileType) |
Protected Member Functions | |
std::string | getDate () |
This private member function will return the current date as a timestamp for the file name. More... | |
void | condenseDataSet (Memory *_mem) |
This member function will condense the data set in the passed Memory instance, i.e. it will remove unneeded empty columns in the table. More... | |
virtual bool | saveLayer (std::string _sFileName, const std::string &_sCache, unsigned short nPrecision)=0 |
![]() | |
int | createFolders (const std::string &_sPath) const |
This member function creates all missing directories in the passed path. More... | |
Protected Attributes | |
std::string | sOutputFile |
std::string | sPrefix |
std::string | sSavePath |
std::string | sDataFile |
bool | bLoadEmptyCols |
bool | bLoadEmptyColsInNextFile |
![]() | |
std::string | sPath |
std::string | sExecutablePath |
std::string | sTokens [7][2] |
std::string | sValidExtensions |
This class represents the file input and output adapter for the MemoryManager class, separating memory management from file handling.
Definition at line 38 of file fileadapter.hpp.
NumeRe::FileAdapter::FileAdapter | ( | ) |
FileAdapted default constructor.
Definition at line 31 of file fileadapter.cpp.
References bLoadEmptyCols, bLoadEmptyColsInNextFile, sDataFile, sOutputFile, sPrefix, and sSavePath.
|
inlinevirtual |
Definition at line 54 of file fileadapter.hpp.
|
protected |
This member function will condense the data set in the passed Memory instance, i.e. it will remove unneeded empty columns in the table.
_mem | Memory* |
Definition at line 66 of file fileadapter.cpp.
References bLoadEmptyCols, bLoadEmptyColsInNextFile, Memory::isValid(), and Memory::memArray.
Referenced by openFile().
std::string NumeRe::FileAdapter::generateFileName | ( | const std::string & | sExtension = ".ndat" | ) |
This member function creates a file name from the file prefix and the time stamp.
sExtension | const std::string& |
Definition at line 366 of file fileadapter.cpp.
References getDate(), sPrefix, and sSavePath.
Referenced by saveDataObject(), and saveFile().
std::string NumeRe::FileAdapter::getDataFileName | ( | const std::string & | sTable | ) | const |
This member function will return the file name of the selected table. Will default to the table name.
sTable | const std::string& |
Definition at line 264 of file fileadapter.cpp.
References sDataFile.
Referenced by cmd_reload(), createOutputForHist1D(), createOutputForHist2D(), createStatsFile(), getDataFileNameShort(), getDataForFit(), load_data(), replaceDataEntities(), and show_data().
std::string NumeRe::FileAdapter::getDataFileNameShort | ( | ) | const |
This member function will return a shortened version of the data file name, where each "/Path/" string part is transformed to "/../".
Definition at line 282 of file fileadapter.cpp.
References getDataFileName(), and shortenFileName().
|
protected |
This private member function will return the current date as a timestamp for the file name.
Definition at line 50 of file fileadapter.cpp.
References getTimeStamp().
Referenced by generateFileName().
std::string NumeRe::FileAdapter::getOutputFileName | ( | ) | const |
This member function will return the output file name, which was used for saving the last table.
Definition at line 296 of file fileadapter.cpp.
References sOutputFile.
Referenced by saveDataObject().
|
pure virtual |
Implemented in MemoryManager.
Referenced by openFile().
FileHeaderInfo NumeRe::FileAdapter::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. This instance is either appended to the already existing instances or melted with an existing one, if the existing one has the same name.
_sFile | std::string |
loadToCache | bool |
overrideTarget | bool |
_nHeadline | int |
sTargetTable | const std::string& |
Definition at line 108 of file fileadapter.cpp.
References SyntaxError::CANNOT_READ_FILE, NumeRe::TableMetaData::comment, condenseDataSet(), Memory::convert(), Memory::createTableHeaders(), DetachedLogger::debug(), fileExists(), g_logger, NumeRe::GenericFile::getData(), NumeRe::GenericFile::getExtension(), NumeRe::getFileByType(), NumeRe::GenericFile::getFileHeaderInformation(), DetachedLogger::info(), SyntaxError::invalid_position, melt(), Memory::memArray, NumeRe::FileHeaderInfo::nCols, NumeRe::FileHeaderInfo::nRows, NumeRe::GenericFile::read(), Memory::resizeMemory(), NumeRe::FileHeaderInfo::sComment, sDataFile, Memory::setMetaData(), Memory::setSaveStatus(), Memory::shrink(), NumeRe::TableMetaData::source, NumeRe::FileHeaderInfo::sTableName, toString(), and FileSystem::ValidFileName().
Referenced by append_data(), cmd_load(), and load_data().
bool NumeRe::FileAdapter::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 evaluated here and a generic one is generated, if necessary.
sTable | const std::string& |
_sFileName | std::string |
nPrecision | unsigned short |
Definition at line 238 of file fileadapter.cpp.
References generateFileName(), saveLayer(), FileSystem::setPath(), FileSystem::sExecutablePath, sOutputFile, FileSystem::sPath, sSavePath, and FileSystem::ValidFileName().
Referenced by saveDataObject().
|
protectedpure virtual |
Implemented in MemoryManager.
Referenced by saveFile().
void NumeRe::FileAdapter::setbLoadEmptyCols | ( | bool | _bLoadEmptyCols | ) |
Set, whether empty columns shall be loaded.
_bLoadEmptyCols | bool |
Definition at line 338 of file fileadapter.cpp.
References bLoadEmptyCols.
Referenced by cmd_set(), and NumeReKernel::StartUp().
void NumeRe::FileAdapter::setbLoadEmptyColsInNextFile | ( | bool | _bLoadEmptyCols | ) |
Set, whether empty columns shall be loaded in the next file.
_bLoadEmptyCols | bool |
Definition at line 352 of file fileadapter.cpp.
References bLoadEmptyColsInNextFile.
Referenced by append_data(), and cmd_load().
void NumeRe::FileAdapter::setPrefix | ( | const std::string & | _sPrefix | ) |
This function is used to set a file prefix for the saving file name.
_sPrefix | const std::string& |
Definition at line 324 of file fileadapter.cpp.
References sPrefix.
Referenced by saveDataObject().
void NumeRe::FileAdapter::setSavePath | ( | const std::string & | _sPath | ) |
This function may be used to update the target saving path of this class.
_sPath | const std::string& |
Definition at line 310 of file fileadapter.cpp.
References sSavePath.
Referenced by cmd_set(), and NumeReKernel::StartUp().
|
protected |
Definition at line 45 of file fileadapter.hpp.
Referenced by condenseDataSet(), FileAdapter(), and setbLoadEmptyCols().
|
protected |
Definition at line 46 of file fileadapter.hpp.
Referenced by condenseDataSet(), FileAdapter(), and setbLoadEmptyColsInNextFile().
|
protected |
Definition at line 44 of file fileadapter.hpp.
Referenced by FileAdapter(), getDataFileName(), openFile(), MemoryManager::removeData(), and MemoryManager::removeTablesFromMemory().
|
protected |
Definition at line 41 of file fileadapter.hpp.
Referenced by FileAdapter(), getOutputFileName(), and saveFile().
|
protected |
Definition at line 42 of file fileadapter.hpp.
Referenced by FileAdapter(), generateFileName(), and setPrefix().
|
protected |
Definition at line 43 of file fileadapter.hpp.
Referenced by FileAdapter(), generateFileName(), saveFile(), and setSavePath().