Debian Codegraph @

code/datastructures/FlagFileData.h

raw
1 /*
2 Copyright (C) 2009-2012 wxLauncher Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef FLAGFILEDATA_H
20 #define FLAGFILEDATA_H
21
22 class Flag {
23 public:
24 Flag();
25 wxString flagString;
26 wxString shortDescription;
27 wxString fsoCatagory;
28 wxString webURL;
29 bool isRecomendedFlag;
30 wxUint32 easyEnable;
31 wxUint32 easyDisable;
32
33 int GetFlagIndex() const { return this->flagIndex; }
34 private:
35 int flagIndex; // private because the proxy depends on it being correct, so nothing should mess it up
36 static int flagIndexCounter;
37 };
38
39 WX_DECLARE_LIST(Flag, FlagList);
40
41 /** Contains all of the flags in a category. */
42 class FlagCategory {
43 public:
44 wxString categoryName;
45 FlagList flags;
46 };
47
48 WX_DECLARE_LIST(FlagCategory, FlagCategoryList);
49
50 class FlagSet {
51 public:
52 FlagSet(wxString name);
53 wxString name;
54 wxArrayString flagsToEnable;
55 wxArrayString flagsToDisable;
56 };
57
58 WX_DECLARE_LIST(FlagSet, FlagSetsList);
59
60 /** Flag data needed by the profile proxy. */
61 class ProxyFlagDataItem {
62 public:
63 ProxyFlagDataItem(const wxString& flagString, int flagIndex);
64 const wxString& GetFlagString() const { return flagString; }
65 int GetFlagIndex() const { return flagIndex; }
66 private:
67 wxString flagString;
68 int flagIndex;
69 };
70
71 WX_DECLARE_LIST(ProxyFlagDataItem, ProxyFlagData);
72
73 /** Flag data needed by the flag list box. */
74 class FlagListBoxDataItem {
75 public:
76 FlagListBoxDataItem(const wxString& fsoCategory);
77 FlagListBoxDataItem(const wxString& shortDescription,
78 const wxString& flagString, bool isRecommendedFlag);
79 wxString fsoCategory;
80 wxString shortDescription;
81 wxString flagString;
82 bool isRecommendedFlag;
83 private:
84 FlagListBoxDataItem();
85 };
86
87 WX_DECLARE_LIST(FlagListBoxDataItem, FlagListBoxData);
88
89 /** The data extracted from the flag file. */
90 class FlagFileData {
91 public:
92 FlagFileData();
93 ~FlagFileData();
94
95 /** Adds the name of an "easy setup" flag set. */
96 void AddEasyFlag(const wxString& easyFlag);
97
98 void AddFlag(Flag* flag);
99
100 /** Generates the "easy setup" flag sets.
101 This function requires that at least one "easy setup" name has been added.
102 Until support for the new mod.ini is added, this function should be called exactly once. */
103 void GenerateFlagSets();
104
105 /** Creates a version of the data suitable for use by the profile proxy. */
106 ProxyFlagData* GenerateProxyFlagData() const;
107
108 /** Creates a version of the data suitable for use by the flag list box. */
109 FlagListBoxData* GenerateFlagListBoxData() const;
110
111 /** Returns the total number of flags and flag category headers. */
112 size_t GetItemCount() const;
113
114 /** Returns a FlagSet, given its name. Returns NULL if not found. */
115 const FlagSet* GetFlagSet(const wxString& flagSetName) const;
116
117 /** Stores the names of the flag sets in the passed-in array. */
118 void GetFlagSetNames(wxArrayString& arr) const;
119
120 /** Gets the nth flag's webURL (if it has one). */
121 const wxString* GetWebURL(int n) const;
122
123 private:
124 FlagCategoryList::iterator begin() { return this->allSupportedFlagsByCategory.begin(); }
125 FlagCategoryList::const_iterator begin() const { return this->allSupportedFlagsByCategory.begin(); }
126
127 FlagCategoryList::iterator end() { return this->allSupportedFlagsByCategory.end(); }
128 FlagCategoryList::const_iterator end() const { return this->allSupportedFlagsByCategory.end(); }
129
130 wxArrayString easyFlags;
131 FlagSetsList flagSets;
132 FlagCategoryList allSupportedFlagsByCategory;
133 bool isProxyDataGenerated;
134 bool isFlagListBoxDataGenerated;
135 };
136
137 #endif