Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDetectorHeader.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JDETECTORHEADER__
2 #define __JDETECTOR__JDETECTORHEADER__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JUTC/JUTCTimeRange.hh"
8 #include "JUTM/JUTMGrid.hh"
9 #include "JUTM/JUTMPosition.hh"
10 #include "JIO/JSerialisable.hh"
12 #include "Jeep/JProperties.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JDETECTOR {}
20 namespace JPP { using namespace JDETECTOR; }
21 
22 namespace JDETECTOR {
23 
24  using JUTC::JUTCTimeRange;
25  using JUTM::JUTMGrid;
26  using JUTM::JUTMPosition;
27  using JIO::JReader;
28  using JIO::JWriter;
30 
31 
32  /**
33  * Data structure for detector header.
34  */
36  public JUTCTimeRange,
37  public JUTMGrid,
38  public JUTMPosition
39  {
40  public:
41  /**
42  * Default constructor.
43  */
45  JUTCTimeRange(),
46  JUTMGrid (),
47  JUTMPosition ()
48  {}
49 
50 
51  /**
52  * Constructor.
53  *
54  * \param range UTC time range
55  * \param grid UTM grid
56  * \param pos UTM position
57  */
59  const JUTMGrid& grid,
60  const JUTMPosition& pos) :
61  JUTCTimeRange(range),
62  JUTMGrid (grid),
63  JUTMPosition (pos)
64  {}
65 
66 
67  /**
68  * Read detector header from input.
69  *
70  * \param in input stream
71  * \param header header
72  * \return input stream
73  */
74  friend inline std::istream& operator>>(std::istream& in, JDetectorHeader& header)
75  {
76  in >> static_cast<JUTCTimeRange&>(header);
77  in >> static_cast<JUTMGrid&> (header);
78  in >> static_cast<JUTMPosition&> (header);
79 
80  return in;
81  }
82 
83 
84  /**
85  * Write detector header to output.
86  *
87  * \param out output stream
88  * \param header header
89  * \return output stream
90  */
91  friend inline std::ostream& operator<<(std::ostream& out, const JDetectorHeader& header)
92  {
93  using namespace std;
94 
95  out << static_cast<const JUTCTimeRange&>(header);
96  out << endl;
97  out << static_cast<const JUTMGrid&> (header);
98  out << ' ';
99  out << static_cast<const JUTMPosition&> (header);
100 
101  return out;
102  }
103 
104 
105  /**
106  * Read detector header from input.
107  *
108  * \param in input stream
109  * \param header header
110  * \return input stream
111  */
112  friend inline JReader& operator>>(JReader& in, JDetectorHeader& header)
113  {
114  in >> static_cast<JUTCTimeRange&>(header);
115  in >> static_cast<JUTMGrid&> (header);
116  in >> static_cast<JUTMPosition&> (header);
117 
118  return in;
119  }
120 
121 
122  /**
123  * Write detector header to output.
124  *
125  * \param out output stream
126  * \param header header
127  * \return output stream
128  */
129  friend inline JWriter& operator<<(JWriter& out, const JDetectorHeader& header)
130  {
131  out << static_cast<const JUTCTimeRange&>(header);
132  out << static_cast<const JUTMGrid&> (header);
133  out << static_cast<const JUTMPosition&> (header);
134 
135  return out;
136  }
137 
138 
139  /**
140  * Get equation parameters.
141  *
142  * \return equation parameters
143  */
145  {
146  static JEquationParameters equation;
147 
148  return equation;
149  }
150 
151 
152 
153  /**
154  * Set equation parameters.
155  *
156  * \param equation equation parameters
157  */
158  static inline void setEquationParameters(const JEquationParameters& equation)
159  {
160  getEquationParameters() = equation;
161  }
162 
163 
164  /**
165  * Get properties of this class.
166  *
167  * \param equation equation parameters
168  */
170  {
171  return JDetectorHeaderHelper(*this, equation);
172  }
173 
174 
175  /**
176  * Get properties of this class.
177  *
178  * \param equation equation parameters
179  */
181  {
182  return JDetectorHeaderHelper(*this, equation);
183  }
184 
185 
186  private:
187  /**
188  * Auxiliary class for I/O of detector header.
189  */
191  public JProperties
192  {
193  public:
194  /**
195  * Constructor.
196  *
197  * \param object header
198  * \param equation equation parameters
199  */
200  template<class JDetectorHeader_t>
201  JDetectorHeaderHelper(JDetectorHeader_t& object,
202  const JEquationParameters& equation) :
203  JProperties(equation, 1)
204  {
205  insert(gmake_property(object.first));
206  insert(gmake_property(object.second));
207  insert(gmake_property(object.east));
208  insert(gmake_property(object.north));
209  insert(gmake_property(object.z));
210  insert(gmake_property(object.key));
211  insert(gmake_property(object.wgs));
212  insert(gmake_property(object.zone));
213  }
214  };
215  };
216 
217 
218  /**
219  * Get detector header for ARCA.
220  *
221  * \return detector header
222  */
224  {
225  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9),
226  JUTMGrid ("UTM", "WGS84", "33N"),
227  JUTMPosition (587600, 4016800, -3450));
228  }
229 
230  /**
231  * Get detector header for ORCA.
232  *
233  * \return detector header
234  */
236  {
237  return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9),
238  JUTMGrid ("UTM", "WGS84", "32N"),
239  JUTMPosition (256500, 4743000, -2425));
240  }
241 }
242 
243 #endif
JDetectorHeader getORCADetectorHeader()
Get detector header for ORCA.
Interface for binary output.
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
JDetectorHeader()
Default constructor.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
Utility class to parse parameter values.
Definition: JProperties.hh:496
JDetectorHeader(const JUTCTimeRange &range, const JUTMGrid &grid, const JUTMPosition &pos)
Constructor.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
friend std::ostream & operator<<(std::ostream &out, const JDetectorHeader &header)
Write detector header to output.
Data structure for UTM position.
Definition: JUTMPosition.hh:34
Data structure for detector header.
Utility class to parse parameter values.
JUTCTimeRange()
Default constructor.
static JEquationParameters & getEquationParameters()
Get equation parameters.
std::string key
Definition: JUTMGrid.hh:183
std::string zone
Definition: JUTMGrid.hh:185
JDetectorHeaderHelper(JDetectorHeader_t &object, const JEquationParameters &equation)
Constructor.
std::string wgs
Definition: JUTMGrid.hh:184
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters()) const
Get properties of this class.
Interface for binary input.
Data structure for UTM grid.
Definition: JUTMGrid.hh:34
JProperties getProperties(const JEquationParameters &equation=JDetectorHeader::getEquationParameters())
Get properties of this class.
UTC time range [s].
Auxiliary class for I/O of detector header.
friend std::istream & operator>>(std::istream &in, JDetectorHeader &header)
Read detector header from input.
JDetectorHeader getARCADetectorHeader()
Get detector header for ARCA.
friend JReader & operator>>(JReader &in, JDetectorHeader &header)
Read detector header from input.
friend JWriter & operator<<(JWriter &out, const JDetectorHeader &header)
Write detector header to output.