forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGDaemonObject.h
More file actions
84 lines (66 loc) · 1.98 KB
/
GDaemonObject.h
File metadata and controls
84 lines (66 loc) · 1.98 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: GDaemonObject.h
@Time: 2022/2/2 9:36 下午
@Desc:
***************************/
#ifndef CGRAPH_GDAEMONOBJECT_H
#define CGRAPH_GDAEMONOBJECT_H
#include "../GraphObject.h"
#include "../GraphParam/GParamInclude.h"
#include "../GraphEvent/GEventInclude.h"
CGRAPH_NAMESPACE_BEGIN
class GDaemonObject : public GraphObject,
public CDescInfo {
protected:
explicit GDaemonObject() {
session_ = URandom<>::generateSession(CGRAPH_STR_DAEMON);
}
~GDaemonObject() override {
CGRAPH_DELETE_PTR(param_)
}
/**
* 设置休眠时间信息,单位ms
* @return
*/
virtual GDaemonObject* setInterval(CMSec interval) {
if (0 == interval) {
return this;
}
interval_ = interval;
return this;
}
/**
* 设置daemon中参数,类型为GDaemonParam (即:GPassedParam)
* @tparam T
* @param param
* @return
*/
template <typename DParam,
c_enable_if_t<std::is_base_of<GDaemonParam, DParam>::value, int> = 0>
GDaemonObject* setDParam(DParam* param);
CGRAPH_DECLARE_GPARAM_MANAGER_WRAPPER
CGRAPH_DECLARE_GEVENT_MANAGER_WRAPPER
private:
/**
* 所有Daemon均不执行run方法
* @return
*/
CStatus run() final {
CGRAPH_NO_SUPPORT
}
CGRAPH_NO_ALLOWED_COPY(GDaemonObject)
friend class GDaemon;
friend class GDaemonManager;
friend class GPipeline;
private:
GParamManagerPtr param_manager_ = nullptr; // GParam参数管理类
GEventManagerPtr event_manager_ = nullptr; // 事件管理类
GDaemonParamPtr param_ = nullptr; // 用于存储daemon对象
CMSec interval_ = 0; // 执行间隔时间
};
using GDaemonObjectPtr = GDaemonObject *;
CGRAPH_NAMESPACE_END
#include "GDaemonObject.inl"
#endif //CGRAPH_GDAEMONOBJECT_H