🛰️航天仿真算法库 SpaceAST
0.0.1
载入中...
搜索中...
未找到
DataSeries.hpp
浏览该文件的文档.
1
21
22
#pragma once
23
24
#include "AstGlobal.h"
25
#include "AstReport/AstReportGlobal.hpp"
26
#include "AstUtil/VariantVector.hpp"
27
28
#include <string>
29
#include <vector>
30
31
AST_NAMESPACE_BEGIN
32
38
// ---- 前置声明 ----
39
40
class
TimePoint;
41
42
44
class
AST_REPORT_API
DataSeries
45
{
46
public
:
47
// ---- 构造/析构 ----
48
49
DataSeries
() =
default
;
50
DataSeries
(
const
std::string& name,
EDataType
type,
size_t
size);
51
53
template
<
typename
T>
54
DataSeries
(
const
std::string& name,
const
std::vector<T>& data);
55
56
~DataSeries
() =
default
;
57
58
// ---- 拷贝 ----
59
60
DataSeries
(
const
DataSeries
& other) =
default
;
61
DataSeries
& operator=(
const
DataSeries
& other) =
default
;
62
63
// ---- 移动 ----
64
65
DataSeries
(
DataSeries
&& other)
noexcept
=
default
;
66
DataSeries
& operator=(
DataSeries
&& other)
noexcept
=
default
;
67
68
// ---- 基本信息 ----
69
70
const
std::string& name()
const
{
return
name_; }
71
void
setName(
const
std::string& name) { name_ = name; }
72
73
size_t
size()
const
{
return
data_.size(); }
74
const
std::type_info& elementType()
const
{
return
data_.elementType(); }
75
bool
empty()
const
{
return
data_.empty(); }
76
77
// ---- 统计方法(返回 double,仅数值类型有效)----
78
79
double
mean()
const
;
80
double
min()
const
;
81
double
max()
const
;
82
double
sum()
const
;
83
double
stddev()
const
;
84
85
// ---- 类型安全访问 ----
86
88
template
<
typename
T>
89
T*
as
() {
return
data_.as<T>(); }
90
91
template
<
typename
T>
92
const
T* as()
const
{
return
data_.as<T>(); }
93
95
template
<
typename
T>
96
Span<T>
asSpan
() {
return
data_.asSpan<T>(); }
97
98
template
<
typename
T>
99
Span<const T>
asSpan()
const
{
return
data_.asSpan<T>(); }
100
101
// ---- 修改 ----
102
103
void
resize(
size_t
n);
104
void
sort(
bool
ascending =
true
);
105
106
// ---- 数据访问 ----
107
108
const
VariantVector& data()
const
{
return
data_; }
109
VariantVector& data() {
return
data_; }
110
protected
:
111
friend
class
DataFrame;
112
113
std::string
name_
;
114
VariantVector
data_
;
115
};
116
117
118
// =========================================
119
// DataSeries 模板构造函数(内联)
120
// =========================================
121
122
template
<
typename
T>
123
inline
DataSeries::DataSeries(
const
std::string& name,
const
std::vector<T>& data)
124
: name_(name)
125
, data_(
VariantVector
::fromVector(data))
126
{
127
}
128
131
AST_NAMESPACE_END
ast::DataSeries
数据列 — 类型擦除的一维数组
定义
DataSeries.hpp:45
ast::DataSeries::name_
std::string name_
数据名称
定义
DataSeries.hpp:113
ast::DataSeries::as
T * as()
获取类型化指针(类型不匹配返回 nullptr)
定义
DataSeries.hpp:89
ast::DataSeries::data_
VariantVector data_
数据向量
定义
DataSeries.hpp:114
ast::DataSeries::asSpan
Span< T > asSpan()
获取类型化 Span 视图(类型不匹配返回空 Span)
定义
DataSeries.hpp:96
ast::Span
非拥有的连续对象序列视图
定义
Span.hpp:71
ast::VariantVector
变类型向量容器
定义
VariantVector.hpp:59
ast::EDataType
EDataType
数据元素的数据类型
定义
AstReportGlobal.hpp:46
src
AstReport
DataFrame
DataSeries.hpp
制作者
1.12.0