version  0.0.1
Defines the C++ API for MsPASS
TimeWindow.h
1 #ifndef _TIMEWINDOW_H_
2 #define _TIMEWINDOW_H_
3 namespace mspass::algorithms
4 {
14 {
15 public:
19  double start;
23  double end;
27  TimeWindow(){start=0.0;end=1.0e99;};
33  TimeWindow(const double ts,const double te){start=ts;end=te;};
34  TimeWindow(const TimeWindow& parent)
35  {
36  start=parent.start;
37  end=parent.end;
38  }
39  TimeWindow& operator=(const TimeWindow& parent)
40  {
41  if(&parent!=this)
42  {
43  start=parent.start;
44  end=parent.end;
45  }
46  return *this;
47  }
51  TimeWindow shift(const double tshift) const
52  {
53  TimeWindow newwindow(*this);
54  newwindow.start+=tshift;
55  newwindow.end += tshift;
56  return(newwindow);
57  }
61  double length()
62  {
63  return(end-start);
64  };
65 };
66 
67 /* This strange looking function is a C++ function object.
68 // It is used in the STL container called a set used for gaps below.
69 // This function is used as the comparison function for ordering
70 // the elements of the set. It makes TimeWindows indexed by
71 // intervals similar to thw way Datascope uses time:endtime
72 // Be aware, however, that for the same reason as datascope overlapping
73 // time windows will cause ambiguity in indexing times by this
74 // method.
75 */
85 {
86 public:
87  bool operator()(const TimeWindow ti1,const TimeWindow ti2) const
88  {return(ti1.end<ti2.start);};
89 };
90 } // end mspass::seismic namespace declaration
91 #endif
Function object used for weak comparison to order TimeWindow objects.
Definition: TimeWindow.h:85
Defines a time window.
Definition: TimeWindow.h:14
double start
Definition: TimeWindow.h:19
TimeWindow()
Definition: TimeWindow.h:27
double length()
Definition: TimeWindow.h:61
double end
Definition: TimeWindow.h:23
TimeWindow shift(const double tshift) const
Definition: TimeWindow.h:51
TimeWindow(const double ts, const double te)
Definition: TimeWindow.h:33