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

Function tutorial_aspect_param

tutorial/T10-AspectParam.cpp:19–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace CGraph;
18
19void tutorial_aspect_param() {
20 GPipelinePtr pipeline = GPipelineFactory::create();
21 MyConnParam paramA;
22 paramA.ip_ = "127.0.0.1";
23 paramA.port_ = 6666;
24
25 MyConnParam paramB;
26 paramB.ip_ = "255.255.255.255";
27 paramB.port_ = 9999;
28
29 GElementPtr a, b, c = nullptr;
30
31 pipeline->registerGElement<MyNode1>(&a, {}, "nodeA", 1);
32 pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB", 1);
33 pipeline->registerGElement<MyWriteParamNode>(&c, {b}, "nodeC", 2);
34
35 /** 给a节点添加 MyConnAspect 切面的逻辑,并且传入 paramA 相关参数 */
36 a->addGAspect<MyConnAspect, MyConnParam>(&paramA);
37
38 /** 给b节点添加多个切面,有的传递参数,有的不传递 */
39 b->addGAspect<MyConnAspect, MyConnParam>(&paramB)->addGAspect<MyTimerAspect>();
40
41 /** 在切面中,获取pipeline中的参数,并且进行对应处理 */
42 c->addGAspect<MyPipelineParamAspect>();
43
44 pipeline->process();
45 GPipelineFactory::clear();
46}
47
48
49int main() {

Callers 1

mainFunction · 0.70

Calls 3

createFunction · 0.85
clearFunction · 0.50
processMethod · 0.45

Tested by

no test coverage detected