25#include "AstUtil/Logger.hpp"
47AST_CORE_CAPI errc_t
aTimeIntervalFormat(
const TimeInterval& interval, std::string& strStart, std::string& strEnd);
54AST_CORE_CAPI errc_t
aTimeIntervalParse(StringView strStart, StringView strEnd, TimeInterval& interval);
76 this->setStartStop(start, stop);
85 this->setStartStop(epoch, start, stop);
124 start_ = -std::numeric_limits<double>::infinity();
125 stop_ = +std::numeric_limits<double>::infinity();
142 std::string strStart, strEnd;
144 return strStart +
" - " + strEnd;
153 errc_t discrete(
const TimePoint& epoch,
double step, std::vector<double>& times)
const;
160 errc_t discrete(
double step, std::vector<TimePoint>& times)
const;
162 class DiscreteTimePointRange;
163 class DiscreteEpochSecondRange;
168 DiscreteTimePointRange discrete(
double step)
const;
174 DiscreteEpochSecondRange discrete(
const TimePoint& epoch,
double step)
const;
192 : interval_(interval), step_(step), n_(n) {}
196 using iterator_category = std::input_iterator_tag;
198 using difference_type = ptrdiff_t;
204 : range_(range), idx_(idx), value_() {}
207 if (idx_ == range_->n_ - 1) {
208 value_ = range_->interval_.stop();
210 value_ = range_->interval_.start() + range_->step_ * idx_;
215 iterator& operator++() { ++idx_;
return *
this; }
216 iterator operator++(
int) {
auto tmp = *
this; ++*
this;
return tmp; }
218 bool operator==(
const iterator& other)
const {
return idx_ == other.idx_; }
219 bool operator!=(
const iterator& other)
const {
return !(*
this == other); }
228 iterator end()
const {
return iterator(
this, n_); }
229 size_t size()
const {
return n_; }
232 TimeInterval interval_;
241 : offset_(offset), step_(step), stopOffset_(stopOffset), n_(n) {}
245 using iterator_category = std::input_iterator_tag;
246 using value_type = double;
247 using difference_type = ptrdiff_t;
248 using pointer =
const double*;
249 using reference =
const double&;
253 : range_(range), idx_(idx), value_() {}
255 reference operator*()
const {
256 if (idx_ == range_->n_ - 1) {
257 value_ = range_->stopOffset_;
259 value_ = range_->offset_ + range_->step_ * idx_;
264 iterator& operator++() { ++idx_;
return *
this; }
265 iterator operator++(
int) {
auto tmp = *
this; ++*
this;
return tmp; }
267 bool operator==(
const iterator& other)
const {
return idx_ == other.idx_; }
268 bool operator!=(
const iterator& other)
const {
return !(*
this == other); }
273 mutable double value_{0.0};
277 iterator end()
const {
return iterator(
this, n_); }
278 size_t size()
const {
return n_; }
289 double dur = duration();
290 if (step <= 0.0 || dur <= 0.0) {
293 size_t n =
static_cast<size_t>(std::ceil(dur / step));
299 double dur = duration();
300 if (step <= 0.0 || dur <= 0.0) {
303 size_t n =
static_cast<size_t>(std::ceil(dur / step));
304 double offset = getStart() - epoch;
305 double stopOffset = getStop() - epoch;
318 aError(
"merge time interval failed, no overlap");
319 return eErrorInvalidParam;
325 setStartStop(mergedStart, mergedStop);
离散化历元秒范围
定义 TimeInterval.hpp:238
离散化时间点范围
定义 TimeInterval.hpp:189
时间区间
定义 TimeInterval.hpp:60
void setInfinite()
设置时间区间为无限时间区间
定义 TimeInterval.hpp:121
TimePoint getStop() const
时间区间的结束时间点
定义 TimeInterval.hpp:98
double duration() const
时间区间的持续时间(秒)
定义 TimeInterval.hpp:137
TimeInterval(const TimePoint &epoch, double start, double stop)
构造函数
定义 TimeInterval.hpp:83
const TimePoint & getStart() const
时间区间的开始时间点
定义 TimeInterval.hpp:92
void setZero()
设置时间区间为零时间区间
定义 TimeInterval.hpp:129
void setStartStop(const TimePoint &epoch, double start, double stop)
设置时间区间的开始时间点和结束时间点
定义 TimeInterval.hpp:114
const TimePoint & start() const
时间区间的开始时间点
定义 TimeInterval.hpp:89
std::string toString() const
将时间区间转换为字符串
定义 TimeInterval.hpp:141
TimePoint stop() const
时间区间的结束时间点
定义 TimeInterval.hpp:95
TimeInterval(const TimePoint &start, const TimePoint &stop)
构造函数
定义 TimeInterval.hpp:75
void setStartStop(const TimePoint &start, const TimePoint &stop)
设置时间区间的开始时间点和结束时间点
定义 TimeInterval.hpp:104
绝对时间点
定义 TimePoint.hpp:106
double fractionalPart() const
时间点的小数秒数部分
定义 TimePoint.hpp:176
double durationFrom(const TimePoint &other) const
计算与另一个时间点的时间差(秒数)
定义 TimePoint.hpp:224
int64_t integerPart() const
时间点的整数秒数部分
定义 TimePoint.hpp:173
errc_t aTimeIntervalFormat(const TimeInterval &interval, std::string &strStart, std::string &strStop)
将时间区间格式化为字符串
定义 TimeInterval.cpp:26
errc_t aTimeIntervalParse(StringView strStart, StringView strStop, TimeInterval &interval)
从字符串解析时间区间
定义 TimeInterval.cpp:36