/[gr2lib]/trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 191 - (show annotations) (download)
Sat Jul 24 06:31:50 2010 UTC (9 years, 1 month ago) by william
File size: 11465 byte(s)
In coreapi:
*Add more texture methods
*Move everthing into related classes, to group related methods,etc
*Update all classes to use these grouped classes

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 using gr2lib.core.typedefs;
6 using gr2lib.core.exceptions;
7 using gr2lib.core.interfaces;
8 using System.ComponentModel;
9
10 namespace gr2lib.core.apiversion
11 {
12 #region public class VersionType
13 /// <summary>
14 /// Iversiontype inteface
15 /// </summary>
16 public interface Iversiontype
17 {
18 /// <summary>
19 /// get/set the major
20 /// </summary>
21 int major { get; set; }
22 /// <summary>
23 /// get/set the minor
24 /// </summary>
25 int minor { get; set; }
26 /// <summary>
27 /// get/set the customization
28 /// </summary>
29 int customization { get; set; }
30 /// <summary>
31 /// get/set the build
32 /// </summary>
33 int build { get; set; }
34 //string version { get; }
35 }
36 /// <summary>
37 /// versiontype class
38 /// </summary>
39 public class versiontype : Iversiontype
40 {
41 /// <summary>
42 /// default versiontype construction: 0.0.0.0
43 /// </summary>
44 public versiontype()
45 {
46 this.major = 0;
47 this.minor = 0;
48 this.customization = 0;
49 this.build = 0;
50 }
51 /// <summary>
52 /// versiontype construction: major.minor.customization.build
53 /// </summary>
54 public versiontype(int major, int minor, int customization, int build)
55 {
56 this.major = major;
57 this.minor = minor;
58 this.customization = customization;
59 this.build = build;
60 }
61 /// <summary>
62 /// versiontype construction: major.minor.customization.build (via string: "0.0.0.0")
63 /// </summary>
64 public versiontype(string version)
65 {
66 string[] _version = version.Split('.');
67
68 this.major = Convert.ToInt32(_version[0]);
69 this.minor = Convert.ToInt32(_version[1]);
70 this.customization = Convert.ToInt32(_version[2]);
71 this.build = Convert.ToInt32(_version[3]);
72 }
73 /// <summary>
74 /// Gets this version in format: major.minor.customization.build
75 /// </summary>
76 /// <returns></returns>
77 public override string ToString()
78 {
79 return this.version;
80 }
81
82 #region IVersionType Members
83 /// <summary>
84 /// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build)
85 /// </summary>
86 private string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
87 private int _major;
88 /// <summary>
89 /// Returns the Major of the Granny2 API Version (X.0.0.0)
90 /// </summary>
91 [RefreshPropertiesAttribute(RefreshProperties.All)]
92 public int major { get { return _major; } set { _major = value; } }
93
94 private int _minor;
95 /// <summary>
96 /// Returns the Minor of the Granny2 API Version (0.X.0.0)
97 /// </summary>
98 [RefreshPropertiesAttribute(RefreshProperties.All)]
99 public int minor { get { return _minor; } set { _minor = value; } }
100
101 private int _customization;
102 /// <summary>
103 /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0)
104 /// </summary>
105 [RefreshPropertiesAttribute(RefreshProperties.All)]
106 public int customization { get { return _customization; } set { _customization = value; } }
107
108 private int _build;
109 /// <summary>
110 /// Returns the Build of the Granny2 API Version (0.0.0.X)
111 /// </summary>
112 [RefreshPropertiesAttribute(RefreshProperties.All)]
113 public int build { get { return _build; } set { _build = value; } }
114 #endregion
115 }
116 #endregion
117
118 #region public class Granny2APIVersion
119 /// <summary>
120 /// Handle's the checking of the Loaded Granny2 API Version
121 /// </summary>
122 public class granny2apiversion : igranny2apiversion
123 {
124 /// <summary>
125 /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30
126 /// </summary>
127 public granny2apiversion()
128 {
129 this._expectedapiversion = new versiontype(
130 apiversiontype.GrannyProductMajorVersion,
131 apiversiontype.GrannyProductMinorVersion,
132 apiversiontype.GrannyProductCustomization,
133 apiversiontype.GrannyProductBuildNumber);
134
135 granny2apiloader _loader = new granny2apiloader(true);
136 this._apiversion = new versiontype();
137 this._apiversionsmatch = this.GrannyVersionsMatch();
138 this.GetGrannyVersion();
139
140 }
141 /// <summary>
142 /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30 (allow disable looking for granny api)
143 /// </summary>
144 public granny2apiversion(bool checkforgrannyapi)
145 {
146 if (checkforgrannyapi)
147 {
148 this._expectedapiversion = new versiontype(
149 apiversiontype.GrannyProductMajorVersion,
150 apiversiontype.GrannyProductMinorVersion,
151 apiversiontype.GrannyProductCustomization,
152 apiversiontype.GrannyProductBuildNumber);
153
154 granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
155 this._apiversion = new versiontype();
156 this._apiversionsmatch = this.GrannyVersionsMatch();
157 this.GetGrannyVersion();
158 }
159
160 }
161 /// <summary>
162 /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
163 /// </summary>
164 public granny2apiversion(granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber)
165 {
166 this._expectedapiversion = new versiontype(
167 ExpectedMajorVersion,
168 ExpectedMinorVersion,
169 ExpectedCustomization,
170 ExpectedBuildNumber);
171
172 granny2apiloader _loader = new granny2apiloader(true);
173 this._apiversion = new versiontype();
174 this._apiversionsmatch = this.GrannyVersionsMatch();
175 this.GetGrannyVersion();
176 }
177 /// <summary>
178 /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
179 /// </summary>
180 public granny2apiversion(bool checkforgrannyapi, granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber)
181 {
182 if (checkforgrannyapi)
183 {
184 this._expectedapiversion = new versiontype(
185 ExpectedMajorVersion,
186 ExpectedMinorVersion,
187 ExpectedCustomization,
188 ExpectedBuildNumber);
189
190 granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
191 this._apiversion = new versiontype();
192 this._apiversionsmatch = this.GrannyVersionsMatch();
193 this.GetGrannyVersion();
194 }
195 }
196 /// <summary>
197 /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0")
198 /// </summary>
199 public granny2apiversion(string ExceptedVersion)
200 {
201 this._expectedapiversion = new versiontype(ExceptedVersion);
202
203 granny2apiloader _loader = new granny2apiloader(true);
204 this._apiversion = new versiontype();
205 this._apiversionsmatch = this.GrannyVersionsMatch();
206 this.GetGrannyVersion();
207 }
208 /// <summary>
209 /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0")
210 /// </summary>
211 public granny2apiversion(bool checkforgrannyapi,string ExceptedVersion)
212 {
213 if (checkforgrannyapi)
214 {
215 this._expectedapiversion = new versiontype(ExceptedVersion);
216
217 granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
218 this._apiversion = new versiontype();
219 this._apiversionsmatch = this.GrannyVersionsMatch();
220 this.GetGrannyVersion();
221 }
222 }
223
224 #region APIVersion Support
225 private class apiversiontype
226 {
227 public static string GrannyProductVersion = "2.7.0.30";
228 public static granny_int32x GrannyProductMajorVersion = 2;
229 public static granny_int32x GrannyProductMinorVersion = 7;
230 public static granny_int32x GrannyProductCustomization = 0;
231 public static granny_int32x GrannyProductBuildNumber = 30;
232 public static string GrannyProductReleaseName = "release";
233 };
234
235 private bool GrannyVersionsMatch()
236 {
237 return gr2lib.core.coreapi.VersionSupport.GrannyVersionsMatch(
238 this._expectedapiversion.major,
239 this._expectedapiversion.minor,
240 this._expectedapiversion.customization,
241 this._expectedapiversion.build);
242 }
243 private void GetGrannyVersion()
244 {
245 granny_int32x major = 0;
246 granny_int32x minor = 0;
247 granny_int32x customization = 0;
248 granny_int32x build = 0;
249
250 gr2lib.core.coreapi.VersionSupport.GrannyGetVersion(
251 ref major,
252 ref minor,
253 ref customization,
254 ref build);
255
256 this._apiversion = new versiontype(major, minor, customization, build);
257
258 }
259 private string GrannyGetVersionString()
260 {
261 return gr2lib.core.coreapi.VersionSupport.GrannyGetVersionString();
262 }
263 #endregion
264
265 #region IGranny2APIVersion Members
266 private bool _apiversionsmatch = false;
267 /// <summary>
268 /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against
269 /// </summary>
270 public bool apiversionsmatch { get { return _apiversionsmatch; } }
271 private versiontype _apiversion;
272 /// <summary>
273 /// Gets the Loaded Granny2 API Version
274 /// </summary>
275 public versiontype apiversion { get { return _apiversion; } }
276 private versiontype _expectedapiversion;
277 /// <summary>
278 /// Gets the Expected Granny2 API Version
279 /// </summary>
280 public versiontype expectedapiversion { get { return _expectedapiversion; } }
281 #endregion
282 }
283 #endregion
284 }

  ViewVC Help
Powered by ViewVC 1.1.22