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

Function tutorial_singleton

tutorial/T11-Singleton.cpp:14–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_singleton() {
15 GPipelinePtr pipeline = GPipelineFactory::create();
16 GElementPtr a, b, c, d, e = nullptr;
17
18 /* 通过GSingleton方式注册的节点,地址相同 */
19 pipeline->registerGElement<GSingleton<MyShowAddressNode>>(&a, {}, "singleton", 2);
20
21 /* 通过普通方式注册的节点,地址不同 */
22 pipeline->registerGElement<MyShowAddressNode>(&b, {a}, "not singleton");
23 pipeline->registerGElement<GSingleton<MyShowAddressNode>>(&c, {a}); // c的地址和a是相同的
24 pipeline->registerGElement<GSingleton<MyNode1>>(&d, {c}, "nodeD");
25 pipeline->registerGElement<GSingleton<MyShowAddressNode>>(&e, {c}); // e的地址和a也是相同的
26
27 pipeline->process();
28 GPipelineFactory::remove(pipeline);
29}
30
31
32int main() {

Callers 1

mainFunction · 0.85

Calls 3

createFunction · 0.85
removeFunction · 0.85
processMethod · 0.45

Tested by

no test coverage detected