00001 #pragma ident "$Id: Epoch.hpp 1163 2008-03-28 13:01:33Z snelsen $"
00002
00003
00004
00010 #ifndef GPSTK_EPOCH_HPP
00011 #define GPSTK_EPOCH_HPP
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include "MathBase.hpp"
00050 #include "Exception.hpp"
00051 #include "StringUtils.hpp"
00052
00053 #include "GPSZcount.hpp"
00054 #include "CommonTime.hpp"
00055 #include "TimeTag.hpp"
00056 #include "SystemTime.hpp"
00057 #include "YDSTime.hpp"
00058
00059 namespace gpstk
00060 {
00063
00119 class Epoch
00120 {
00121 public:
00128 NEW_EXCEPTION_CLASS(EpochException, gpstk::Exception);
00129
00134 NEW_EXCEPTION_CLASS(FormatException, gpstk::Exception);
00135
00143
00144 static const double ONE_NSEC_TOLERANCE;
00146 static const double ONE_USEC_TOLERANCE;
00148 static const double ONE_MSEC_TOLERANCE;
00150 static const double ONE_SEC_TOLERANCE;
00152 static const double ONE_MIN_TOLERANCE;
00154 static const double ONE_HOUR_TOLERANCE;
00155
00157 static double EPOCH_TOLERANCE;
00158
00160 static const Epoch BEGINNING_OF_TIME;
00162 static const Epoch END_OF_TIME;
00163
00165 static std::string PRINT_FORMAT;
00167
00169
00170
00171 static double setEpochTolerance(double tol)
00172 throw()
00173 { return EPOCH_TOLERANCE = tol; }
00174
00176 static double getEpochTolerance()
00177 throw()
00178 { return EPOCH_TOLERANCE; }
00179
00187 Epoch& setTolerance(double tol)
00188 throw();
00189
00194 double getTolerance() throw()
00195 { return tolerance; }
00197
00199
00200
00211 Epoch(const TimeTag& tt = SystemTime())
00212 throw(EpochException);
00213
00218 Epoch(const CommonTime& ct)
00219 throw();
00220
00230 Epoch(const TimeTag& tt,
00231 short year)
00232 throw(EpochException);
00233
00237 Epoch(const GPSZcount& gzc)
00238 throw();
00239
00240
00241
00242
00243
00245 ~Epoch()
00246 throw()
00247 {}
00249
00251
00252
00253 Epoch(const Epoch &right)
00254 throw();
00255
00257 Epoch& operator=(const Epoch& right)
00258 throw();
00260
00262
00263
00268 double operator-(const Epoch& right) const
00269 throw();
00270
00276 Epoch operator+(double sec) const
00277 throw(EpochException);
00278
00284 Epoch operator-(double sec) const
00285 throw(EpochException);
00286
00292 Epoch& operator+=(double sec)
00293 throw(EpochException);
00294
00300 Epoch& operator-=(double sec)
00301 throw(EpochException);
00302
00308 Epoch& addSeconds(double seconds)
00309 throw(EpochException);
00310
00316 Epoch& addSeconds(long seconds)
00317 throw(EpochException);
00318
00324 Epoch& addMilliSeconds(long msec)
00325 throw(EpochException);
00326
00332 Epoch& addMicroSeconds(long usec)
00333 throw(EpochException);
00335
00337
00338 bool operator==(const Epoch &right) const
00339 throw();
00340 bool operator!=(const Epoch &right) const
00341 throw();
00342 bool operator<(const Epoch &right) const
00343 throw();
00344 bool operator>(const Epoch &right) const
00345 throw();
00346 bool operator<=(const Epoch &right) const
00347 throw();
00348 bool operator>=(const Epoch &right) const
00349 throw();
00351
00353
00354
00355
00356
00357 template <class TimeTagType>
00358 TimeTagType get() const
00359 throw(EpochException);
00360
00364 inline long double JD() const
00365 throw(EpochException);
00366
00370 inline long double MJD() const
00371 throw(EpochException);
00372
00374 inline short year() const
00375 throw(EpochException);
00376
00378 inline short month() const
00379 throw(EpochException);
00380
00382 inline short day() const
00383 throw(EpochException);
00384
00386 inline short dow() const
00387 throw(EpochException);
00388
00390 inline short hour() const
00391 throw(EpochException);
00392
00394 inline short minute() const
00395 throw(EpochException);
00396
00398 inline double second() const
00399 throw(EpochException);
00400
00402 inline double sod() const
00403 throw(EpochException);
00404
00406 inline short GPSweek10() const
00407 throw(EpochException);
00408
00410 inline long GPSzcount() const
00411 throw(EpochException);
00412
00414 inline long GPSzcountFloor() const
00415 throw(EpochException);
00416
00422 inline unsigned long GPSzcount32() const
00423 throw(EpochException);
00424
00426 inline unsigned long GPSzcount32Floor() const
00427 throw(EpochException);
00428
00430 inline double GPSsow() const
00431 throw(EpochException);
00432
00434 inline short GPSweek() const
00435 throw(EpochException);
00436
00438 inline short doy() const
00439 throw(EpochException);
00440
00444 inline long double getMJDasLongDouble() const
00445 throw(EpochException);
00446
00448 inline struct timeval unixTime() const
00449 throw(EpochException);
00450
00452 operator GPSZcount() const
00453 throw(EpochException);
00454
00456 operator CommonTime() const
00457 throw();
00458
00462
00468 Epoch& set(const TimeTag& tt = SystemTime())
00469 throw(EpochException);
00470
00476 Epoch& set(const TimeTag& tt,
00477 short year)
00478 throw(EpochException);
00479
00485 Epoch& set(const CommonTime& c)
00486 throw();
00487
00491 Epoch& set(const GPSZcount& z)
00492 throw(EpochException);
00493
00500 Epoch& setTime(const CommonTime& ct)
00501 throw(EpochException);
00502
00509 Epoch& setDate(const CommonTime& ct)
00510 throw(EpochException);
00511
00516 Epoch& setLocalTime()
00517 throw(EpochException);
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00536
00538
00539
00540
00541
00591 Epoch& scanf(const std::string& str,
00592 const std::string& fmt)
00593 throw(StringUtils::StringException);
00594
00595
00596
00597
00643 std::string printf(const std::string& fmt = PRINT_FORMAT) const
00644 throw(StringUtils::StringException);
00646
00647 private:
00649
00650
00651
00652 CommonTime core;
00653
00655 double tolerance;
00656
00659 short whichGPSEpoch(int week, int year) const
00660 throw(EpochException);
00662 };
00663
00665
00666
00672 std::ostream& operator<<( std::ostream& s,
00673 const Epoch& t );
00675
00676
00677 }
00678
00679 #endif