hydrogen 1.2.6
Files.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef H2C_FILES_H
24#define H2C_FILES_H
25
26#include <core/Object.h>
27#include <QtCore/QString>
28
29namespace H2Core
30{
31
32class Pattern;
33class Playlist;
34class Song;
35
40class Files : public H2Core::Object<Files>
41{
43 public:
44 enum SaveMode {
45 SAVE_NEW, // construct regular path, do not overwrite
46 SAVE_OVERWRITE, // construct regular path, overwrite existing file
47 SAVE_PATH, // given filename is the path
48 SAVE_TMP, // construct the path in save
49 };
50
60 static inline QString savePatternNew( const QString& fileName, Pattern* pattern, std::shared_ptr<Song> song, const QString& drumkitName )
61 {
62 return savePattern( SAVE_NEW, fileName, pattern, song, drumkitName );
63 }
64
74 static inline QString savePatternOver( const QString& fileName, Pattern* pattern, std::shared_ptr<Song> song, const QString& drumkitName )
75 {
76 return savePattern( SAVE_OVERWRITE, fileName, pattern, song, drumkitName );
77 }
78
88 static inline QString savePatternPath( const QString& filePath, Pattern* pattern, std::shared_ptr<Song> song, const QString& drumkitName )
89 {
90 return savePattern( SAVE_PATH, filePath, pattern, song, drumkitName );
91 }
92
102 static inline QString savePatternTmp( const QString& fileName, Pattern* pattern, std::shared_ptr<Song> song, const QString& drumkitName )
103 {
104 return savePattern( SAVE_TMP, fileName, pattern, song, drumkitName );
105 }
106
115 static inline QString savePlaylistPath( const QString& filePath, Playlist* playlist, bool relativePaths )
116 {
117 return savePlaylist( SAVE_PATH, filePath, playlist, relativePaths );
118 }
119
120 private:
121 static QString savePattern( SaveMode mode, const QString& fileName, const Pattern* pattern, std::shared_ptr<Song> song, const QString& drumkitName );
122 static QString savePlaylist( SaveMode mode, const QString& fileName, Playlist* playlist, bool relativePaths );
123};
124
125};
126
127#endif // H2C_FILES_H
128
129/* vim: set softtabstop=4 noexpandtab: */
#define H2_OBJECT(name)
Definition Object.h:227
Files is in charge of writing and reading Patterns, Drumkits, Songs to the filesystem.
Definition Files.h:41
static QString savePatternNew(const QString &fileName, Pattern *pattern, std::shared_ptr< Song > song, const QString &drumkitName)
save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will NOT overwr...
Definition Files.h:60
static QString savePlaylistPath(const QString &filePath, Playlist *playlist, bool relativePaths)
save the given playlist to filePath will overwrite an existing file
Definition Files.h:115
static QString savePatternPath(const QString &filePath, Pattern *pattern, std::shared_ptr< Song > song, const QString &drumkitName)
save the given pattern to filePath will overwrite an existing file
Definition Files.h:88
@ SAVE_OVERWRITE
Definition Files.h:46
static QString savePatternOver(const QString &fileName, Pattern *pattern, std::shared_ptr< Song > song, const QString &drumkitName)
save the given pattern to <user_data_path>/pattern/<drumkitName>/<fileName>.h2pattern will overwrite ...
Definition Files.h:74
static QString savePlaylist(SaveMode mode, const QString &fileName, Playlist *playlist, bool relativePaths)
Definition Files.cpp:71
static QString savePattern(SaveMode mode, const QString &fileName, const Pattern *pattern, std::shared_ptr< Song > song, const QString &drumkitName)
Definition Files.cpp:34
static QString savePatternTmp(const QString &fileName, Pattern *pattern, std::shared_ptr< Song > song, const QString &drumkitName)
save the given pattern under <Tmp_directory> with a unique filename built from <fileName> will overwr...
Definition Files.h:102
Pattern class is a Note container.
Definition Pattern.h:46
Drumkit info.
Definition Playlist.h:37
Song class.
Definition Song.h:61