Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FileManager Class Referenceabstract

Abstract singleton adapter for opening files. More...

#include <filemanager.h>

+ Inheritance diagram for FileManager:

Public Member Functions

 FileManager ()
 Constructor, setting the singleton pointer to its own instance. More...
 
virtual ~FileManager ()
 Virtual destructor. More...
 
virtual bool open (std::ifstream &stream, const std::string &absolute, std::ios_base::openmode mode=std::ios_base::in)
 Open an input stream. More...
 
virtual bool open (std::ofstream &stream, const std::string &absolute, std::ios_base::openmode mode=std::ios_base::out)
 Open an output file stream. More...
 
virtual std::string getLogFilePath (const std::string &logname) const =0
 Abstract function: Get the standard path for logfiles. More...
 
virtual std::string getAlgorithmInformationFileContent (const std::string &algorithmId) const =0
 Abstract function: Get the file content for an algorithm. More...
 

Static Public Member Functions

static FileManagergetSingleton ()
 FileManager::getSingleton: Get a reference to the singleton. More...
 

Static Private Attributes

static std::unique_ptr
< FileManager
mSingleton
 Singleton unique pointer. More...
 

Detailed Description

Abstract singleton adapter for opening files.

This adapter provides an interface for opening files. The tuner produces various files (e.g. log files) which have to be saved at certain standard locations, depending on the platform of the implementation. For example, Windows and Android applications provide different standard locations for writing and reading files. These differences are accounted for in the derived implemenations.

The FileManager is a singleton class, i.e., there is only a single instance.

Definition at line 43 of file filemanager.h.

Constructor & Destructor Documentation

FileManager::FileManager ( )
inline

Constructor, setting the singleton pointer to its own instance.

Definition at line 47 of file filemanager.h.

virtual FileManager::~FileManager ( )
inlinevirtual

Virtual destructor.

Definition at line 48 of file filemanager.h.

Member Function Documentation

virtual std::string FileManager::getAlgorithmInformationFileContent ( const std::string &  algorithmId) const
pure virtual

Abstract function: Get the file content for an algorithm.

In the EPT each tuning algorithm comes with its own xml file. This function opens the xml file and returns its content in form of a single string. The only parameter is the ID of the algorithm. This function has to be implemented in the derived class.

See also
FileManagerForQt
Parameters
algorithID: Identification string of the algorithm
Returns
String containing the information of the corresponding XML file

Implemented in FileManagerForQt.

virtual std::string FileManager::getLogFilePath ( const std::string &  logname) const
pure virtual

Abstract function: Get the standard path for logfiles.

Each platform provides a different standard directory for logfile. This abstract function has to be overridden accordingly in the respective implementation. The tuner software allows for different logs labelled by certain names passed here as an argument.

See also
FileManagerForQt
Parameters
logname: The name of the log
Returns
Absolute path to the log

Implemented in FileManagerForQt.

FileManager & FileManager::getSingleton ( )
static

FileManager::getSingleton: Get a reference to the singleton.

Returns
Pointer to the instance of the singleton.

Definition at line 47 of file filemanager.cpp.

bool FileManager::open ( std::ifstream &  stream,
const std::string &  absolute,
std::ios_base::openmode  mode = std::ios_base::in 
)
virtual

Open an input stream.

This function opens an input stream. If the stream can be opened successfully an information message is sent. If it cannot be opened a warning is displayed. The function may be overwritten in the implementation.

See also
FileManagerForQt
Parameters
stream: Reference to standard C11 stream
absolute: Absolute path and file name
mode: Standard C11 reading mode
Returns
true if the stream could be opened

Definition at line 71 of file filemanager.cpp.

bool FileManager::open ( std::ofstream &  stream,
const std::string &  absolute,
std::ios_base::openmode  mode = std::ios_base::out 
)
virtual

Open an output file stream.

This function opens an output stream. If the stream can be opened successfully an information message is sent. If it cannot be opened a warning is displayed. The function may be overwritten in the implementation.

See also
FileManagerForQt
Parameters
Referenceto the C11 standard output stream.
Absolutepath and filename.
StandardC11 output mode.
Returns
true if the stream could be opened successfully

Definition at line 106 of file filemanager.cpp.

Member Data Documentation

std::unique_ptr< FileManager > FileManager::mSingleton
staticprivate

Singleton unique pointer.

Singleton pointer.

The FileManager is a singleton class, meaning that it admits only a single instance. The unique pointer mSingleton points to this instance.

Definition at line 90 of file filemanager.h.


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