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

Function tutorial_param

tutorial/T05-Param.cpp:14–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_param() {
15 GPipelinePtr pipeline = GPipelineFactory::create();
16 CStatus status;
17 GElementPtr a, b, c, d, e, f = nullptr;
18
19 status += pipeline->registerGElement<MyReadParamNode>(&a, {}, "readNodeA"); // 读取param中的信息,不做修改
20 status += pipeline->registerGElement<MyReadParamNode>(&b, {a}, "readNodeB");
21 status += pipeline->registerGElement<MyWriteParamNode>(&c, {a}, "writeNodeC");
22 status += pipeline->registerGElement<MyWriteParamNode>(&d, {a}, "writeNodeD", 2); // 对param中的iValue值+1,循环执行2次
23 status += pipeline->registerGElement<MyReadParamNode>(&e, {a}, "readNodeE");
24 status += pipeline->registerGElement<MyWriteParamNode>(&f, {b, c, d, e}, "writeNodeF");
25 if (!status.isOK()) {
26 return; // 使用时,请对所有CGraph接口的返回值做判定。本例子中省略
27 }
28
29 status += pipeline->init();
30
31 for (int i = 0; i < 3; i++) {
32 status += pipeline->run();
33 std::cout << "[CGraph] tutorial_param, loop : " << i + 1 << ", and run status = " << status.getCode() << std::endl;
34 }
35
36 /**
37 auto param = pipeline->getGParam<MyParam>("param1"); // 可以获取pipeline内部的参数内容。但是需要考虑param的setup()和reset()的时机
38 std::cout << "[CGraph] get param from pipeline, iCount = " << param->iCount << std::endl;
39 */
40
41 status += pipeline->destroy();
42 GPipelineFactory::remove(pipeline);
43}
44
45
46int main() {

Callers 1

mainFunction · 0.70

Calls 7

createFunction · 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