34 class QFile; |
34 class QFile; |
35 class QStringList; |
35 class QStringList; |
36 |
36 |
37 /** |
37 /** |
38 * @brief Offers access to the data files of hedgewars. |
38 * @brief Offers access to the data files of hedgewars. |
39 * |
39 * |
40 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
40 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
41 * |
41 * |
42 * @author sheepluva |
42 * @author sheepluva |
43 * @since 0.9.17 |
43 * @since 0.9.17 |
44 */ |
44 */ |
45 class HWDataManager |
45 class HWDataManager |
46 { |
46 { |
47 public: |
47 public: |
48 /** |
48 /** |
49 * @brief Returns reference to the <i>singleton</i> instance of this class. |
49 * @brief Returns reference to the <i>singleton</i> instance of this class. |
50 * |
50 * |
51 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
51 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
52 * |
52 * |
53 * @return reference to the instance. |
53 * @return reference to the instance. |
54 */ |
54 */ |
55 static HWDataManager & instance(); |
55 static HWDataManager & instance(); |
56 |
56 |
57 /** |
57 /** |
58 * @brief Returns a sorted list of data directory entries. |
58 * @brief Returns a sorted list of data directory entries. |
59 * |
59 * |
60 * @param subDirectory sub-directory to search. |
60 * @param subDirectory sub-directory to search. |
61 * @param filters filters for entry type. |
61 * @param filters filters for entry type. |
62 * @param nameFilters filters by name patterns. |
62 * @param nameFilters filters by name patterns. |
63 * @return a sorted list of matches in the subDirectory of data directory. |
63 * @return a sorted list of matches in the subDirectory of data directory. |
64 */ |
64 */ |
65 QStringList entryList(const QString & subDirectory, |
65 QStringList entryList(const QString & subDirectory, |
66 QDir::Filters filters = QDir::NoFilter, |
66 QDir::Filters filters = QDir::NoFilter, |
67 const QStringList & nameFilters = QStringList("*") |
67 const QStringList & nameFilters = QStringList("*") |
68 ) const; |
68 ) const; |
69 |
69 |
70 /** |
70 /** |
71 * @brief Returns the path for the desires data file. |
71 * @brief Returns the path for the desires data file. |
72 * |
72 * |
73 * Use this method if you want to read an existing data file. |
73 * Use this method if you want to read an existing data file. |
74 * |
74 * |
75 * @param relativeDataFilePath relative path of the data file. |
75 * @param relativeDataFilePath relative path of the data file. |
76 * @return real path to the file. |
76 * @return real path to the file. |
77 */ |
77 */ |
78 QString findFileForRead(const QString & relativeDataFilePath) const; |
78 QString findFileForRead(const QString & relativeDataFilePath) const; |
79 |
79 |
80 |
80 |
81 /** |
81 /** |
82 * @brief Returns the path for the data file that is to be written. |
82 * @brief Returns the path for the data file that is to be written. |
83 * |
83 * |
84 * Use this method if you want to create or write into a data file. |
84 * Use this method if you want to create or write into a data file. |
85 * |
85 * |
86 * @param relativeDataFilePath relative path of data file write path. |
86 * @param relativeDataFilePath relative path of data file write path. |
87 * @return destination of path data file. |
87 * @return destination of path data file. |
88 */ |
88 */ |
89 QString findFileForWrite(const QString & relativeDataFilePath) const; |
89 QString findFileForWrite(const QString & relativeDataFilePath) const; |
90 |
90 |
91 |
91 |
92 private: |
92 private: |
93 /** |
93 /** |
94 * @brief Class constructor of the <i>singleton</i>. |
94 * @brief Class constructor of the <i>singleton</i>. |
95 * |
95 * |
96 * Not to be used from outside the class, |
96 * Not to be used from outside the class, |
97 * use the static {@link HWDataManager::instance()} instead. |
97 * use the static {@link HWDataManager::instance()} instead. |
98 * |
98 * |
99 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
99 * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
100 */ |
100 */ |
101 HWDataManager(); |
101 HWDataManager(); |
102 |
102 |
103 QDir * defaultData; ///< directory of the installed data |
103 QDir * defaultData; ///< directory of the installed data |
104 QDir * userData; ///< directory of custom data in the user's directory |
104 QDir * userData; ///< directory of custom data in the user's directory |
105 }; |
105 }; |
106 |
106 |
107 #endif // HEDGEWARS_HWDATAMANAGER_H |
107 #endif // HEDGEWARS_HWDATAMANAGER_H |