forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGElementRepository.h
More file actions
88 lines (69 loc) · 1.89 KB
/
GElementRepository.h
File metadata and controls
88 lines (69 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: GElementRepository.h
@Time: 2023/6/24 16:42
@Desc:
***************************/
#ifndef CGRAPH_GELEMENTREPOSITORY_H
#define CGRAPH_GELEMENTREPOSITORY_H
#include "GElementObject.h"
#include "GElement.h"
CGRAPH_NAMESPACE_BEGIN
class GElementRepository : public GElementObject {
private:
/**
* 插入一个element
* @param ptr
* @return
*/
CVoid insert(GElementPtr ptr);
/**
* 查找对应的element
* @param ptr
* @return
*/
CBool find(GElementPtr ptr) const;
/**
* 给所有的element,设定线程池
* @param ptr
* @return
*/
GElementRepository* setThreadPool(UThreadPoolPtr ptr);
/**
* 准备执行流程
* @return
*/
CStatus setup();
/**
* 等待所有的element执行结束
* @return
* @notice 主要针对异步流程
*/
CStatus reset();
/**
* 设置所有内部的element状态
* @param state
* @return
*/
CStatus pushAllState(const GElementState& state);
/**
* 用于判断是否是出于退出状态
* @return
*/
CBool isCancelState() const;
CStatus init() override;
CStatus destroy() override;
CStatus run() final;
~GElementRepository() override;
private:
GElementPtrSet elements_ {}; // 用于记录所有的element信息
GElementState cur_state_ { GElementState::CREATE }; // 当前状态信息
GElementPtrSet async_elements_ {}; // 所有异步执行的逻辑,到后来一次性统一获取执行结果信息
friend class GPipeline;
friend class GPerf;
};
using GElementRepositoryPtr = GElementRepository *;
using GElementRepositoryRef = GElementRepository &;
CGRAPH_NAMESPACE_END
#endif //CGRAPH_GELEMENTREPOSITORY_H