//# MVEpoch.h: a class for high precision time //# Copyright (C) 1996,1997,1998,1999,2000 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# //# $Id$ #ifndef CASA_MVEPOCH_H #define CASA_MVEPOCH_H //# Includes #include #include #include #include namespace casacore { //# NAMESPACE CASACORE - BEGIN //# Forward Declarations class Unit; // A class for high precision time // // // // //
  • MeasValue class // // // // MVEpoch from Measure, Value and Epoch // // // // MVEpoch is a class for high precision (10-16 s) epochs over a // period of 6*1010 a.
    // MVEpochs can be compared, a time interval can be added or subtracted, and // the time difference can be found. // The following constructors: //
      //
    • MVEpoch() default; assuming 0 //
    • MVEpoch(Double) with time given in days //
    • MVEpoch(Double, Double=0) with times given in days //
    • MVEpoch(Quantity, Quantity=0) with times given //
    • MVEpoch(Quantum >) with times given //
    • MVEpoch(Vector) with times in days //
    • MVEpoch(Vector) with times //
    //
    // // // See MEpoch // // // // To have high precision timing // // // //
  • A proper high precision time, including multiplication etc should // be considered. E.g. a multi-byte number with 6 bytes day // and 8 bytes fractional day. // class MVEpoch : public MeasValue { public: //# Friends //# Constructors // Default constructor, generates default 0 epoch MVEpoch(); // Copy constructor MVEpoch(const MVEpoch &other); // Constructor with time in days // MVEpoch(Double inday, Double infrac=0); MVEpoch(const Vector &inday); // // Constructor with Quantities // MVEpoch(const Quantity &in); MVEpoch(const Quantity &in1, const Quantity &in2); MVEpoch(const Quantum > &in); MVEpoch(const Vector &in); // //# Destructor ~MVEpoch(); //# Operators // Copy assignment MVEpoch &operator=(const MVEpoch &other); // Add times // MVEpoch &operator+=(const MVEpoch &other); MVEpoch operator+(const MVEpoch &other) const; // // Difference times // MVEpoch &operator-=(const MVEpoch &other); MVEpoch operator-(const MVEpoch &other) const; // // Comparisons // Bool operator==(const MVEpoch &other) const; Bool operator!=(const MVEpoch &other) const; Bool near(const MVEpoch &other, Double tol = 1e-13) const; Bool nearAbs(const MVEpoch &other, Double tol = 1e-13) const; // //# General Member Functions // Constants static const Double secInDay; static const Unit unitDay; // Tell me your type // static void assure(const MeasValue &in); // // Adjust the time to its constituent parts. The returned result is always 1.0 // virtual void adjust(); virtual void adjust(Double &res); // // Get value in days Double get() const; // Get value with units // Quantity getTime() const; Quantity getTime(const Unit &unit) const; // // Get value of integer days Double getDay() const; // Get fraction of days Double getDayFraction() const; // Print a value virtual void print(ostream &os) const; // Clone a value virtual MeasValue *clone() const; // Get the value in internal units virtual Vector getVector() const; // Set the value from internal units (set 0 for empty vector) virtual void putVector(const Vector &in); // Get the internal value as a Vector. Usable in // records. The getXRecordValue() gets additional information for records. // Note that the Vectors could be empty. // virtual Vector > getRecordValue() const; // // Set the internal value if correct values and dimensions virtual Bool putValue(const Vector > &in); private: //# Data members // Whole days // Note that if higher precision is needed, the splitting could be in // 0.001 days and fractions thereof Double wday; // Fraction of days Double frday; //# Member functions // Make days from quantity Double makeDay(const Quantity &in) const; // Add time from days void addTime(Double in); }; //# Global functions } //# NAMESPACE CASACORE - END #endif