NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
NumeRe::FileAdapter Class Referenceabstract

This class represents the file input and output adapter for the MemoryManager class, separating memory management from file handling. More...

#include <fileadapter.hpp>

Inheritance diagram for NumeRe::FileAdapter:
Collaboration diagram for NumeRe::FileAdapter:

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
 
- Public Member Functions inherited from FileSystem
 FileSystem ()
 Default constructor. More...
 
FileSystemassign (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
 
- Protected Member Functions inherited from FileSystem
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
 
- Protected Attributes inherited from FileSystem
std::string sPath
 
std::string sExecutablePath
 
std::string sTokens [7][2]
 
std::string sValidExtensions
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FileAdapter()

NumeRe::FileAdapter::FileAdapter ( )

FileAdapted default constructor.

Definition at line 31 of file fileadapter.cpp.

References bLoadEmptyCols, bLoadEmptyColsInNextFile, sDataFile, sOutputFile, sPrefix, and sSavePath.

◆ ~FileAdapter()

virtual NumeRe::FileAdapter::~FileAdapter ( )
inlinevirtual

Definition at line 54 of file fileadapter.hpp.

Member Function Documentation

◆ condenseDataSet()

void NumeRe::FileAdapter::condenseDataSet ( Memory _mem)
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.

Parameters
_memMemory*
Returns
void

Definition at line 66 of file fileadapter.cpp.

References bLoadEmptyCols, bLoadEmptyColsInNextFile, Memory::isValid(), and Memory::memArray.

Referenced by openFile().

Here is the call graph for this function:

◆ generateFileName()

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.

Parameters
sExtensionconst std::string&
Returns
std::string

Definition at line 366 of file fileadapter.cpp.

References getDate(), sPrefix, and sSavePath.

Referenced by saveDataObject(), and saveFile().

Here is the call graph for this function:

◆ getDataFileName()

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.

Parameters
sTableconst std::string&
Returns
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().

◆ getDataFileNameShort()

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 "/../".

Returns
std::string

Definition at line 282 of file fileadapter.cpp.

References getDataFileName(), and shortenFileName().

Here is the call graph for this function:

◆ getDate()

std::string NumeRe::FileAdapter::getDate ( )
protected

This private member function will return the current date as a timestamp for the file name.

Returns
std::string

Definition at line 50 of file fileadapter.cpp.

References getTimeStamp().

Referenced by generateFileName().

Here is the call graph for this function:

◆ getOutputFileName()

std::string NumeRe::FileAdapter::getOutputFileName ( ) const

This member function will return the output file name, which was used for saving the last table.

Returns
std::string

Definition at line 296 of file fileadapter.cpp.

References sOutputFile.

Referenced by saveDataObject().

◆ melt()

virtual void NumeRe::FileAdapter::melt ( Memory _mem,
const std::string &  sTable,
bool  overrideTarget = false 
)
pure virtual

Implemented in MemoryManager.

Referenced by openFile().

◆ 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.

Parameters
_sFilestd::string
loadToCachebool
overrideTargetbool
_nHeadlineint
sTargetTableconst std::string&
Returns
FileHeaderInfo

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().

Here is the call graph for this function:

◆ saveFile()

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.

Parameters
sTableconst std::string&
_sFileNamestd::string
nPrecisionunsigned short
Returns
bool

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().

Here is the call graph for this function:

◆ saveLayer()

virtual bool NumeRe::FileAdapter::saveLayer ( std::string  _sFileName,
const std::string &  _sCache,
unsigned short  nPrecision 
)
protectedpure virtual

Implemented in MemoryManager.

Referenced by saveFile().

◆ setbLoadEmptyCols()

void NumeRe::FileAdapter::setbLoadEmptyCols ( bool  _bLoadEmptyCols)

Set, whether empty columns shall be loaded.

Parameters
_bLoadEmptyColsbool
Returns
void

Definition at line 338 of file fileadapter.cpp.

References bLoadEmptyCols.

Referenced by cmd_set(), and NumeReKernel::StartUp().

◆ setbLoadEmptyColsInNextFile()

void NumeRe::FileAdapter::setbLoadEmptyColsInNextFile ( bool  _bLoadEmptyCols)

Set, whether empty columns shall be loaded in the next file.

Parameters
_bLoadEmptyColsbool
Returns
void

Definition at line 352 of file fileadapter.cpp.

References bLoadEmptyColsInNextFile.

Referenced by append_data(), and cmd_load().

◆ setPrefix()

void NumeRe::FileAdapter::setPrefix ( const std::string &  _sPrefix)

This function is used to set a file prefix for the saving file name.

Parameters
_sPrefixconst std::string&
Returns
void

Definition at line 324 of file fileadapter.cpp.

References sPrefix.

Referenced by saveDataObject().

◆ setSavePath()

void NumeRe::FileAdapter::setSavePath ( const std::string &  _sPath)

This function may be used to update the target saving path of this class.

Parameters
_sPathconst std::string&
Returns
void

Definition at line 310 of file fileadapter.cpp.

References sSavePath.

Referenced by cmd_set(), and NumeReKernel::StartUp().

Member Data Documentation

◆ bLoadEmptyCols

bool NumeRe::FileAdapter::bLoadEmptyCols
protected

Definition at line 45 of file fileadapter.hpp.

Referenced by condenseDataSet(), FileAdapter(), and setbLoadEmptyCols().

◆ bLoadEmptyColsInNextFile

bool NumeRe::FileAdapter::bLoadEmptyColsInNextFile
protected

Definition at line 46 of file fileadapter.hpp.

Referenced by condenseDataSet(), FileAdapter(), and setbLoadEmptyColsInNextFile().

◆ sDataFile

std::string NumeRe::FileAdapter::sDataFile
protected

◆ sOutputFile

std::string NumeRe::FileAdapter::sOutputFile
protected

Definition at line 41 of file fileadapter.hpp.

Referenced by FileAdapter(), getOutputFileName(), and saveFile().

◆ sPrefix

std::string NumeRe::FileAdapter::sPrefix
protected

Definition at line 42 of file fileadapter.hpp.

Referenced by FileAdapter(), generateFileName(), and setPrefix().

◆ sSavePath

std::string NumeRe::FileAdapter::sSavePath
protected

Definition at line 43 of file fileadapter.hpp.

Referenced by FileAdapter(), generateFileName(), saveFile(), and setSavePath().


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