-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a14f68f
commit f279714
Showing
6 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ CGRAPH_TUTORIAL_LIST = [ | |
"T24-Fence", | ||
"T25-Coordinator", | ||
"T26-Mutable", | ||
"T27-Trim", | ||
] | ||
|
||
[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ set(CGRAPH_TUTORIAL_LIST | |
T24-Fence | ||
T25-Coordinator | ||
T26-Mutable | ||
T27-Trim | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
@Contact: [email protected] | ||
@File: T26-Mutable.cpp | ||
@Time: 2023/11/15 21:18 | ||
@Desc: | ||
@Desc: 本例主要演示,通过 GMutable 在pipeline执行的过程中,修改 GMutable 中的依赖关系逻辑 | ||
***************************/ | ||
|
||
#include "MyGMutable/MyMutable.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: T27-Trim.cpp | ||
@Time: 2024/9/28 21:43 | ||
@Desc: 本例主要演示,通过 Trim() 方法,修剪pipeline中的冗余依赖逻辑 | ||
***************************/ | ||
|
||
#include "MyGNode/MyNode1.h" | ||
#include "MyGNode/MyNode2.h" | ||
|
||
using namespace CGraph; | ||
|
||
void tutorial_trim() { | ||
GPipelinePtr pipeline = GPipelineFactory::create(); | ||
GElementPtr a, b, c, d = nullptr; | ||
|
||
pipeline->registerGElement<MyNode1>(&a, {}, "nodeA"); | ||
pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB"); | ||
pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC"); | ||
|
||
/** | ||
* 可以看出,d节点 对a 的依赖,是可有可无的 | ||
* 建议通过 trim() 接口删除冗余依赖 | ||
* 参考文档:http://www.chunel.cn/archives/cgraph-remove-redundancy-link | ||
*/ | ||
pipeline->registerGElement<MyNode2>(&d, {a, b, c}, "nodeD"); | ||
|
||
auto trimSize = pipeline->trim(); | ||
CGRAPH_ECHO("trim size is: %u", trimSize); | ||
|
||
// 查看 trim后的效果 | ||
pipeline->dump(); | ||
GPipelineFactory::remove(pipeline); | ||
} | ||
|
||
|
||
int main() { | ||
tutorial_trim(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters