GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GTimeReference.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GTimeReference.hpp - Time reference class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2018 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GTimeReference.hpp
23  * @brief Time reference class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GTIMEREFERENCE_HPP
28 #define GTIMEREFERENCE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 
34 /* __ Forward declarations _______________________________________________ */
35 class GXmlElement;
36 class GFitsHDU;
37 
38 
39 /***********************************************************************//**
40  * @class GTimeReference
41  *
42  * @brief Implements a time reference
43  *
44  * This class implements the reference of a time with respect to Modified
45  * Julian Days. The zero point of the time is specified by the member
46  * m_mjdref that is given in Modified Julian Days. A time may be either
47  * either given in seconds or in days. Furthermore, the time system needs to
48  * be specified. So far, only Terrestrial Time (TT) is supported. Also the
49  * reference of the time system needs to be given. So far, only Local is
50  * supported.
51  *
52  * References:
53  * http://aa.usno.navy.mil/publications/docs/Circular_179.php
54  * http://hpiers.obspm.fr/eop-pc/index.php?index=TAI-UTC_tab&lang=en
55  ***************************************************************************/
56 class GTimeReference : public GBase {
57 
58 public:
59  // Constructors and destructors
60  GTimeReference(void);
61  GTimeReference(const GTimeReference& ref);
62  explicit GTimeReference(const double& mjdref,
63  const std::string& timeunit,
64  const std::string& timesys = "TT",
65  const std::string& timeref = "LOCAL");
66  explicit GTimeReference(const int& mjdrefi,
67  const double& mrdreff,
68  const std::string& timeunit,
69  const std::string& timesys = "TT",
70  const std::string& timeref = "LOCAL");
71  explicit GTimeReference(const GFitsHDU& hdu);
72  virtual ~GTimeReference(void);
73 
74  // Operators
76 
77  // Methods
78  void clear(void);
79  GTimeReference* clone(void) const;
80  std::string classname(void) const;
81  void read(const GFitsHDU& hdu);
82  void write(GFitsHDU& hdu) const;
83  void read(const GXmlElement& xml);
84  void write(GXmlElement& xml) const;
85  void set(const double& mrdref,
86  const std::string& timeunit,
87  const std::string& timesys = "TT",
88  const std::string& timeref = "LOCAL");
89  void set(const int& mjdrefi,
90  const double& mjdreff,
91  const std::string& timeunit,
92  const std::string& timesys = "TT",
93  const std::string& timeref = "LOCAL");
94  const double& mjdref(void) const;
95  int mjdrefi(void) const;
96  double mjdreff(void) const;
97  const std::string& timeunit(void) const;
98  const std::string& timesys(void) const;
99  const std::string& timeref(void) const;
100  double unitseconds(void) const;
101  std::string print(const GChatter& chatter = NORMAL) const;
102 
103 protected:
104  // Protected methods
105  void init_members(void);
106  void copy_members(const GTimeReference& ref);
107  void free_members(void);
108 
109  // Protected data members
110  double m_mjdref; //!< Time MJD reference (days)
111  std::string m_timeunit; //!< Time unit
112  std::string m_timesys; //!< Time system
113  std::string m_timeref; //!< Time reference
114  bool m_unit_sec; //!< True: unit is seconds, False: unit is days
115 };
116 
117 
118 /***********************************************************************//**
119  * @brief Return class name
120  *
121  * @return String containing the class name ("GTimeReference").
122  ***************************************************************************/
123 inline
124 std::string GTimeReference::classname(void) const
125 {
126  return ("GTimeReference");
127 }
128 
129 #endif /* GTIMEREFERENCE_HPP */
void clear(void)
Clear time reference.
std::string m_timeunit
Time unit.
GTimeReference(void)
Void constructor.
double mjdreff(void) const
Returns fractional part of MJD reference (units: days)
const std::string & timeunit(void) const
Return time unit.
void write(GFitsHDU &hdu) const
Write time reference into FITS header.
int mjdrefi(void) const
Returns integer part of MJD reference (units: days)
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
double m_mjdref
Time MJD reference (days)
void read(const GFitsHDU &hdu)
Read time reference from FITS header.
void free_members(void)
Delete class members.
Definition of interface for all GammaLib classes.
XML element node class.
Definition: GXmlElement.hpp:48
double unitseconds(void) const
Return the time unit in seconds.
GTimeReference & operator=(const GTimeReference &ref)
Assignment operator.
const double & mjdref(void) const
Return MJD reference (units: days)
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
std::string classname(void) const
Return class name.
const std::string & timesys(void) const
Return time system.
void copy_members(const GTimeReference &ref)
Copy class members.
GChatter
Definition: GTypemaps.hpp:33
virtual ~GTimeReference(void)
Destructor.
const std::string & timeref(void) const
Return time reference.
std::string print(const GChatter &chatter=NORMAL) const
Print time reference.
void set(const double &mrdref, const std::string &timeunit, const std::string &timesys="TT", const std::string &timeref="LOCAL")
Set time reference.
GTimeReference * clone(void) const
Clone object.
Implements a time reference.
std::string m_timeref
Time reference.
std::string m_timesys
Time system.
void init_members(void)
Initialise class members.
bool m_unit_sec
True: unit is seconds, False: unit is days.