28 class QDir; |
28 class QDir; |
29 class QFile; |
29 class QFile; |
30 class QStringList; |
30 class QStringList; |
31 |
31 |
32 /** |
32 /** |
33 * Offers access to the data files of hedgewars. |
33 * @brief Offers access to the data files of hedgewars. |
34 * Note: singleton pattern |
34 * |
|
35 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
|
36 * |
35 * @author sheepluva |
37 * @author sheepluva |
36 * @since 0.9.17 |
38 * @since 0.9.17 |
37 */ |
39 */ |
38 class HWDataManager |
40 class HWDataManager |
39 { |
41 { |
40 public: |
42 public: |
41 /** |
43 /** |
42 * Returns a pointer to the singleton instance of this class. |
44 * @brief Returns a pointer to the <i>singleton</i> instance of this class. |
|
45 * |
|
46 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
|
47 * |
43 * @return pointer to the instance. |
48 * @return pointer to the instance. |
44 */ |
49 */ |
45 static HWDataManager & instance(); |
50 static HWDataManager & instance(); |
46 |
51 |
47 /** |
52 /** |
48 * Returns a pointer to the singleton instance of this class. |
53 * @brief Returns a pointer to the <i>singleton</i> instance of this class. |
|
54 * |
49 * @param subDirectory sub-directory to search. |
55 * @param subDirectory sub-directory to search. |
50 * @param filters filters for entry type. |
56 * @param filters filters for entry type. |
51 * @param namefilters filters by name patterns. |
57 * @param nameFilters filters by name patterns. |
52 * @return a list of matches in the subDirectory of data directory. |
58 * @return a sorted list of matches in the subDirectory of data directory. |
53 */ |
59 */ |
54 QStringList entryList(const QString & subDirectory, |
60 QStringList entryList(const QString & subDirectory, |
55 QDir::Filters filters = QDir::NoFilter, |
61 QDir::Filters filters = QDir::NoFilter, |
56 const QStringList & nameFilters = QStringList() |
62 const QStringList & nameFilters = QStringList("*") |
57 ) const; |
63 ) const; |
58 |
64 |
59 /** |
65 /** |
60 * Creates a QFile for the desired data path and returns a pointer to it. |
66 * @brief Creates a file object for the desired data path and |
61 * Use this method if you want to read an existing data file; |
67 * returns a pointer to it. |
|
68 * |
|
69 * Use this method if you want to read an existing data file. |
|
70 * |
62 * @param relativeDataFilePath path to the data file. |
71 * @param relativeDataFilePath path to the data file. |
63 * @return respective QFile pointer, the actual file may actually not exist. |
72 * @return respective <code>QFile</code> pointer, the file may not exist. |
64 */ |
73 */ |
65 QFile * findFileForRead(const QString & relativeDataFilePath) const; |
74 QFile * findFileForRead(const QString & relativeDataFilePath) const; |
66 |
75 |
67 |
76 |
68 /** |
77 /** |
69 * Creates a QFile for the desired data path and returns a pointer to it. |
78 * @brief Creates a file object for the desired data path and |
|
79 * returns a pointer to it. |
|
80 * |
70 * Use this method if you want to create or write into a data file. |
81 * Use this method if you want to create or write into a data file. |
|
82 * |
71 * @param relativeDataFilePath path to the data file. |
83 * @param relativeDataFilePath path to the data file. |
72 * @return respective QFile pointer. |
84 * @return respective <code>QFile</code> pointer. |
73 */ |
85 */ |
74 QFile * findFileForWrite(const QString & relativeDataFilePath) const; |
86 QFile * findFileForWrite(const QString & relativeDataFilePath) const; |
75 |
87 |
76 |
88 |
77 private: |
89 private: |
78 /** |
90 /** |
79 * Singleton class constructor. |
91 * @brief Class constructor of the <i>singleton</i>. |
|
92 * |
|
93 * Not to be used from outside the class, |
|
94 * use the static {@link HWDataManager::instance()} instead. |
|
95 * |
|
96 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
80 */ |
97 */ |
81 HWDataManager(); |
98 HWDataManager(); |
82 |
99 |
83 QDir * defaultData; |
100 QDir * defaultData; |
84 QDir * userData; |
101 QDir * userData; |