General Purpose Geodetic Library
SgVersion.h
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef SG_VERSION_H
24 #define SG_VERSION_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 #include <iostream>
33 
34 #include <QtCore/QString>
35 
36 class QDataStream;
37 
38 #include <SgMJD.h>
39 
40 
41 
42 class SgVersion;
44 extern SgVersion *driverVersion;
45 
46 /***===================================================================================================*/
52 class SgVersion
53 {
54 public:
56  {
57  NF_Human = 0,
58  NF_Cylon = 1,
59  NF_Petrov = 2,
60  };
61  //
62  // constructors/destructors:
63  //
66  inline SgVersion();
67 
68  inline SgVersion(const QString&, int, int, int, const QString&, const SgMJD&);
69 
70  inline SgVersion(const SgVersion&);
71 
75  inline ~SgVersion();
76 
77 
78  //
79  // Interfaces:
80  //
81  // gets:
82  //
83  //
84  inline const QString& getSoftwareName() const;
85 
86  //
87  inline int getMajorNumber() const;
88 
89  //
90  inline int getMinorNumber() const;
91 
92  //
93  inline int getTeenyNumber() const;
94 
95  //
96  inline const QString& getCodeName() const;
97 
98  //
99  inline const SgMJD& getReleaseEpoch() const;
100 
101 
102  // sets:
103  //
104  inline void setSoftwareName(const QString&);
105 
106  //
107  inline void setMajorNumber(int);
108 
109  //
110  inline void setMinorNumber(int);
111 
112  //
113  inline void setTeenyNumber(int);
114 
115  //
116  inline void setCodeName(const QString&);
117 
118  //
119  inline void setReleaseEpoch(const SgMJD&);
120 
121  //
122  // Functions:
123  //
124  //
125  inline QString className() const {return "SgVersion";};
126 
127  //
128  inline QString toString() const;
129 
130 
131  bool parseString(const QString& str);
132 
133  //
134  QString name(NameFormat fmt=NF_Human) const;
135 
139  inline SgVersion& operator=(const SgVersion& ver);
140 
141  //
142  inline bool operator==(const SgVersion&) const;
143 
144  //
145  inline bool operator!=(const SgVersion&) const;
146 
147  //
148  inline bool operator<(const SgVersion&) const;
149 
150  //
151  inline bool operator<=(const SgVersion&) const;
152 
153  //
154  inline bool operator>(const SgVersion&) const;
155 
156  //
157  inline bool operator>=(const SgVersion&) const;
158 
159 
160  //
161  // Friends:
162  //
163 
164 
165  //
166  // I/O:
167  //
169 
171  //
172 
173 protected:
174  QString softwareName_;
178  QString codeName_;
180 };
181 /*=====================================================================================================*/
182 
183 
184 
185 
186 
187 
188 
189 
190 /*=====================================================================================================*/
191 /* */
192 /* SgVersion inline members: */
193 /* */
194 /*=====================================================================================================*/
195 //
196 //
197 // CONSTRUCTORS:
198 //
199 // An empty constructor:
201  softwareName_(""),
202  codeName_(""),
203  releaseEpoch_(tZero)
204 {
205  majorNumber_ = 0;
206  minorNumber_ = 0;
207  teenyNumber_ = 0;
208 };
209 
210 
211 
212 //
213 inline SgVersion::SgVersion(const QString& softwareName, int major, int minor, int teeny,
214  const QString& codeName, const SgMJD& epoch) :
215  softwareName_(softwareName),
216  codeName_(codeName),
217  releaseEpoch_(epoch)
218 {
219  majorNumber_ = major;
220  minorNumber_ = minor;
221  teenyNumber_ = teeny;
222 };
223 
224 
225 
226 //
227 inline SgVersion::SgVersion(const SgVersion& ver) :
228  softwareName_(ver.getSoftwareName()),
229  codeName_(ver.getCodeName()),
230  releaseEpoch_(ver.getReleaseEpoch())
231 {
235 };
236 
237 
238 
239 //
241 {
242 };
243 
244 
245 
246 // A destructor:
247 
248 
249 
250 //
251 // INTERFACES:
252 //
253 //
254 inline const QString& SgVersion::getSoftwareName() const
255 {
256  return softwareName_;
257 };
258 
259 
260 
261 //
262 inline int SgVersion::getMajorNumber() const
263 {
264  return majorNumber_;
265 };
266 
267 
268 
269 //
270 inline int SgVersion::getMinorNumber() const
271 {
272  return minorNumber_;
273 };
274 
275 
276 
277 //
278 inline int SgVersion::getTeenyNumber() const
279 {
280  return teenyNumber_;
281 };
282 
283 
284 
285 //
286 inline const QString& SgVersion::getCodeName() const
287 {
288  return codeName_;
289 };
290 
291 
292 
293 //
294 inline const SgMJD& SgVersion::getReleaseEpoch() const
295 {
296  return releaseEpoch_;
297 };
298 
299 
300 
301 // sets:
302 //
303 //
304 inline void SgVersion::setSoftwareName(const QString& name)
305 {
307 };
308 
309 
310 
311 //
312 inline void SgVersion::setMajorNumber(int v)
313 {
314  majorNumber_ = v;
315 };
316 
317 
318 
319 //
320 inline void SgVersion::setMinorNumber(int v)
321 {
322  minorNumber_ = v;
323 };
324 
325 
326 
327 //
328 inline void SgVersion::setTeenyNumber(int v)
329 {
330  teenyNumber_ = v;
331 };
332 
333 
334 
335 //
336 inline void SgVersion::setCodeName(const QString& str)
337 {
338  codeName_ = str;
339 };
340 
341 
342 
343 //
344 inline void SgVersion::setReleaseEpoch(const SgMJD& t)
345 {
346  releaseEpoch_ = t;
347 };
348 
349 
350 
351 //
352 // FUNCTIONS:
353 //
354 //
355 //
356 inline QString SgVersion::toString() const
357 {
358  return QString().sprintf("%1d.%d.%d", majorNumber_, minorNumber_, teenyNumber_);
359 };
360 
361 
362 
363 //
365 {
367  codeName_ = ver.getCodeName();
372  return *this;
373 };
374 
375 
376 
377 //
378 inline bool SgVersion::operator==(const SgVersion& v) const
379 {
380  return
383 };
384 
385 
386 
387 //
388 inline bool SgVersion::operator!=(const SgVersion& v) const
389 {
390  return !(*this==v);
391 };
392 
393 
394 
395 //
396 inline bool SgVersion::operator<(const SgVersion& v) const
397 {
398  return
399  1000* majorNumber_ + minorNumber_ + 0.0001* teenyNumber_ <
400  1000*v.majorNumber_ + v.minorNumber_ + 0.0001*v.teenyNumber_;
401 };
402 
403 
404 
405 //
406 inline bool SgVersion::operator<=(const SgVersion& v) const
407 {
408  return
409  1000* majorNumber_ + minorNumber_ + 0.0001* teenyNumber_ <=
410  1000*v.majorNumber_ + v.minorNumber_ + 0.0001*v.teenyNumber_;
411 };
412 
413 
414 
415 //
416 inline bool SgVersion::operator>(const SgVersion& v) const
417 {
418  return
419  1000* majorNumber_ + minorNumber_ + 0.0001* teenyNumber_ >
420  1000*v.majorNumber_ + v.minorNumber_ + 0.0001*v.teenyNumber_;
421 };
422 
423 
424 
425 //
426 inline bool SgVersion::operator>=(const SgVersion& v) const
427 {
428  return
429  1000* majorNumber_ + minorNumber_ + 0.0001* teenyNumber_ >=
430  1000*v.majorNumber_ + v.minorNumber_ + 0.0001*v.teenyNumber_;
431 };
432 
433 
434 
435 //
436 // FRIENDS:
437 //
438 //
439 //
440 
441 
442 
443 /*=====================================================================================================*/
444 
445 
446 
447 
448 
449 /*=====================================================================================================*/
450 //
451 // aux functions:
452 //
453 
454 
455 /*=====================================================================================================*/
456 #endif // SG_VERSION_H
457 
const SgMJD tZero(1957, 10, 4)
SgVersion libraryVersion
SgVersion * driverVersion
Definition: l2aVersion.cpp:31
Definition: SgMJD.h:59
@ NF_Human
Definition: SgVersion.h:57
@ NF_Cylon
Definition: SgVersion.h:58
@ NF_Petrov
Definition: SgVersion.h:59
bool operator==(const SgVersion &) const
Definition: SgVersion.h:378
void setTeenyNumber(int)
Definition: SgVersion.h:328
bool loadIntermediateResults(QDataStream &)
Definition: SgVersion.cpp:99
void setCodeName(const QString &)
Definition: SgVersion.h:336
bool saveIntermediateResults(QDataStream &) const
Definition: SgVersion.cpp:78
int getMinorNumber() const
Definition: SgVersion.h:270
const SgMJD & getReleaseEpoch() const
Definition: SgVersion.h:294
const QString & getSoftwareName() const
Definition: SgVersion.h:254
QString codeName_
Definition: SgVersion.h:178
void setReleaseEpoch(const SgMJD &)
Definition: SgVersion.h:344
SgMJD releaseEpoch_
Definition: SgVersion.h:179
int minorNumber_
Definition: SgVersion.h:176
QString className() const
Definition: SgVersion.h:125
QString name(NameFormat fmt=NF_Human) const
Definition: SgVersion.cpp:54
void setMinorNumber(int)
Definition: SgVersion.h:320
QString softwareName_
Definition: SgVersion.h:174
SgVersion & operator=(const SgVersion &ver)
Definition: SgVersion.h:364
int getTeenyNumber() const
Definition: SgVersion.h:278
void setMajorNumber(int)
Definition: SgVersion.h:312
const QString & getCodeName() const
Definition: SgVersion.h:286
void setSoftwareName(const QString &)
Definition: SgVersion.h:304
~SgVersion()
Definition: SgVersion.h:240
int teenyNumber_
Definition: SgVersion.h:177
bool operator<(const SgVersion &) const
Definition: SgVersion.h:396
bool operator>(const SgVersion &) const
Definition: SgVersion.h:416
int majorNumber_
Definition: SgVersion.h:175
bool operator>=(const SgVersion &) const
Definition: SgVersion.h:426
bool operator!=(const SgVersion &) const
Definition: SgVersion.h:388
QString toString() const
Definition: SgVersion.h:356
int getMajorNumber() const
Definition: SgVersion.h:262
bool parseString(const QString &str)
Definition: SgVersion.cpp:140
bool operator<=(const SgVersion &) const
Definition: SgVersion.h:406