🛰️航天仿真算法库 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 this->setReadOnly(true);
44 }
45
46 ~Struct() override;
47
48 // @todo: 考虑使用StringView作为索引
49 using PropertyMap = std::unordered_map<std::string, Property*>;
50 using PropertyList = std::vector<Property*>;
51
53 const std::string& getName() const final {return name_;}
54
57 void setName(StringView name) final {name_ = std::string(name);}
58
60 const std::string& desc() const{return desc_;}
61
64 void setDesc(StringView desc){desc_ = std::string(desc);}
65
70 Property* addProperty(StringView name, Property* property);
71
75 Property* addProperty(Property* property);
76
81
84 const PropertyList& getProperties() const{return properties_;}
85
88 std::string getModuleName() const;
89
90protected:
91 std::string name_;
92 std::string desc_;
93 PropertyList properties_;
94 PropertyMap propertyMap_;
95};
96
97
98
99AST_NAMESPACE_END
对象基类,继承自该类的对象可以使用运行时类型信息相关功能,实现强弱引用计数、运行时元信息(属性访问、序列化等)等基础功能
定义 Object.hpp:95
Property * getProperty(StringView fieldName) const
获取属性元信息
定义 Object.cpp:213
反射属性类
定义 Property.hpp:67
结构体类
定义 Struct.hpp:38
PropertyList properties_
属性列表
定义 Struct.hpp:93
std::string name_
名称
定义 Struct.hpp:91
PropertyMap propertyMap_
属性映射表
定义 Struct.hpp:94
const PropertyList & getProperties() const
获取属性列表
定义 Struct.hpp:84
const std::string & desc() const
获取字段描述
定义 Struct.hpp:60
void setName(StringView name) final
设置字段名称
定义 Struct.hpp:57
std::string desc_
描述
定义 Struct.hpp:92
void setDesc(StringView desc)
设置字段描述
定义 Struct.hpp:64
const std::string & getName() const final
获取字段名称
定义 Struct.hpp:53
constexpr initial_strong_ref_t initial_strong_ref
初始化强引用计数的标记值
定义 Referenced.hpp:38