version  0.0.1
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 };
38 TimeWindow(const TimeWindow &parent) {
39 start = parent.start;
40 end = parent.end;
41 }
42 TimeWindow &operator=(const TimeWindow &parent) {
43 if (&parent != this) {
44 start = parent.start;
45 end = parent.end;
46 }
47 return *this;
48 }
52 TimeWindow shift(const double tshift) const {
53 TimeWindow newwindow(*this);
54 newwindow.start += tshift;
55 newwindow.end += tshift;
56 return (newwindow);
57 }
61 double length() { return (end - start); };
62};
63
64/* This strange looking function is a C++ function object.
65// It is used in the STL container called a set used for gaps below.
66// This function is used as the comparison function for ordering
67// the elements of the set. It makes TimeWindows indexed by
68// intervals similar to thw way Datascope uses time:endtime
69// Be aware, however, that for the same reason as datascope overlapping
70// time windows will cause ambiguity in indexing times by this
71// method.
72*/
82public:
83 bool operator()(const TimeWindow ti1, const TimeWindow ti2) const {
84 return (ti1.end < ti2.start);
85 };
86};
87} // namespace mspass::algorithms
88#endif
Function object used for weak comparison to order TimeWindow objects.
Definition TimeWindow.h:81
Defines a time window.
Definition TimeWindow.h:12
double start
Definition TimeWindow.h:17
TimeWindow()
Definition TimeWindow.h:25
double length()
Definition TimeWindow.h:61
double end
Definition TimeWindow.h:21
TimeWindow shift(const double tshift) const
Definition TimeWindow.h:52
TimeWindow(const double ts, const double te)
Definition TimeWindow.h:34