Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ if __name__ == '__main__':
* 优化 `message` 功能
* 优化 `aspect` 功能

[2025.10.06 - v3.2.0 - Chunel]
* 提供 本地保存和加载 功能

</details>

------------
Expand Down
11 changes: 0 additions & 11 deletions proto/aspect.proto

This file was deleted.

12 changes: 0 additions & 12 deletions proto/daemon.proto

This file was deleted.

26 changes: 0 additions & 26 deletions proto/element.proto

This file was deleted.

12 changes: 0 additions & 12 deletions proto/event.proto

This file was deleted.

22 changes: 0 additions & 22 deletions proto/param.proto

This file was deleted.

15 changes: 0 additions & 15 deletions proto/pipeline.proto

This file was deleted.

1 change: 1 addition & 0 deletions src/CBasic/CBasicDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace internal { \
CGRAPH_INTERNAL_NAMESPACE_BEGIN

using CCHAR = char;
using CUCHAR = unsigned char;
using CUINT = unsigned int;
using CVOID = void;
using CINT = int;
Expand Down
2 changes: 2 additions & 0 deletions src/CBasic/CValType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

using CChar = CGraph::internal::CCHAR;
using CCharPtr = CGraph::internal::CCHAR *;
using CUChar = CGraph::internal::CUCHAR;
using CUCharPtr = CGraph::internal::CUCHAR *;
using CUInt = CGraph::internal::CUINT;
using CSize = CGraph::internal::CSIZE;
using CVoid = CGraph::internal::CVOID;
Expand Down
2 changes: 2 additions & 0 deletions src/GraphCtrl/GraphElement/GElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ class GElement : public GElementObject,
friend class GSeparateOptimizer;
friend class GElementRepository;
friend class GPerf;
friend class _GElementStorage;
friend class GStorage;

CGRAPH_DECLARE_GPARAM_MANAGER_WRAPPER_WITH_MEMBER
CGRAPH_DECLARE_GEVENT_MANAGER_WRAPPER_WITH_MEMBER
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GElementRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class GElementRepository : public GElementObject {

friend class GPipeline;
friend class GPerf;
friend class GStorage;
};

using GElementRepositoryPtr = GElementRepository *;
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GCluster : public GGroup {
friend class GPipeline;
friend class GDynamicEngine;
friend class CAllocator;
friend class GStorageFactory;
};

CGRAPH_NAMESPACE_END
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GCondition : public GGroup {
CBool isSeparate(GElementCPtr a, GElementCPtr b) const override;

friend class GPipeline;
friend class GStorageFactory;
};

using GConditionPtr = GCondition *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GMultiCondition : public GCondition {

friend class GPipeline;
friend class CAllocator;
friend class GStorageFactory;
};

CGRAPH_NAMESPACE_END
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GGroup : public GElement {
friend class GCondition;
friend class GMutable;
friend class GElementRepository;
friend class GStorage;
template<GMultiConditionType> friend class GMultiCondition;
template<CInt> friend class GSome;

Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GMutable : public GGroup {

friend class GPipeline;
friend class CAllocator;
friend class GStorageFactory;
};

using GMutablePtr = GMutable *;
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class GRegion : public GGroup {

friend class GPipeline;
friend class CAllocator;
friend class GStorageFactory;
friend class GTrimOptimizer;
};

Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GGroup/GSome/GSome.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GSome : public GGroup {
friend class GPipeline;
friend class GDynamicEngine;
friend class CAllocator;
friend class GStorageFactory;
};

CGRAPH_NAMESPACE_END
Expand Down
38 changes: 37 additions & 1 deletion src/GraphCtrl/GraphPipeline/GPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "GPipeline.h"
#include "_GPerf/GPerfInclude.h"
#include "_GStroage/GStorageInclude.h"
#include "../GraphElement/_GOptimizer/GOptimizerInclude.h"

CGRAPH_NAMESPACE_BEGIN
Expand Down Expand Up @@ -321,9 +322,44 @@ CBool GPipeline::checkSeparate(GElementPtr fst, GElementPtr snd) const {
}


CStatus GPipeline::save(const std::string& path) {
CGRAPH_FUNCTION_BEGIN
std::set<std::string> names;

// 不允许有同名的 element 被存储
for (const auto* element : repository_.elements_) {
CGRAPH_ASSERT_NOT_NULL(element)
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(element->isGAdaptor(),
element->name_ + " is GAdaptor, cannot be saved.")
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(names.find(element->name_) != names.end(),
element->name_ + " name is duplicated, cannot be saved.")
names.insert(element->name_);
}

#if __cplusplus >= 201703L
status = GStorage::save(this, path);
#else
status = CStatus("save function support cpp17+ only");
#endif
CGRAPH_FUNCTION_END
}


CStatus GPipeline::load(const std::string& path) {
CGRAPH_FUNCTION_BEGIN
#if __cplusplus >= 201703L
status = GStorage::load(this, path);
#else
status = CStatus("load function support cpp17+ only");
#endif

CGRAPH_FUNCTION_END
}


CStatus GPipeline::initEnv() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(event_manager_, element_manager_)
CGRAPH_ASSERT_NOT_NULL(event_manager_, element_manager_, stage_manager_)

status = schedule_.init();
CGRAPH_FUNCTION_CHECK_STATUS
Expand Down
16 changes: 16 additions & 0 deletions src/GraphCtrl/GraphPipeline/GPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "GPipelineObject.h"
#include "_GSchedule/GScheduleInclude.h"
#include "_GStroage/GStorageInclude.h"
#include "../GraphElement/GElementInclude.h"
#include "../GraphDaemon/GDaemonInclude.h"
#include "../GraphEvent/GEventInclude.h"
Expand Down Expand Up @@ -393,6 +394,20 @@ class GPipeline : public GPipelineObject,
*/
CBool checkSeparate(GElementPtr fst, GElementPtr snd) const;

/**
* 存储当前 pipeline 信息到本地
* @param path
* @return
*/
CStatus save(const std::string& path);

/**
* 从本地文件中加载 pipeline 信息
* @param path
* @return
*/
CStatus load(const std::string& path);

/**
* 注册GParam 交互类集合
* @return
Expand Down Expand Up @@ -437,6 +452,7 @@ class GPipeline : public GPipelineObject,
friend class GPipelineFactory;
friend class CAllocator;
friend class GPerf;
friend class GStorage;

public:
CStatus __registerGElement_4py(GElementPtr element, const GElementPtrSet &depends,
Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphPipeline/GPipelineFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

CGRAPH_NAMESPACE_BEGIN

GPipelinePtrList GPipelineFactory::s_pipeline_list_;
std::mutex GPipelineFactory::s_lock_;
GPipelinePtrList GPipelineFactory::s_pipeline_list_ {};
std::mutex GPipelineFactory::s_lock_ {};

GPipelinePtr GPipelineFactory::create() {
CGRAPH_FUNCTION_BEGIN
Expand Down
5 changes: 3 additions & 2 deletions src/GraphCtrl/GraphPipeline/GPipelineFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef CGRAPH_GPIPELINEFACTORY_H
#define CGRAPH_GPIPELINEFACTORY_H

#include <list>
#include <mutex>
#include <list>
#include <map>

#include "GPipeline.h"
#include "GPipelineObject.h"
Expand Down Expand Up @@ -38,7 +39,7 @@ class GPipelineFactory : public GPipelineObject {
static CStatus clear();

private:
static GPipelinePtrList s_pipeline_list_; // 记录所有的
static GPipelinePtrList s_pipeline_list_; // 记录所有的 pipeline 信息
static std::mutex s_lock_;
};

Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class GSchedule : public GraphObject {
internal::GScheduleType type_ = internal::GScheduleType::UNIQUE; // 调度类型

friend class GPipeline;
friend class GStorage;
};

CGRAPH_NAMESPACE_END
Expand Down
Loading
Loading