MsPASS C++ API  2.4.1.dev4+g92330b7a
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
TimeWindow.h
1#ifndef _TIMEWINDOW_H_
2#define _TIMEWINDOW_H_
3namespace mspass::algorithms {
13public:
17 double start;
21 double end;
26 start = 0.0;
27 end = 1.0e99;
28 };
34 TimeWindow(const double ts, const double te) {
35 start = ts;
36 end = te;
37 };
41 TimeWindow(const TimeWindow &parent) {
42 start = parent.start;
43 end = parent.end;
44 }
50 if (&parent != this) {
51 start = parent.start;
52 end = parent.end;
53 }
54 return *this;
55 }
59 TimeWindow shift(const double tshift) const {
60 TimeWindow newwindow(*this);
61 newwindow.start += tshift;
62 newwindow.end += tshift;
63 return (newwindow);
64 }
68 double length() { return (end - start); };
69};
70
71/* This strange looking function is a C++ function object.
72// It is used in the STL container called a set used for gaps below.
73// This function is used as the comparison function for ordering
74// the elements of the set. It makes TimeWindows indexed by
75// intervals similar to thw way Datascope uses time:endtime
76// Be aware, however, that for the same reason as datascope overlapping
77// time windows will cause ambiguity in indexing times by this
78// method.
79*/
89public:
95 bool operator()(const TimeWindow ti1, const TimeWindow ti2) const {
96 return (ti1.end < ti2.start);
97 };
98};
99} // namespace mspass::algorithms
100#endif
Function object used for weak comparison to order TimeWindow objects.
Definition TimeWindow.h:88
bool operator()(const TimeWindow ti1, const TimeWindow ti2) const
Definition TimeWindow.h:95
Defines a time window.
Definition TimeWindow.h:12
double start
Definition TimeWindow.h:17
TimeWindow()
Definition TimeWindow.h:25
TimeWindow & operator=(const TimeWindow &parent)
Definition TimeWindow.h:49
double length()
Definition TimeWindow.h:68
double end
Definition TimeWindow.h:21
TimeWindow shift(const double tshift) const
Definition TimeWindow.h:59
TimeWindow(const double ts, const double te)
Definition TimeWindow.h:34
TimeWindow(const TimeWindow &parent)
Definition TimeWindow.h:41