GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCaldb.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCaldb.hpp - Calibration database class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2016 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 GCaldb.hpp
23  * @brief Calibration database class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCALDB_HPP
28 #define GCALDB_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GFits.hpp"
34 #include "GFitsTable.hpp"
35 #include "GFilename.hpp"
36 
37 
38 /***********************************************************************//**
39  * @class GCaldb
40  *
41  * @brief Calibration database class
42  *
43  * This class holds the definition of a calibration database. The
44  * calibration database is located in a root directory that can be set using
45  * the GCaldb::rootdir method. If no root directory is set, GCaldb will take
46  * the directory path from the CALDB environment variable, which is mandatory
47  * in case that no root directory has been set.
48  *
49  * It is assumed that the calibration data are found under
50  *
51  * $CALDB/data/<mission>[/<instrument>]
52  *
53  * and that the Calibration Index File (CIF) is located at
54  *
55  * $CALDB/data/<mission>[/<instrument>]/caldb.indx
56  *
57  * where <mission> is the name of the mission and <instrument> is the
58  * optional instrument name (all lower case). If the root directory has been
59  * set using the GCaldb::rootdir method, $CALDB is replaced by the root
60  * directory name.
61  *
62  * The calibration database for a given mission and instrument is opened
63  * using the open() method. Once opened, database information can be
64  * accessed. After usage, the database is closed using the close() method.
65  ***************************************************************************/
66 class GCaldb : public GBase {
67 
68 public:
69  // Constructors and destructors
70  GCaldb(void);
71  GCaldb(const GCaldb& caldb);
72  explicit GCaldb(const std::string& pathname);
73  GCaldb(const std::string& mission, const std::string& instrument);
74  virtual ~GCaldb(void);
75 
76  // Operators
77  GCaldb& operator=(const GCaldb& caldb);
78 
79  // Methods
80  void clear(void);
81  GCaldb* clone(void) const;
82  std::string classname(void) const;
83  int size(void) const;
84  std::string rootdir(void) const;
85  void rootdir(const std::string& pathname);
86  std::string path(const std::string& mission,
87  const std::string& instrument = "");
88  std::string cifname(const std::string& mission,
89  const std::string& instrument = "");
90  void open(const std::string& mission,
91  const std::string& instrument = "");
92  void close(void);
93  GFilename filename(const std::string& detector,
94  const std::string& filter,
95  const std::string& codename,
96  const std::string& date,
97  const std::string& time,
98  const std::string& expr);
99  const std::string& mission(void) const;
100  const std::string& instrument(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 GCaldb& caldb);
107  void free_members(void);
108 
109  // Protected data area
110  std::string m_opt_rootdir; //!< Optional root directory
111  std::string m_mission; //!< Mission of opened database
112  std::string m_instrument; //!< Instrument of opened database
113  std::string m_cifname; //!< CIF filename of opened database
114  GFits m_fits; //!< CIF FITS file
115  GFitsTable* m_cif; //!< Pointer to CIF table
116 };
117 
118 
119 /***********************************************************************//**
120  * @brief Return class name
121  *
122  * @return String containing the class name ("GCaldb").
123  ***************************************************************************/
124 inline
125 std::string GCaldb::classname(void) const
126 {
127  return ("GCaldb");
128 }
129 
130 
131 /***********************************************************************//**
132  * @brief Return mission
133  *
134  * @return String containing the mission.
135  ***************************************************************************/
136 inline
137 const std::string& GCaldb::mission(void) const
138 {
139  return (m_mission);
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Return instrument
145  *
146  * @return String containing the instrument.
147  ***************************************************************************/
148 inline
149 const std::string& GCaldb::instrument(void) const
150 {
151  return (m_instrument);
152 }
153 
154 #endif /* GCALDB_HPP */
GCaldb & operator=(const GCaldb &caldb)
Assignment operator.
Definition: GCaldb.cpp:164
int size(void) const
Returns number of entries in calibration database.
Definition: GCaldb.cpp:227
std::string path(const std::string &mission, const std::string &instrument="")
Return path to calibration directory.
Definition: GCaldb.cpp:356
std::string m_mission
Mission of opened database.
Definition: GCaldb.hpp:111
void free_members(void)
Delete class members.
Definition: GCaldb.cpp:751
const std::string & mission(void) const
Return mission.
Definition: GCaldb.hpp:137
GCaldb * clone(void) const
Clone calibration database.
Definition: GCaldb.cpp:212
GFilename filename(const std::string &detector, const std::string &filter, const std::string &codename, const std::string &date, const std::string &time, const std::string &expr)
Return calibration file name based on selection parameters.
Definition: GCaldb.cpp:524
Definition of interface for all GammaLib classes.
GFits m_fits
CIF FITS file.
Definition: GCaldb.hpp:114
FITS file class.
Definition: GFits.hpp:63
void init_members(void)
Initialise class members.
Definition: GCaldb.cpp:705
FITS file class interface definition.
virtual ~GCaldb(void)
Destructor.
Definition: GCaldb.cpp:143
void copy_members(const GCaldb &caldb)
Copy class members.
Definition: GCaldb.cpp:725
std::string m_instrument
Instrument of opened database.
Definition: GCaldb.hpp:112
void close(void)
Close calibration database.
Definition: GCaldb.cpp:487
void open(const std::string &mission, const std::string &instrument="")
Open calibration database.
Definition: GCaldb.cpp:458
const std::string & instrument(void) const
Return instrument.
Definition: GCaldb.hpp:149
std::string m_cifname
CIF filename of opened database.
Definition: GCaldb.hpp:113
Calibration database class.
Definition: GCaldb.hpp:66
GCaldb(void)
Void constructor.
Definition: GCaldb.cpp:62
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
std::string classname(void) const
Return class name.
Definition: GCaldb.hpp:125
GChatter
Definition: GTypemaps.hpp:33
std::string m_opt_rootdir
Optional root directory.
Definition: GCaldb.hpp:110
GFitsTable * m_cif
Pointer to CIF table.
Definition: GCaldb.hpp:115
std::string cifname(const std::string &mission, const std::string &instrument="")
Return absolute CIF filename.
Definition: GCaldb.cpp:430
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
Definition: GCaldb.cpp:657
void clear(void)
Clear calibration database.
Definition: GCaldb.cpp:194
std::string rootdir(void) const
Return path to CALDB root directory.
Definition: GCaldb.cpp:257
Filename class interface definition.
FITS table abstract base class interface definition.