-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathT01-Simple.cpp
50 lines (39 loc) · 1.12 KB
/
T01-Simple.cpp
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
/***************************
@Author: Chunel
@Contact: [email protected]
@File: T01-simple.cpp
@Time: 2024/9/6 20:24
@Desc:
***************************/
#include <iostream>
#include <chrono>
#include "CGraph-lite.h"
using namespace CGraphLite;
class MyNode1 : public GNode {
CStatus run() override {
std::cout << getName() << ": sleep 1s.\n";
std::this_thread::sleep_for(std::chrono::seconds(1));
return CStatus();
}
};
class MyNode2 : public GNode {
CStatus run() override {
std::cout << getName() << ": sleep 2s.\n";
std::this_thread::sleep_for(std::chrono::seconds(2));
return CStatus();
}
};
void tutorial_simple() {
GElement *a, *b, *c, *d = nullptr;
auto pipeline = GPipelineFactory::create();
pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB");
pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC");
pipeline->registerGElement<MyNode2>(&d, {b, c}, "nodeD");
pipeline->process();
GPipelineFactory::remove(pipeline);
}
int main() {
tutorial_simple();
return 0;
}