Home

Awesome

<p align="left"> <a href="https://github.com/ChunelFeng/CGraph"><img src="https://badgen.net/badge/langs/C++/cyan?list=1" alt="languages"></a> <a href="https://github.com/ChunelFeng/CGraph"><img src="https://badgen.net/badge/os/MacOS,Linux,Windows/cyan?list=1" alt="os"></a> <a href="https://github.com/ChunelFeng/CGraph/stargazers"><img src="https://badgen.net/github/stars/ChunelFeng/CGraph?color=cyan" alt="stars"></a> <a href="https://github.com/ChunelFeng/CGraph/network/members"><img src="https://badgen.net/github/forks/ChunelFeng/CGraph?color=cyan" alt="forks"></a> <a href="https://www.codefactor.io/repository/github/chunelfeng/cgraph/overview/main"><img src="https://www.codefactor.io/repository/github/chunelfeng/cgraph/badge/main" alt="CodeFactor" /></a> </p>

awesome-cpp HelloGithub GitHub-Chinese-Top-Charts

中文 | English Readme

<h1 align="center"> CGraph 说明文档 </h1> <img align="right" src="https://github.com/ChunelFeng/CGraph/blob/main/doc/image/CGraph%20Author.jpg" width="256px">

<b>CGraph</b> is a cross-platform <b>D</b>irected <b>A</b>cyclic <b>G</b>raph framework based on pure C++ without any 3rd-party dependencies.</br></br> You, with it, can <b>build your own operators simply, and describe any running schedules</b> as you need, such as dependence, parallelling, aggregation and so on. Some useful tools and plugins are also provide to improve your project.</br></br> Tutorials and contact information are show as follows. Please <b>get in touch with us for free</b> if you need more about this repository.

一. 简介

CGraph中文名为【色丶图】,是一套无任何第三方依赖的跨平台图流程执行框架。通过GPipeline(流水线)底层调度,提供了包含依赖元素依次执行、非依赖元素并发执行在 eDAG 调度功能。

使用者只需继承GNode(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行或流水线执行。还可以通过设定各种包含多节点信息的GGroup(组),自行控制图的条件判断、循环和并发执行逻辑。

项目提供了丰富的Param(参数)类型,用于不同应用场景下的数据互通。此外,还可以通过添加GAspect(切面)的方式,实现以上各种元素功能的横向扩展;通过引入GAdapter(适配器)对单个节点功能进行加强;或者通过添加GEvent(信号),丰富和优化执行逻辑。

CGraph Skeleton <br>

本工程使用纯C++11标准库编写,无任何第三方依赖。兼容MacOSLinuxWindowsAndroid系统,支持通过 CLionVSCodeXcodeVisual StudioCode::BlocksQt Creator等多款IDE进行本地编译和二次开发,具体编译方式请参考 CGraph 编译说明 <br>

详细功能介绍和用法,请参考 一面之猿网 中的文章内容。相关视频在B站持续更新中,欢迎观看和交流:<br>

二. 使用Demo

MyNode.h

#include "CGraph.h"

class MyNode1 : public CGraph::GNode {
public:
    CStatus run() override {
        printf("[%s], sleep for 1 second ...\n", this->getName().c_str());
        CGRAPH_SLEEP_SECOND(1)
        return CStatus();
    }
};

class MyNode2 : public CGraph::GNode {
public:
    CStatus run() override {
        printf("[%s], sleep for 2 second ...\n", this->getName().c_str());
        CGRAPH_SLEEP_SECOND(2)
        return CStatus();
    }
};

main.cpp

#include "MyNode.h"

using namespace CGraph;

int main() {
    /* 创建一个流水线,用于设定和执行流图信息 */
    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");
    pipeline->registerGElement<MyNode2>(&d, {b, c}, "nodeD");

    /* 执行流图框架 */
    pipeline->process();

    /* 清空流水线中所有的资源 */
    GPipelineFactory::remove(pipeline);

    return 0;
}

CGraph Demo <br> 如上图所示,图结构执行的时候,首先执行a节点。a节点执行完毕后,并行执行bc节点。bc节点全部执行完毕后,再执行d节点。

三. 推荐阅读

四. 关联项目

Star History Chart


<details> <summary><b>附录-1. 版本信息</b></summary>

[2021.05.04 - v1.0.0 - Chunel]

[2021.05.09 - v1.1.0 - Chunel]

[2021.05.18 - v1.1.1 - Chunel]

[2021.05.23 - v1.2.0 - Chunel]

[2021.05.29 - v1.3.0 - Chunel]

[2021.06.14 - v1.4.0 - Chunel]

[2021.06.20 - v1.4.1 - Chunel]

[2021.06.24 - v1.5.0 - Chunel]

[2021.07.07 - v1.5.1 - Chunel]

[2021.07.11 - v1.5.2 - Chunel]

[2021.07.31 - v1.5.3 - Chunel]

[2021.08.29 - v1.6.0 - Chunel]

[2021.09.19 - v1.6.1 - Chunel]

[2021.09.29 - v1.7.0 - Chunel]

[2021.10.07 - v1.7.1 - Chunel]

[2021.11.01 - v1.8.0 - Chunel]

[2021.12.18 - v1.8.1 - Chunel]

[2022.01.02 - v1.8.2 - Chunel]

[2022.01.23 - v1.8.3 - Chunel]

[2022.01.31 - v1.8.4 - Chunel]

[2022.02.03 - v1.8.5 - Chunel]

[2022.04.03 - v1.8.6 - Chunel]

[2022.04.05 - v2.0.0 - Chunel]

[2022.05.01 - v2.0.1 - Chunel]

[2022.05.29 - v2.1.0 - Chunel]

[2022.10.03 - v2.1.1 - Chunel]

[2022.11.03 - v2.2.0 - Chunel]

[2022.12.24 - v2.2.1 - Chunel]

[2022.12.25 - v2.2.2 - yeshenyong]

[2022.12.30 - v2.2.3 - Chunel]

[2023.01.21 - v2.3.0 - Chunel]

[2023.01.25 - v2.3.1 - Chunel]

[2023.02.10 - v2.3.2 - Chunel]

[2023.02.12 - v2.3.3 - yeshenyong, Chunel]

[2023.02.22 - v2.3.4 - Chunel]

[2023.03.25 - v2.4.0 - woodx, Chunel]

[2023.05.05 - v2.4.1 - Chunel]

[2023.06.17 - v2.4.2 - Chunel]

[2023.07.12 - v2.4.3 - Chunel]

[2023.09.05 - v2.5.0 - Chunel]

[2023.09.15 - v2.5.1 - Chunel]

[2023.11.06 - v2.5.2 - Chunel]

[2023.11.15 - v2.5.3 - Chunel]

[2024.01.05 - v2.5.4 - Chunel]

[2024.07.18 - v2.6.0 - PaPaPig-Melody, Chunel]

[2024.09.17 - v2.6.1 - Chunel]

[2024.11.16 - v2.6.2 - Chunel]

</details>
<details> <summary><b>附录-2. 感谢</b></summary> <p align="center"><img src="https://github.com/ChunelFeng/CGraph/blob/main/doc/image/HelloGithub%20Logo.gif"/></p> <p align="center"><img src="https://github.com/ChunelFeng/CGraph/blob/main/doc/image/GrowingGit%20Logo.png"/></p> </details>
<details> <summary><b>附录-3. 联系方式</b></summary> </details>