|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com> |
|
4 * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License as published by |
|
8 * the Free Software Foundation; version 2 of the License |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 */ |
|
19 |
|
20 #ifndef HEDGEWARS_HWDATAMANAGER_H |
|
21 #define HEDGEWARS_HWDATAMANAGER_H |
|
22 |
|
23 #include <QDir> |
|
24 #include <QFile> |
|
25 |
|
26 #include <QStringList> |
|
27 |
|
28 class QDir; |
|
29 class QFile; |
|
30 class QStringList; |
|
31 |
|
32 /** |
|
33 * Offers access to the data files of hedgewars. |
|
34 * Note: singleton pattern |
|
35 * @author sheepluva |
|
36 * @since 0.9.17 |
|
37 */ |
|
38 class HWDataManager |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * Returns a pointer to the singleton instance of this class. |
|
43 * @return pointer to the instance. |
|
44 */ |
|
45 static HWDataManager & instance(); |
|
46 |
|
47 /** |
|
48 * Returns a pointer to the singleton instance of this class. |
|
49 * @param subDirectory sub-directory to search. |
|
50 * @param filters filters for entry type. |
|
51 * @param namefilters filters by name patterns. |
|
52 * @return a list of matches in the subDirectory of data directory. |
|
53 */ |
|
54 QStringList entryList(const QString & subDirectory, |
|
55 QDir::Filters filters = QDir::NoFilter, |
|
56 const QStringList & nameFilters = QStringList() |
|
57 ) const; |
|
58 |
|
59 /** |
|
60 * Creates a QFile for the desired data path and returns a pointer to it. |
|
61 * Use this method if you want to read an existing data file; |
|
62 * @param relativeDataFilePath path to the data file. |
|
63 * @return respective QFile pointer, the actual file may actually not exist. |
|
64 */ |
|
65 QFile * findFileForRead(const QString & relativeDataFilePath) const; |
|
66 |
|
67 |
|
68 /** |
|
69 * Creates a QFile for the desired data path and returns a pointer to it. |
|
70 * Use this method if you want to create or write into a data file. |
|
71 * @param relativeDataFilePath path to the data file. |
|
72 * @return respective QFile pointer. |
|
73 */ |
|
74 QFile * findFileForWrite(const QString & relativeDataFilePath) const; |
|
75 |
|
76 |
|
77 private: |
|
78 /** |
|
79 * Singleton class constructor. |
|
80 */ |
|
81 HWDataManager(); |
|
82 |
|
83 QDir * defaultData; |
|
84 QDir * userData; |
|
85 }; |
|
86 |
|
87 #endif // HEDGEWARS_HWDATAMANAGER_H |