🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
Struct.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "Field.hpp"
25#include "AstUtil/Object.hpp"
26#include <unordered_map>
27#include <vector>
28
29
30AST_NAMESPACE_BEGIN
31
32class Property;
33
37class AST_UTIL_API Struct: public Object
38{
39public:
40 Struct()
42 {}
43
44 ~Struct() override;
45
46 // @todo: 考虑使用StringView作为索引
47 using PropertyMap = std::unordered_map<std::string, Property*>;
48 using PropertyList = std::vector<Property*>;
49
51 const std::string& getName() const final {return name_;}
52
55 void setName(StringView name) final {name_ = std::string(name);}
56
58 const std::string& desc() const{return desc_;}
59
62 void setDesc(StringView desc){desc_ = std::string(desc);}
63
68 Property* addProperty(StringView name, Property* property);
69
73 Property* addProperty(Property* property);
74
79
82 const PropertyList& getProperties() const{return properties_;}
83
86 std::string getModuleName() const;
87
88protected:
89 std::string name_;
90 std::string desc_;
91 PropertyList properties_;
92 PropertyMap propertyMap_;
93};
94
95
96
97AST_NAMESPACE_END
对象基类,继承自该类的对象可以使用运行时类型信息相关功能,实现强弱引用计数、运行时元信息(属性访问、序列化等)等基础功能
定义 Object.hpp:86
Property * getProperty(StringView fieldName) const
获取属性元信息
定义 Object.cpp:205
反射属性类
定义 Property.hpp:67
结构体类
定义 Struct.hpp:38
PropertyList properties_
属性列表
定义 Struct.hpp:91
std::string name_
名称
定义 Struct.hpp:89
PropertyMap propertyMap_
属性映射表
定义 Struct.hpp:92
const PropertyList & getProperties() const
获取属性列表
定义 Struct.hpp:82
const std::string & desc() const
获取字段描述
定义 Struct.hpp:58
void setName(StringView name) final
设置字段名称
定义 Struct.hpp:55
std::string desc_
描述
定义 Struct.hpp:90
void setDesc(StringView desc)
设置字段描述
定义 Struct.hpp:62
const std::string & getName() const final
获取字段名称
定义 Struct.hpp:51
constexpr initial_strong_ref_t initial_strong_ref
初始化强引用计数的标记值
定义 Object.hpp:80