22 #ifndef DBA_MSG_DEFS_H
23 #define DBA_MSG_DEFS_H
46 const char* encoding_name(Encoding enc);
47 Encoding parse_encoding(
const std::string& s);
52 static const int MISSING_INT = INT_MAX;
65 Level(
int ltype1=MISSING_INT,
int l1=MISSING_INT,
int ltype2=MISSING_INT,
int l2=MISSING_INT)
66 : ltype1(ltype1), l1(l1), ltype2(ltype2), l2(l2) {}
67 Level(
const char* ltype1,
const char* l1=NULL,
const char* ltype2=NULL,
const char* l2=NULL);
69 bool operator==(
const Level& l)
const
71 return ltype1 == l.
ltype1 && l1 == l.
l1
75 bool operator!=(
const Level& l)
const
77 return ltype1 != l.ltype1 || l1 != l.l1
78 || ltype2 != l.ltype2 || l2 != l.l2;
81 bool operator<(
const Level& l)
const {
return compare(l) < 0; }
82 bool operator>(
const Level& l)
const {
return compare(l) > 0; }
93 if ((res = ltype1 - l.
ltype1))
return res;
94 if ((res = l1 - l.
l1))
return res;
95 if ((res = ltype2 - l.
ltype2))
return res;
104 void format(std::ostream& out,
const char* undef=
"-")
const;
106 static inline Level cloud(
int ltype2=MISSING_INT,
int l2=MISSING_INT) {
return Level(256, MISSING_INT, ltype2, l2); }
107 static inline Level waves(
int ltype2=MISSING_INT,
int l2=MISSING_INT) {
return Level(264, MISSING_INT, ltype2, l2); }
108 static inline Level ana() {
return Level(); }
111 std::ostream& operator<<(std::ostream& out,
const Level& l);
122 Trange(
int pind=MISSING_INT,
int p1=MISSING_INT,
int p2=MISSING_INT)
123 : pind(pind), p1(p1), p2(p2) {}
124 Trange(
const char* pind,
const char* p1=NULL,
const char* p2=NULL);
126 bool operator==(
const Trange& tr)
const
128 return pind == tr.
pind && p1 == tr.
p1 && p2 == tr.
p2;
131 bool operator!=(
const Trange& tr)
const
133 return pind != tr.pind || p1 != tr.p1 || p2 != tr.p2;
136 bool operator<(
const Trange& t)
const {
return compare(t) < 0; }
137 bool operator>(
const Trange& t)
const {
return compare(t) > 0; }
148 if ((res = pind - t.
pind))
return res;
149 if ((res = p1 - t.
p1))
return res;
158 void format(std::ostream& out,
const char* undef=
"-")
const;
160 static inline Trange instant() {
return Trange(254, 0, 0); }
161 static inline Trange ana() {
return Trange(); }
164 std::ostream& operator<<(std::ostream& out,
const Trange& l);
176 Coord(
int lat,
int lon);
177 Coord(
double lat,
double lon);
182 bool operator<(
const Coord& o)
const {
return compare(o) < 0; }
183 bool operator>(
const Coord& o)
const {
return compare(o) > 0; }
185 bool operator==(
const Coord& c)
const
187 return lat == c.lat && lon == c.lon;
190 bool operator!=(
const Coord& c)
const
192 return lat != c.lat || lon != c.lon;
203 if (
int res = lat - o.
lat)
return res;
208 static int normalon(
int lon);
209 static double fnormalon(
double lon);
212 std::ostream& operator<<(std::ostream& out,
const Coord& c);
221 Date(
unsigned short year,
unsigned char month=1,
unsigned char day=1)
222 : year(year), month(month), day(day)
225 Date(
const Date& d) : year(d.year), month(d.month), day(d.day) {}
227 : year(val[0]), month(val[1]), day(val[2])
231 int compare(
const Date& o)
const
233 if (
int res = year - o.year)
return res;
234 if (
int res = month - o.month)
return res;
238 bool operator<(
const Date& dt)
const;
239 bool operator>(
const Date& dt)
const;
240 bool operator==(
const Date& dt)
const;
241 bool operator!=(
const Date& dt)
const;
244 std::ostream& operator<<(std::ostream& out,
const Date& dt);
249 unsigned char minute;
250 unsigned char second;
252 Time(
unsigned char hour=0,
unsigned char minute=0,
unsigned char second=0)
253 : hour(hour), minute(minute), second(second) {}
254 Time(
const Time& d) : hour(d.hour), minute(d.minute), second(d.second) {}
256 : hour(val[0]), minute(val[1]), second(val[2])
260 int compare(
const Time& o)
const
262 if (
int res = hour - o.hour)
return res;
263 if (
int res = minute - o.minute)
return res;
264 return second - o.second;
267 bool operator<(
const Time& dt)
const;
268 bool operator>(
const Time& dt)
const;
269 bool operator==(
const Time& dt)
const;
270 bool operator!=(
const Time& dt)
const;
273 std::ostream& operator<<(std::ostream& out,
const Time& t);
282 Datetime(
unsigned short year,
unsigned char month=1,
unsigned char day=1,
283 unsigned char hour=0,
unsigned char minute=0,
unsigned char second=0)
284 : date(year, month, day), time(hour, minute, second) {}
285 Datetime(
const int* val) : date(val), time(val+3) {}
287 int compare(
const Datetime& o)
const
289 if (
int res = date.compare(o.date))
return res;
290 return time.compare(o.time);
293 bool operator==(
const Datetime& dt)
const;
294 bool operator!=(
const Datetime& dt)
const;
295 bool operator<(
const Datetime& dt)
const;
296 bool operator>(
const Datetime& dt)
const;
299 std::ostream& operator<<(std::ostream& out,
const Datetime& dt);
int ltype1
Type of the first level.
Definition: defs.h:57
int ltype2
Type of the second level.
Definition: defs.h:61
int p1
Time range P1 indicator.
Definition: defs.h:118
int pind
Time range type indicator.
Definition: defs.h:116
int lat
Latitude multiplied by 100000 (5 significant digits preserved)
Definition: defs.h:170
int l2
L2 value of the level.
Definition: defs.h:63
int lon
Longitude normalised from -180.0 to 180.0 and multiplied by 100000 (5 significant digits preserved) ...
Definition: defs.h:173
int compare(const Level &l) const
Compare two Level strutures, for use in sorting.
Definition: defs.h:90
Coordinates.
Definition: defs.h:167
int compare(const Trange &t) const
Compare two Trange strutures, for use in sorting.
Definition: defs.h:145
Simple datetime structure.
Definition: defs.h:276
int compare(const Coord &o) const
Compare two Coords strutures, for use in sorting.
Definition: defs.h:201
int l1
L1 value of the level.
Definition: defs.h:59
int p2
Time range P2 indicator.
Definition: defs.h:120
std::string describe() const
Return a string description of this time range.
std::string describe() const
Return a string description of this level.