hydrogen 1.1.1
Files Class Reference

Files is in charge of writing and reading Patterns, Drumkits, Songs to the filesystem. More...

#include <Files.h>

Inheritance diagram for Files:
Object

Public Types

enum  SaveMode { SAVE_NEW , SAVE_OVERWRITE , SAVE_PATH , SAVE_TMP }
 

Static Public Member Functions

static QString savePatternNew (const QString &fileName, Pattern *pattern, Song *song, const QString &drumkitName)
 save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will NOT overwrite an existing file More...
 
static QString savePatternOver (const QString &fileName, Pattern *pattern, Song *song, const QString &drumkitName)
 save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will overwrite an existing file More...
 
static QString savePatternPath (const QString &filePath, Pattern *pattern, Song *song, const QString &drumkitName)
 save the given pattern to filePath will overwrite an existing file More...
 
static QString savePatternTmp (const QString &fileName, Pattern *pattern, Song *song, const QString &drumkitName)
 save the given pattern under <Tmp_directory> with a unique filename built from <fileName> will overwrite an existing file More...
 
static QString savePlaylistPath (const QString &filePath, Playlist *playlist, bool relativePaths)
 save the given playlist to filePath will overwrite an existing file More...
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 

Static Private Member Functions

static QString savePattern (SaveMode mode, const QString &fileName, const Pattern *pattern, Song *song, const QString &drumkitName)
 
static QString savePlaylist (SaveMode mode, const QString &fileName, Playlist *playlist, bool relativePaths)
 

Additional Inherited Members

- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Files is in charge of writing and reading Patterns, Drumkits, Songs to the filesystem.

Member Enumeration Documentation

◆ SaveMode

enum SaveMode
Enumerator
SAVE_NEW 
SAVE_OVERWRITE 
SAVE_PATH 
SAVE_TMP 

Member Function Documentation

◆ savePattern()

QString savePattern ( SaveMode  mode,
const QString &  fileName,
const Pattern pattern,
Song song,
const QString &  drumkitName 
)
staticprivate

◆ savePatternNew()

static QString savePatternNew ( const QString &  fileName,
Pattern pattern,
Song song,
const QString &  drumkitName 
)
inlinestatic

save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will NOT overwrite an existing file

Parameters
fileNameto build filePath from
patternthe one to be saved
songto access license, author info
drumkitNameto build filePath from and to access name info
Returns
filePath on success, NULL on failure

◆ savePatternOver()

static QString savePatternOver ( const QString &  fileName,
Pattern pattern,
Song song,
const QString &  drumkitName 
)
inlinestatic

save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will overwrite an existing file

Parameters
fileNameto build filePath from
patternthe one to be saved
songto access license, author info
drumkitNameto build filePath from and to access name info
Returns
filePath on success, NULL on failure

◆ savePatternPath()

static QString savePatternPath ( const QString &  filePath,
Pattern pattern,
Song song,
const QString &  drumkitName 
)
inlinestatic

save the given pattern to filePath will overwrite an existing file

Parameters
filePathto write the pattern to
patternthe one to be saved
songto access license, author info
drumkitNameto access name info
Returns
filePath on success, NULL on failure

◆ savePatternTmp()

static QString savePatternTmp ( const QString &  fileName,
Pattern pattern,
Song song,
const QString &  drumkitName 
)
inlinestatic

save the given pattern under <Tmp_directory> with a unique filename built from <fileName> will overwrite an existing file

Parameters
fileNameto build filePath from
patternthe one to be saved
songto access license, author info
drumkitNameto access name info
Returns
filePath on success, NULL on failure

◆ savePlaylist()

QString savePlaylist ( SaveMode  mode,
const QString &  fileName,
Playlist playlist,
bool  relativePaths 
)
staticprivate

◆ savePlaylistPath()

static QString savePlaylistPath ( const QString &  filePath,
Playlist playlist,
bool  relativePaths 
)
inlinestatic

save the given playlist to filePath will overwrite an existing file

Parameters
filePathto write the playlist to
playlistthe one to be saved
relativePathsshould the path to the songs be relative to the playlist instead of absolute
Returns
filePath on success, NULL on failure