MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / tutorial_condition

Function tutorial_condition

tutorial/T06-Condition.cpp:18–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16using namespace CGraph;
17
18void tutorial_condition() {
19 CStatus status;
20 GPipelinePtr pipeline = GPipelineFactory::create();
21 GElementPtr a, b_condition, c, d_condition = nullptr;
22
23 b_condition = pipeline->createGGroup<MyCondition>({
24 pipeline->createGNode<MyNode1>(GNodeInfo("conditionNodeB0", 1)),
25 pipeline->createGNode<MyNode2>(GNodeInfo("conditionNodeB1", 1)),
26 pipeline->createGNode<MyNode1>(GNodeInfo("conditionNodeB2", 1))
27 }); // 生成 b_condition。执行的时候,根据choose()的返回值,在B0,B1,B2中选择一个执行
28
29 d_condition = pipeline->createGGroup<MyParamCondition>({
30 pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD0", 1)),
31 pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD1", 1)),
32 pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD2", 1))
33 });
34
35 status += pipeline->registerGElement<MyWriteParamNode>(&a, {}, "writeNodeA", 1);
36 status += pipeline->registerGElement<MyCondition>(&b_condition, {a}, "conditionB", 1);
37 status += pipeline->registerGElement<MyReadParamNode>(&c, {b_condition}, "readNodeC", 1);
38 status += pipeline->registerGElement<MyParamCondition>(&d_condition, {c}, "conditionD", 1);
39 if (!status.isOK()) {
40 return;
41 }
42
43 status = pipeline->init();
44
45 for (int i = 0; i < 3; i++) {
46 status += pipeline->run();
47 std::cout << "[CGraph] tutorial_condition, loop : " << i + 1 << ", and run status = " << status.getCode() << std::endl;
48 }
49
50 status = pipeline->destroy();
51
52 GPipelineFactory::remove(pipeline);
53}
54
55
56int main() {

Callers 1

mainFunction · 0.70

Calls 8

createFunction · 0.85
GNodeInfoClass · 0.85
removeFunction · 0.85
isOKMethod · 0.80
getCodeMethod · 0.80
initMethod · 0.45
runMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected