Install SeisComP and scanloc ARM64 nightly packages
This commit is contained in:
@ -21,44 +21,80 @@
|
||||
#ifndef SC_CORE_TIMESPAN_H
|
||||
#define SC_CORE_TIMESPAN_H
|
||||
|
||||
#include<seiscomp/core.h>
|
||||
#include<seiscomp/core/datetime.h>
|
||||
#include <seiscomp/core.h>
|
||||
#include <seiscomp/core/datetime.h>
|
||||
#include <seiscomp/core/optional.h>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Core {
|
||||
|
||||
|
||||
class SC_SYSTEM_CORE_API TimeWindow {
|
||||
|
||||
// Xstruction
|
||||
// ----------------------------------------------------------------------
|
||||
// X'truction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
TimeWindow();
|
||||
TimeWindow() = default;
|
||||
TimeWindow(const Time &startTime, double length);
|
||||
TimeWindow(const Time &startTime, const TimeSpan length);
|
||||
TimeWindow(const Time &startTime, const Time &endTime);
|
||||
TimeWindow(const TimeWindow &tw);
|
||||
~TimeWindow() {}
|
||||
TimeWindow(const TimeWindow &other);
|
||||
|
||||
// Operators
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Assignment operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
TimeWindow &operator=(const TimeWindow&);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Comparison operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
bool operator==(const TimeWindow&) const;
|
||||
bool operator!=(const TimeWindow&) const;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Arithmetic operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
//! Returns the minimal timewindow including this and other
|
||||
TimeWindow operator|(const TimeWindow &other) const;
|
||||
//! Sets the minimal timewindow including this and other
|
||||
TimeWindow &operator|=(const TimeWindow &other);
|
||||
|
||||
//! Returns the intersection of this and other
|
||||
TimeWindow operator&(const TimeWindow &other) const;
|
||||
//! Sets the intersection of this and other
|
||||
TimeWindow &operator&=(const TimeWindow &other);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Cast operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
//! Returns if the time window has length larger than 0.
|
||||
operator bool() const;
|
||||
|
||||
//! Returns the minimal timewindow including this and other
|
||||
TimeWindow operator|(const TimeWindow &other) const;
|
||||
|
||||
// more operators :-)
|
||||
|
||||
// Interface
|
||||
// ----------------------------------------------------------------------
|
||||
// Public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
Time startTime() const;
|
||||
Time endTime() const;
|
||||
double length() const;
|
||||
TimeSpan length() const;
|
||||
|
||||
void set(const Time &t1, const Time &t2);
|
||||
void setStartTime(const Time &t);
|
||||
void setEndTime(const Time &t);
|
||||
//! set length in seconds, affects endTime
|
||||
void setLength(double length);
|
||||
void setLength(TimeSpan length);
|
||||
|
||||
//! does it contain time t?
|
||||
bool contains(const Time &t) const;
|
||||
@ -68,111 +104,102 @@ class SC_SYSTEM_CORE_API TimeWindow {
|
||||
|
||||
//! is equal to time window?
|
||||
//! +/- tolerance in seconds
|
||||
bool equals(const TimeWindow &tw, double tolerance=0.0) const;
|
||||
bool equals(const TimeWindow &tw, TimeSpan tolerance = TimeSpan(0, 0)) const;
|
||||
|
||||
//! does it overlap with time window tw?
|
||||
bool overlaps(const TimeWindow &tw) const;
|
||||
|
||||
//! compute overlap with time window tw
|
||||
TimeWindow overlap(const TimeWindow &tw) const;
|
||||
|
||||
//! test if this+other would form a contiguous time window
|
||||
bool contiguous(const TimeWindow&, double tolerance=0) const;
|
||||
bool contiguous(const TimeWindow &, TimeSpan tolerance = TimeSpan(0, 0)) const;
|
||||
|
||||
//! extend time window by appending the other (without check!)
|
||||
void extend(const TimeWindow&);
|
||||
//! Sets the intersection time window with this and other
|
||||
TimeWindow &overlap(const TimeWindow &other);
|
||||
|
||||
//! merges this and other to the minimal timewindow overlapping both
|
||||
TimeWindow merge(const TimeWindow&) const;
|
||||
//! Computes the intersection with time window other
|
||||
TimeWindow overlapped(const TimeWindow &other) const;
|
||||
|
||||
// Implementation
|
||||
//! Merges other into this to the minimal timewindow overlapping both.
|
||||
TimeWindow &merge(const TimeWindow &other);
|
||||
|
||||
//! Returns the minimal timewindow including this and other
|
||||
TimeWindow merged(const TimeWindow &other) const;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private members
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
Time _startTime, _endTime;
|
||||
Time _startTime;
|
||||
Time _endTime;
|
||||
};
|
||||
|
||||
|
||||
inline TimeWindow::TimeWindow()
|
||||
{
|
||||
set(Time(), Time());
|
||||
}
|
||||
|
||||
inline TimeWindow::TimeWindow(const Time &startTime, double length)
|
||||
{
|
||||
set(startTime, startTime + Time(length)); // FIXME
|
||||
}
|
||||
class SC_SYSTEM_CORE_API OpenTimeWindow {
|
||||
// ----------------------------------------------------------------------
|
||||
// X'truction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
OpenTimeWindow() = default;
|
||||
OpenTimeWindow(const OPT(Time) &startTime, const OPT(Time) &endTime);
|
||||
OpenTimeWindow(const OpenTimeWindow &other);
|
||||
|
||||
inline TimeWindow::TimeWindow(const Time &startTime, const Time &endTime)
|
||||
{
|
||||
set(startTime, endTime);
|
||||
}
|
||||
|
||||
inline TimeWindow::TimeWindow(const TimeWindow &tw)
|
||||
{
|
||||
set(tw._startTime, tw._endTime);
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// Assignment operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
OpenTimeWindow &operator=(const OpenTimeWindow&);
|
||||
|
||||
inline bool TimeWindow::operator==(const TimeWindow &tw) const
|
||||
{
|
||||
return _startTime == tw._startTime && _endTime == tw._endTime;
|
||||
}
|
||||
|
||||
inline bool TimeWindow::operator!=(const TimeWindow &tw) const
|
||||
{
|
||||
return _startTime != tw._startTime || _endTime != tw._endTime;
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// Comparison operators
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
bool operator==(const OpenTimeWindow&) const;
|
||||
bool operator!=(const OpenTimeWindow&) const;
|
||||
|
||||
inline TimeWindow::operator bool() const
|
||||
{
|
||||
return (bool)_startTime && (bool)_endTime;
|
||||
}
|
||||
|
||||
inline Time TimeWindow::startTime() const
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// Public interface
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
OPT(Time) startTime() const;
|
||||
OPT(Time) endTime() const;
|
||||
OPT(TimeSpan) length() const;
|
||||
|
||||
inline Time TimeWindow::endTime() const
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
void set(const OPT(Time) &t1, const OPT(Time) &t2);
|
||||
void setStartTime(const OPT(Time) &t);
|
||||
void setEndTime(const OPT(Time) &t);
|
||||
|
||||
inline double TimeWindow::length() const
|
||||
{
|
||||
return (double)(_endTime-_startTime);
|
||||
}
|
||||
//! does it contain time t?
|
||||
bool contains(const Time &t) const;
|
||||
|
||||
inline void TimeWindow::set(const Time &startTime, const Time &endTime)
|
||||
{
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
//! does it contain time window tw completely?
|
||||
bool contains(const OpenTimeWindow &tw) const;
|
||||
|
||||
inline void TimeWindow::setStartTime(const Time &t)
|
||||
{
|
||||
_startTime = t;
|
||||
}
|
||||
//! does it overlap with time window tw?
|
||||
bool overlaps(const OpenTimeWindow &tw) const;
|
||||
|
||||
inline void TimeWindow::setEndTime(const Time &t)
|
||||
{
|
||||
_endTime = t;
|
||||
}
|
||||
|
||||
inline void TimeWindow::setLength(double length)
|
||||
{
|
||||
_endTime = _startTime + Time(length); // FIXME
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// Private members
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
OPT(Time) _startTime;
|
||||
OPT(Time) _endTime;
|
||||
};
|
||||
|
||||
inline bool TimeWindow::contains(const Time &t) const
|
||||
{
|
||||
return t >= _startTime && t < _endTime;
|
||||
}
|
||||
|
||||
inline bool TimeWindow::contains(const TimeWindow &tw) const
|
||||
{
|
||||
return tw._startTime >= _startTime && tw._endTime <= _endTime;
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &os, const TimeWindow &timeWindow);
|
||||
std::ostream &operator<<(std::ostream &os, const OpenTimeWindow &timeWindow);
|
||||
|
||||
|
||||
#include "timewindow.ipp"
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user