28#include "AstUtil/Logger.hpp"
51AST_CORE_CAPI errc_t
aTimeIntervalFormat(
const TimeInterval& interval, std::string& strStart, std::string& strEnd,
int precision = kTimePointDefaultFormatPrecision);
58AST_CORE_CAPI errc_t
aTimeIntervalParse(StringView strStart, StringView strEnd, TimeInterval& interval);
76 TimePoint{0, -std::numeric_limits<double>::infinity()});
84 ~TimeInterval() =
default;
90 : start_(start), stop_(stop) {}
97 : start_(epoch + start), stop_(epoch + stop) {}
130 start_ = epoch + start;
131 stop_ = epoch + stop;
138 start_ = epoch + interval.start();
139 stop_ = epoch + interval.stop();
153 return Interval{getStart() - epoch, getStop() - epoch};
159 start_ = {0, -std::numeric_limits<double>::infinity()};
160 stop_ = {0, +std::numeric_limits<double>::infinity()};
165 start_ = {0, +std::numeric_limits<double>::infinity()};
166 stop_ = {0, -std::numeric_limits<double>::infinity()};
173 bool isEmpty()
const {
return !(start_ <= stop_); }
175 bool isPoint()
const {
return start_ == stop_; }
179 bool isValid()
const {
return start_ <= stop_; }
189 std::string
toString(
int precision = kTimePointDefaultFormatPrecision)
const{
190 std::string strStart, strEnd;
192 return strStart +
" - " + strEnd;
201 errc_t discretize(
const TimePoint& epoch,
double step, std::vector<double>& times)
const;
208 errc_t discretize(
double step, std::vector<TimePoint>& times)
const;
215 errc_t discretize(
double step,
TimeList& times)
const;
236 double dur = duration();
237 if (step > 0 && dur >= 0)
239 return static_cast<size_t>(std::ceil(dur / step)) + 1;
297 double dur = duration();
298 if (step > 0 && dur >= 0)
300 size_t n =
static_cast<size_t>(std::ceil(dur / step)) + 1;
308 double dur = duration();
309 if (step > 0 && dur >= 0)
311 size_t n =
static_cast<size_t>(std::ceil(dur / step)) + 1;
312 double start = getStart() - epoch;
313 double stop = getStop() - epoch;
按步长采样的相对秒范围(惰性可迭代)
定义 DoubleRange.hpp:41
时间区间
定义 TimeInterval.hpp:64
bool isValid() const
是否非空(start_ <= stop_,即点区间或有效区间)
定义 TimeInterval.hpp:179
Interval toInterval(const TimePoint &epoch) const
将绝对时间区间转换为相对于给定基准历元的相对时间区间
定义 TimeInterval.hpp:151
double duration() const
时间区间的持续时间(秒)
定义 TimeInterval.hpp:170
TimeInterval & operator|=(const TimeInterval &other)
原地并集(等价于 unite)
定义 TimeInterval.hpp:279
bool isNonEmpty() const
isValid() 的别名
定义 TimeInterval.hpp:181
static TimeInterval Empty()
空区间哨兵({+∞, -∞},IEEE 1788 惯例)
定义 TimeInterval.hpp:74
TimeInterval(const TimePoint &epoch, double start, double stop)
构造函数
定义 TimeInterval.hpp:96
const TimePoint & getStart() const
时间区间的开始时间点
定义 TimeInterval.hpp:103
void setBounds(const TimePoint &epoch, const Interval &interval)
设置时间区间的开始时间点和结束时间点
定义 TimeInterval.hpp:137
void setBounds(const TimePoint &epoch, double start, double stop)
设置时间区间的开始时间点和结束时间点
定义 TimeInterval.hpp:129
bool isDegenerate() const
isPoint() 的别名
定义 TimeInterval.hpp:177
TimeInterval operator&(const TimeInterval &other) const
交集(返回副本,等价于 intersected)
定义 TimeInterval.hpp:288
void setEmpty()
设置时间区间为空区间
定义 TimeInterval.hpp:163
void setStart(const TimePoint &start)
设置时间区间的开始时间点
定义 TimeInterval.hpp:106
bool isEmpty() const
是否为空区间(start_ > stop_,弱序否定;反向 / {+∞,-∞} 哨兵 / NaN → true)
定义 TimeInterval.hpp:173
bool contains(const TimePoint &t) const
是否包含绝对时间点 t(闭区间含端点)
定义 TimeInterval.hpp:183
size_t discretizedCount(double step) const
计算离散化采样点数量
定义 TimeInterval.hpp:234
bool isPoint() const
是否为点区间(start_ == stop_,恰含一个瞬时,非空)
定义 TimeInterval.hpp:175
const TimePoint & stop() const
时间区间的结束时间点
定义 TimeInterval.hpp:109
const TimePoint & start() const
时间区间的开始时间点
定义 TimeInterval.hpp:100
void setBounds(const TimePoint &start, const TimePoint &stop)
设置时间区间的开始时间点和结束时间点
定义 TimeInterval.hpp:120
std::string toString(int precision=kTimePointDefaultFormatPrecision) const
将时间区间转换为字符串
定义 TimeInterval.hpp:189
const TimePoint & getStop() const
时间区间的结束时间点
定义 TimeInterval.hpp:112
TimeInterval operator|(const TimeInterval &other) const
并集(返回副本,等价于 united)
定义 TimeInterval.hpp:282
TimeInterval(const TimePoint &start, const TimePoint &stop)
构造函数
定义 TimeInterval.hpp:89
TimeInterval & operator&=(const TimeInterval &other)
原地交集(等价于 intersect)
定义 TimeInterval.hpp:285
void setWhole()
设置时间区间为全区间
定义 TimeInterval.hpp:157
void setStop(const TimePoint &stop)
设置时间区间的结束时间点
定义 TimeInterval.hpp:115
按步长采样的时间点范围(惰性可迭代)
定义 TimePointRange.hpp:41
绝对时间点
定义 TimePoint.hpp:108
errc_t aTimeIntervalParse(StringView strStart, StringView strStop, TimeInterval &interval)
从字符串解析时间区间
定义 TimeInterval.cpp:37
errc_t aTimeIntervalFormat(const TimeInterval &interval, std::string &strStart, std::string &strStop, int precision)
将时间区间格式化为字符串
定义 TimeInterval.cpp:27