diff --git a/python/PyCGraph.cpp b/python/PyCGraph.cpp index c14320d2..029854eb 100644 --- a/python/PyCGraph.cpp +++ b/python/PyCGraph.cpp @@ -141,13 +141,13 @@ PYBIND11_MODULE(pycgraph, cg) { py::class_ >(cg, "GAspect") .def(py::init<>()) - .def("getName", &GAspect::__getName_4py) + .def("getName", &GAspect::__getName_4expose) .PYCGRAPH_DEF_GPARAM_PYBIND11_FUNCTIONS(GAspect) .PYCGRAPH_DEF_GEVENT_PYBIND11_FUNCTIONS(GAspect); py::class_ >(cg, "GDaemon") .def(py::init<>()) - .def("getInterval", &GDaemon::__getInterval_4py) + .def("getInterval", &GDaemon::__getInterval_4expose) .PYCGRAPH_DEF_GPARAM_PYBIND11_FUNCTIONS(GDaemon) .PYCGRAPH_DEF_GEVENT_PYBIND11_FUNCTIONS(GDaemon); @@ -212,15 +212,15 @@ PYBIND11_MODULE(pycgraph, cg) { py::arg("runTimes") = 1, py::call_guard()) .def("destroy", &GPipeline::destroy) - .def("addGEvent", &GPipeline::__addGEvent_4py, + .def("addGEvent", &GPipeline::__addGEvent_4expose, py::arg("event"), py::arg("key"), py::keep_alive<1, 2>()) - .def("addGDaemon", &GPipeline::__addGDaemon_4py, + .def("addGDaemon", &GPipeline::__addGDaemon_4expose, py::arg("daemon"), py::arg("ms"), py::keep_alive<1, 2>()) - .def("addGStage", &GPipeline::__addGStage_4py, + .def("addGStage", &GPipeline::__addGStage_4expose, py::arg("stage"), py::arg("key"), py::arg("threshold"), @@ -238,9 +238,9 @@ PYBIND11_MODULE(pycgraph, cg) { py::call_guard()) .def("resume", &GPipeline::resume, py::call_guard()) - .def("perf", &GPipeline::__perf_4py, + .def("perf", &GPipeline::__perf_4expose, py::call_guard()) - .def("dump", &GPipeline::__dump_4py) + .def("dump", &GPipeline::__dump_4expose) .def("trim", &GPipeline::trim) .def("makeSerial", &GPipeline::makeSerial) .def("getMaxPara", &GPipeline::getMaxPara) @@ -248,7 +248,7 @@ PYBIND11_MODULE(pycgraph, cg) { .def("checkSeparate", &GPipeline::checkSeparate, py::arg("fst"), py::arg("snd")) - .def("registerGElement", &GPipeline::__registerGElement_4py, + .def("registerGElement", &GPipeline::__registerGElement_4expose, py::arg("element"), py::arg("depends") = GElementPtrSet{}, py::arg("name") = CGRAPH_EMPTY, @@ -278,10 +278,10 @@ PYBIND11_MODULE(pycgraph, cg) { py::class_ >(cg, "GElement") .def(py::init<>()) - .def("__str__", &GElement::__str_4py) + .def("__str__", &GElement::__str_4expose) .PYCGRAPH_DEF_GPARAM_PYBIND11_FUNCTIONS(GElement) .PYCGRAPH_DEF_GEVENT_PYBIND11_FUNCTIONS(GElement) - .def("enterStage", &GElement::__enterStage_4py, + .def("enterStage", &GElement::__enterStage_4expose, py::arg("key"), py::call_guard()) .def("getName", &GElement::getName) @@ -302,11 +302,11 @@ PYBIND11_MODULE(pycgraph, cg) { .def("setTimeout", &GElement::setTimeout, py::arg("timeout"), py::arg("strategy") = GElementTimeoutStrategy::AS_ERROR) - .def("isTimeout", &GElement::__isTimeout_4py) + .def("isTimeout", &GElement::__isTimeout_4expose) .def("isGGroup", &GElement::isGGroup) .def("isGAdaptor", &GElement::isGAdaptor) .def("isGNode", &GElement::isGNode) - .def("addGAspect", &GElement::__addGAspect_4py, + .def("addGAspect", &GElement::__addGAspect_4expose, py::arg("aspect"), py::keep_alive<1, 2>()) .def("addDependGElements", &GElement::addDependGElements, diff --git a/python/setup.py b/python/setup.py index 4ac42c06..84adeb7e 100644 --- a/python/setup.py +++ b/python/setup.py @@ -44,6 +44,7 @@ Extension( name=__PYCGRAPH_NAME__, sources=_sources, + define_macros=[("CGRAPH_EXPOSE_INTERNALS", None)], extra_compile_args=_extra_compile_args, include_dirs=_include_dirs, extra_link_args=_extra_link_args, diff --git a/python/wrapper/PyWrapperMacro.h b/python/wrapper/PyWrapperMacro.h index d58e8aea..3b4e02b2 100644 --- a/python/wrapper/PyWrapperMacro.h +++ b/python/wrapper/PyWrapperMacro.h @@ -49,38 +49,38 @@ protected: .def(py::init(), \ py::arg("elements") = GElementPtrArr{}, \ py::keep_alive<1, 2>()) \ - .def("addGElements", &Pyw##PCGG::__addGElements_4py, \ + .def("addGElements", &Pyw##PCGG::__addGElements_4expose, \ py::arg("elements"), \ py::keep_alive<1, 2>()) \ \ #define PYCGRAPH_DEF_GPARAM_PYBIND11_FUNCTIONS(PCGO) \ - def("createGParam", &PCGO::__createGParam_4py, \ + def("createGParam", &PCGO::__createGParam_4expose, \ py::arg("param"), \ py::arg("key"), \ py::keep_alive<1, 2>(), \ py::call_guard()) \ - .def("getGParam", &PCGO::__getGParam_4py, \ + .def("getGParam", &PCGO::__getGParam_4expose, \ py::arg("key")) \ - .def("getGParamWithNoEmpty", &PCGO::__getGParamWithNoEmpty_4py, \ + .def("getGParamWithNoEmpty", &PCGO::__getGParamWithNoEmpty_4expose, \ py::arg("key")) \ - .def("removeGParam", &PCGO::__removeGParam_4py, \ + .def("removeGParam", &PCGO::__removeGParam_4expose, \ py::arg("key"), \ py::call_guard()) \ - .def("hasGParam", &PCGO::__hasGParam_4py, \ + .def("hasGParam", &PCGO::__hasGParam_4expose, \ py::arg("key"), \ py::call_guard()) \ \ #define PYCGRAPH_DEF_GEVENT_PYBIND11_FUNCTIONS(PCGO) \ - def("notify", &PCGO::__notify_4py, \ + def("notify", &PCGO::__notify_4expose, \ py::arg("key"), \ py::arg("type"), \ py::arg("strategy") = GEventAsyncStrategy::PIPELINE_RUN_FINISH, \ py::call_guard()) \ - .def("asyncNotify", &PCGO::__asyncNotify_4py, \ + .def("asyncNotify", &PCGO::__asyncNotify_4expose, \ py::arg("key"), \ py::arg("strategy") = GEventAsyncStrategy::PIPELINE_RUN_FINISH, \ py::call_guard()) \ diff --git a/python/wrapper/PywGCluster.h b/python/wrapper/PywGCluster.h index 106f5b14..2e59a33f 100644 --- a/python/wrapper/PywGCluster.h +++ b/python/wrapper/PywGCluster.h @@ -15,7 +15,7 @@ class PywGCluster : public CGraph::GCluster { public: explicit PywGCluster(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - __addGElements_4py(elements); + __addGElements_4expose(elements); } ~PywGCluster() override = default; diff --git a/python/wrapper/PywGCondition.h b/python/wrapper/PywGCondition.h index 1c1bc653..64963d61 100644 --- a/python/wrapper/PywGCondition.h +++ b/python/wrapper/PywGCondition.h @@ -17,7 +17,7 @@ class PywGCondition : public CGraph::GCondition { public: explicit PywGCondition(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - __addGElements_4py(elements); + __addGElements_4expose(elements); } ~PywGCondition() override = default; diff --git a/python/wrapper/PywGMutable.h b/python/wrapper/PywGMutable.h index 89f0d221..3941dc7f 100644 --- a/python/wrapper/PywGMutable.h +++ b/python/wrapper/PywGMutable.h @@ -17,7 +17,7 @@ class PywGMutable : public CGraph::GMutable { public: explicit PywGMutable(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - __addGElements_4py(elements); + __addGElements_4expose(elements); } ~PywGMutable() override = default; diff --git a/python/wrapper/PywGParallelMultiCondition.h b/python/wrapper/PywGParallelMultiCondition.h index 16286bf9..d2badff8 100644 --- a/python/wrapper/PywGParallelMultiCondition.h +++ b/python/wrapper/PywGParallelMultiCondition.h @@ -15,7 +15,7 @@ class PywGParallelMultiCondition : public CGraph::GMultiCondition { public: explicit PywGParallelMultiCondition(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - CGraph::GMultiCondition::__addGElements_4py(elements); + CGraph::GMultiCondition::__addGElements_4expose(elements); }; ~PywGParallelMultiCondition() override = default; diff --git a/python/wrapper/PywGRegion.h b/python/wrapper/PywGRegion.h index e72710e0..76a84c31 100644 --- a/python/wrapper/PywGRegion.h +++ b/python/wrapper/PywGRegion.h @@ -15,7 +15,7 @@ class PywGRegion : public CGraph::GRegion { public: explicit PywGRegion(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - __addGElements_4py(elements); + __addGElements_4expose(elements); }; ~PywGRegion() override = default; diff --git a/python/wrapper/PywGSerialMultiCondition.h b/python/wrapper/PywGSerialMultiCondition.h index c537f0dd..5a223935 100644 --- a/python/wrapper/PywGSerialMultiCondition.h +++ b/python/wrapper/PywGSerialMultiCondition.h @@ -15,7 +15,7 @@ class PywGSerialMultiCondition : public CGraph::GMultiCondition { public: explicit PywGSerialMultiCondition(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - CGraph::GMultiCondition::__addGElements_4py(elements); + CGraph::GMultiCondition::__addGElements_4expose(elements); }; ~PywGSerialMultiCondition() override = default; diff --git a/python/wrapper/PywGSome.h b/python/wrapper/PywGSome.h index d0084996..83ce9895 100644 --- a/python/wrapper/PywGSome.h +++ b/python/wrapper/PywGSome.h @@ -17,7 +17,7 @@ class PywGSome : public CGraph::GSome { public: explicit PywGSome(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { - __addGElements_4py(elements); + __addGElements_4expose(elements); } ~PywGSome() override = default; diff --git a/src/GraphCtrl/GraphAspect/GAspectObject.h b/src/GraphCtrl/GraphAspect/GAspectObject.h index 0d0c9369..1ef0ba18 100644 --- a/src/GraphCtrl/GraphAspect/GAspectObject.h +++ b/src/GraphCtrl/GraphAspect/GAspectObject.h @@ -70,8 +70,8 @@ class GAspectObject : public GraphObject, friend class GAspect; friend class GElement; -public: - const std::string& __getName_4py() const { +CGRAPH_INTERNAL_ACCESS: + const std::string& __getName_4expose() const { return getName(); } }; diff --git a/src/GraphCtrl/GraphDaemon/GDaemon.cpp b/src/GraphCtrl/GraphDaemon/GDaemon.cpp index 5441368e..c2a57c34 100644 --- a/src/GraphCtrl/GraphDaemon/GDaemon.cpp +++ b/src/GraphCtrl/GraphDaemon/GDaemon.cpp @@ -38,7 +38,7 @@ CMSec GDaemon::modify(GDaemonParamPtr param) { } -CMSec GDaemon::__getInterval_4py() const { +CMSec GDaemon::__getInterval_4expose() const { return getInterval(); } diff --git a/src/GraphCtrl/GraphDaemon/GDaemon.h b/src/GraphCtrl/GraphDaemon/GDaemon.h index c5272965..ccd07762 100644 --- a/src/GraphCtrl/GraphDaemon/GDaemon.h +++ b/src/GraphCtrl/GraphDaemon/GDaemon.h @@ -51,8 +51,8 @@ class GDaemon : public GDaemonObject { UTimer timer_; // 计时器 -public: - CMSec __getInterval_4py() const; +CGRAPH_INTERNAL_ACCESS: + CMSec __getInterval_4expose() const; }; using GDaemonPtr = GDaemon *; diff --git a/src/GraphCtrl/GraphElement/GElement.cpp b/src/GraphCtrl/GraphElement/GElement.cpp index 71b65495..0ab91fe0 100644 --- a/src/GraphCtrl/GraphElement/GElement.cpp +++ b/src/GraphCtrl/GraphElement/GElement.cpp @@ -641,7 +641,7 @@ GElementPtr GElement::updateAspectInfo() { } -GElementPtr GElement::__addGAspect_4py(GAspectPtr aspect) { +GElementPtr GElement::__addGAspect_4expose(GAspectPtr aspect) { CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(aspect) if (!aspect_manager_) { aspect_manager_ = CGRAPH_SAFE_MALLOC_COBJECT(GAspectManager) @@ -652,17 +652,17 @@ GElementPtr GElement::__addGAspect_4py(GAspectPtr aspect) { } -CStatus GElement::__enterStage_4py(const std::string& key) { +CStatus GElement::__enterStage_4expose(const std::string& key) { return enterStage(key); } -CBool GElement::__isTimeout_4py() { +CBool GElement::__isTimeout_4expose() { return isTimeout(); } -std::string GElement::__str_4py() { +std::string GElement::__str_4expose() { // python 中 print 展示的格式 std::string info = "getName() + ", session=" + this->getSession() + ", loop=" + std::to_string(this->getLoop()); diff --git a/src/GraphCtrl/GraphElement/GElement.h b/src/GraphCtrl/GraphElement/GElement.h index 5160e78b..0053b051 100644 --- a/src/GraphCtrl/GraphElement/GElement.h +++ b/src/GraphCtrl/GraphElement/GElement.h @@ -507,11 +507,11 @@ class GElement : public GElementObject, CGRAPH_DECLARE_GEVENT_MANAGER_WRAPPER_WITH_MEMBER CGRAPH_DECLARE_GSTAGE_MANAGER_WRAPPER_WITH_MEMBER -public: - GElement* __addGAspect_4py(GAspectPtr aspect); - CStatus __enterStage_4py(const std::string& key); - CBool __isTimeout_4py(); - std::string __str_4py(); +CGRAPH_INTERNAL_ACCESS: + GElement* __addGAspect_4expose(GAspectPtr aspect); + CStatus __enterStage_4expose(const std::string& key); + CBool __isTimeout_4expose(); + std::string __str_4expose(); }; using GElementRef = GElement &; diff --git a/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp b/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp index de531110..aec3e193 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp +++ b/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp @@ -123,7 +123,7 @@ CBool GGroup::isSeparate(GElementCPtr a, GElementCPtr b) const { } -CStatus GGroup::__addGElements_4py(const GElementPtrArr& elements) { +CStatus GGroup::__addGElements_4expose(const GElementPtrArr& elements) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_INIT(false) for (auto* element : elements) { diff --git a/src/GraphCtrl/GraphElement/GGroup/GGroup.h b/src/GraphCtrl/GraphElement/GGroup/GGroup.h index 6cba84f4..e0a698f2 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GGroup.h +++ b/src/GraphCtrl/GraphElement/GGroup/GGroup.h @@ -79,8 +79,8 @@ class GGroup : public GElement { template friend class GMultiCondition; friend class GSome; -public: - CStatus __addGElements_4py(const GElementPtrArr& elements); +CGRAPH_INTERNAL_ACCESS: + CStatus __addGElements_4expose(const GElementPtrArr& elements); }; using GGroupPtr = GGroup *; diff --git a/src/GraphCtrl/GraphEvent/GEventManager.cpp b/src/GraphCtrl/GraphEvent/GEventManager.cpp index 032f9faf..26430f35 100644 --- a/src/GraphCtrl/GraphEvent/GEventManager.cpp +++ b/src/GraphCtrl/GraphEvent/GEventManager.cpp @@ -12,7 +12,7 @@ CGRAPH_NAMESPACE_BEGIN CStatus GEventManager::init() { CGRAPH_FUNCTION_BEGIN - for (auto& iter : events_map_) { + for (const auto& iter : events_map_) { // fatInit 中包含了init(),和部分其他逻辑 auto event = iter.second; event->setGParamManager(param_manager_); @@ -24,7 +24,7 @@ CStatus GEventManager::init() { CStatus GEventManager::destroy() { CGRAPH_FUNCTION_BEGIN - for (auto& iter : events_map_) { + for (const auto& iter : events_map_) { status += (iter.second)->fatDestroy(); } CGRAPH_FUNCTION_END @@ -90,7 +90,7 @@ CStatus GEventManager::reset() { } -CStatus GEventManager::__create_4py(GEventPtr event, const std::string& key) { +CStatus GEventManager::__create_4expose(GEventPtr event, const std::string& key) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(event) CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(events_map_.find(key) != events_map_.end(), diff --git a/src/GraphCtrl/GraphEvent/GEventManager.h b/src/GraphCtrl/GraphEvent/GEventManager.h index cffa85bf..0646547b 100644 --- a/src/GraphCtrl/GraphEvent/GEventManager.h +++ b/src/GraphCtrl/GraphEvent/GEventManager.h @@ -76,7 +76,7 @@ class GEventManager : public GEventObject, friend class GStorage; private: - CStatus __create_4py(GEventPtr event, const std::string& key); + CStatus __create_4expose(GEventPtr event, const std::string& key); }; using GEventManagerPtr = GEventManager *; diff --git a/src/GraphCtrl/GraphEvent/GEventManagerWrapper.h b/src/GraphCtrl/GraphEvent/GEventManagerWrapper.h index 9ab157f3..a07dd18f 100644 --- a/src/GraphCtrl/GraphEvent/GEventManagerWrapper.h +++ b/src/GraphCtrl/GraphEvent/GEventManagerWrapper.h @@ -52,13 +52,13 @@ CGRAPH_NAMESPACE_BEGIN return this->event_manager_->asyncTrigger(key, strategy); \ } \ \ -public: \ - CStatus __notify_4py(const std::string& key, GEventType type, \ +CGRAPH_INTERNAL_ACCESS: \ + CStatus __notify_4expose(const std::string& key, GEventType type, \ GEventAsyncStrategy strategy = GEventAsyncStrategy::PIPELINE_RUN_FINISH) { \ return this->notify(key, type, strategy); \ } \ \ - std::shared_future __asyncNotify_4py(const std::string& key, \ + std::shared_future __asyncNotify_4expose(const std::string& key, \ GEventAsyncStrategy strategy = GEventAsyncStrategy::PIPELINE_RUN_FINISH) { \ return asyncNotify(key, strategy); \ } \ diff --git a/src/GraphCtrl/GraphMessage/GMessageDefine.h b/src/GraphCtrl/GraphMessage/GMessageDefine.h index 17796c30..79821381 100644 --- a/src/GraphCtrl/GraphMessage/GMessageDefine.h +++ b/src/GraphCtrl/GraphMessage/GMessageDefine.h @@ -16,8 +16,8 @@ CGRAPH_NAMESPACE_BEGIN using GMessagePushStrategy = URingBufferPushStrategy; CGRAPH_INTERNAL_NAMESPACE_BEGIN -static const char* PUB_SUB_PREFIX = "PS_PRE_"; -static const char* SEND_RECV_PREFIX = "SR_PRE_"; +static auto PUB_SUB_PREFIX = "PS_PRE_"; +static auto SEND_RECV_PREFIX = "SR_PRE_"; CGRAPH_INTERNAL_NAMESPACE_END CGRAPH_NAMESPACE_END diff --git a/src/GraphCtrl/GraphParam/GParamManager.cpp b/src/GraphCtrl/GraphParam/GParamManager.cpp index 9fe40ab7..ca7f7515 100644 --- a/src/GraphCtrl/GraphParam/GParamManager.cpp +++ b/src/GraphCtrl/GraphParam/GParamManager.cpp @@ -102,7 +102,7 @@ std::vector GParamManager::getKeys() { } -CStatus GParamManager::__create_4py(GParamPtr param, const std::string& key) { +CStatus GParamManager::__create_4expose(GParamPtr param, const std::string& key) { CGRAPH_FUNCTION_BEGIN CGRAPH_LOCK_GUARD lock(this->mutex_); const auto& iter = params_map_.find(key); @@ -115,7 +115,7 @@ CStatus GParamManager::__create_4py(GParamPtr param, const std::string& key) { } -GParamPtr GParamManager::__get_4py(const std::string& key) { +GParamPtr GParamManager::__get_4expose(const std::string& key) { const auto& iter = params_map_.find(key); if (iter == params_map_.end()) { return nullptr; @@ -125,7 +125,7 @@ GParamPtr GParamManager::__get_4py(const std::string& key) { } -CStatus GParamManager::__remove_4py(const std::string& key) { +CStatus GParamManager::__remove_4expose(const std::string& key) { CGRAPH_FUNCTION_BEGIN CGRAPH_LOCK_GUARD lock(this->mutex_); const auto& iter = params_map_.find(key); @@ -139,7 +139,7 @@ CStatus GParamManager::__remove_4py(const std::string& key) { } -CBool GParamManager::__has_4py(const std::string& key) { +CBool GParamManager::__has_4expose(const std::string& key) { CGRAPH_LOCK_GUARD lock(this->mutex_); return params_map_.find(key) != params_map_.end(); } diff --git a/src/GraphCtrl/GraphParam/GParamManager.h b/src/GraphCtrl/GraphParam/GParamManager.h index c49c00d7..b5bfaa95 100644 --- a/src/GraphCtrl/GraphParam/GParamManager.h +++ b/src/GraphCtrl/GraphParam/GParamManager.h @@ -87,10 +87,10 @@ class GParamManager : public GParamObject, public: /// 为 python 版本设定的函数,cpp 的童鞋不需要使用 - CStatus __create_4py(GParamPtr param, const std::string& key); - GParamPtr __get_4py(const std::string& key); - CStatus __remove_4py(const std::string& key); - CBool __has_4py(const std::string& key); + CStatus __create_4expose(GParamPtr param, const std::string& key); + GParamPtr __get_4expose(const std::string& key); + CStatus __remove_4expose(const std::string& key); + CBool __has_4expose(const std::string& key); }; using GParamManagerPtr = GParamManager *; diff --git a/src/GraphCtrl/GraphParam/GParamManagerWrapper.h b/src/GraphCtrl/GraphParam/GParamManagerWrapper.h index a2298bf4..73093acb 100644 --- a/src/GraphCtrl/GraphParam/GParamManagerWrapper.h +++ b/src/GraphCtrl/GraphParam/GParamManagerWrapper.h @@ -79,30 +79,30 @@ CGRAPH_NAMESPACE_BEGIN return param_manager_->getKeys(); \ } \ \ -public: \ - GParamPtr __getGParam_4py(const std::string& key) { \ - return param_manager_ ? param_manager_->__get_4py(key) : nullptr; \ +CGRAPH_INTERNAL_ACCESS: \ + GParamPtr __getGParam_4expose(const std::string& key) { \ + return param_manager_ ? param_manager_->__get_4expose(key) : nullptr; \ } \ \ - GParamPtr __getGParamWithNoEmpty_4py(const std::string& key) { \ + GParamPtr __getGParamWithNoEmpty_4expose(const std::string& key) { \ CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(param_manager_); \ - auto param = param_manager_->__get_4py(key); \ + auto param = param_manager_->__get_4expose(key); \ CGRAPH_THROW_EXCEPTION_BY_CONDITION(!param, "param [" + key + "] is null"); \ return param; \ } \ \ - CStatus __createGParam_4py(GParamPtr param, const std::string& key) { \ + CStatus __createGParam_4expose(GParamPtr param, const std::string& key) { \ CGRAPH_ASSERT_NOT_NULL(param_manager_) \ - return param_manager_->__create_4py(param, key); \ + return param_manager_->__create_4expose(param, key); \ } \ \ - CStatus __removeGParam_4py(const std::string& key) { \ + CStatus __removeGParam_4expose(const std::string& key) { \ CGRAPH_ASSERT_NOT_NULL(param_manager_) \ - return param_manager_->__remove_4py(key); \ + return param_manager_->__remove_4expose(key); \ } \ \ - CBool __hasGParam_4py(const std::string& key) { \ - return param_manager_ ? param_manager_->__has_4py(key) : false; \ + CBool __hasGParam_4expose(const std::string& key) { \ + return param_manager_ ? param_manager_->__has_4expose(key) : false; \ } \ \ private: \ diff --git a/src/GraphCtrl/GraphParam/GParamUtils.h b/src/GraphCtrl/GraphParam/GParamUtils.h index d48ea572..771cfc7b 100644 --- a/src/GraphCtrl/GraphParam/GParamUtils.h +++ b/src/GraphCtrl/GraphParam/GParamUtils.h @@ -46,7 +46,7 @@ CGRAPH_NAMESPACE_BEGIN #if __cplusplus >= 201703L #define CGRAPH_PARAM_SCOPED_CODE_BLOCK(p1, p2) \ std::scoped_lock __paramSLock__((p1)->_param_shared_lock_, \ - (p2)->_param_shared_lock_); \ + (p2)->_param_shared_lock_); \ #endif diff --git a/src/GraphCtrl/GraphPipeline/GPipeline.cpp b/src/GraphCtrl/GraphPipeline/GPipeline.cpp index 938c6c97..e1acdfcd 100644 --- a/src/GraphCtrl/GraphPipeline/GPipeline.cpp +++ b/src/GraphCtrl/GraphPipeline/GPipeline.cpp @@ -396,24 +396,24 @@ CStatus GPipeline::innerRegister(GElementPtr element, const GElementPtrSet &depe } -CStatus GPipeline::__registerGElement_4py(CGraph::GElementPtr element, const CGraph::GElementPtrSet &depends, +CStatus GPipeline::__registerGElement_4expose(CGraph::GElementPtr element, const CGraph::GElementPtrSet &depends, const std::string &name, CSize loop) { return innerRegister(element, depends, name, loop); } -GPipelinePtr GPipeline::__addGEvent_4py(GEventPtr event, const std::string& key) { +GPipelinePtr GPipeline::__addGEvent_4expose(GEventPtr event, const std::string& key) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(event, event_manager_, param_manager_) event_manager_->param_manager_ = this->param_manager_; - status = event_manager_->__create_4py(event, key); + status = event_manager_->__create_4expose(event, key); CGRAPH_THROW_EXCEPTION_BY_STATUS(status) return this; } -GPipelinePtr GPipeline::__addGDaemon_4py(GDaemonPtr daemon, CMSec ms) { +GPipelinePtr GPipeline::__addGDaemon_4expose(GDaemonPtr daemon, CMSec ms) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(daemon, param_manager_, event_manager_, daemon_manager_) daemon->setGParamManager(this->param_manager_); @@ -425,16 +425,16 @@ GPipelinePtr GPipeline::__addGDaemon_4py(GDaemonPtr daemon, CMSec ms) { } -GPipelinePtr GPipeline::__addGStage_4py(GStagePtr stage, const std::string& key, CInt threshold) { +GPipelinePtr GPipeline::__addGStage_4expose(GStagePtr stage, const std::string& key, CInt threshold) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(stage, param_manager_, stage_manager_) stage_manager_->setGParamManager(param_manager_); - stage_manager_->__create_4py(stage, key, threshold); + stage_manager_->__create_4expose(stage, key, threshold); return this; } -std::string GPipeline::__dump_4py() { +std::string GPipeline::__dump_4expose() { std::ostringstream oss; auto status = this->dump(oss); CGRAPH_THROW_EXCEPTION_BY_STATUS(status); @@ -442,7 +442,7 @@ std::string GPipeline::__dump_4py() { } -std::string GPipeline::__perf_4py() { +std::string GPipeline::__perf_4expose() { std::ostringstream oss; auto status = this->perf(oss); CGRAPH_THROW_EXCEPTION_BY_STATUS(status); diff --git a/src/GraphCtrl/GraphPipeline/GPipeline.h b/src/GraphCtrl/GraphPipeline/GPipeline.h index 494b9c26..4bf748d1 100644 --- a/src/GraphCtrl/GraphPipeline/GPipeline.h +++ b/src/GraphCtrl/GraphPipeline/GPipeline.h @@ -455,14 +455,14 @@ class GPipeline : public GPipelineObject, friend class GPerf; friend class GStorage; -public: - CStatus __registerGElement_4py(GElementPtr element, const GElementPtrSet &depends, +CGRAPH_INTERNAL_ACCESS: + CStatus __registerGElement_4expose(GElementPtr element, const GElementPtrSet &depends, const std::string &name, CSize loop); - GPipeline* __addGEvent_4py(GEventPtr event, const std::string& key); - GPipeline* __addGDaemon_4py(GDaemonPtr daemon, CMSec ms); - GPipeline* __addGStage_4py(GStagePtr stage, const std::string& key, CInt threshold); - std::string __dump_4py(); - std::string __perf_4py(); + GPipeline* __addGEvent_4expose(GEventPtr event, const std::string& key); + GPipeline* __addGDaemon_4expose(GDaemonPtr daemon, CMSec ms); + GPipeline* __addGStage_4expose(GStagePtr stage, const std::string& key, CInt threshold); + std::string __dump_4expose(); + std::string __perf_4expose(); }; using GPipelinePtr = GPipeline *; diff --git a/src/GraphCtrl/GraphStage/GStageManager.h b/src/GraphCtrl/GraphStage/GStageManager.h index 911ce4d1..08a550d0 100644 --- a/src/GraphCtrl/GraphStage/GStageManager.h +++ b/src/GraphCtrl/GraphStage/GStageManager.h @@ -96,7 +96,7 @@ class GStageManager : public GStageObject, friend class GStorage; private: - CStatus __create_4py(GStagePtr stage, const std::string& key, CInt threshold) { + CStatus __create_4expose(GStagePtr stage, const std::string& key, CInt threshold) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_NOT_NULL(stage) CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(stage_map_.find(key) != stage_map_.end(), diff --git a/src/UtilsCtrl/UtilsDefine.h b/src/UtilsCtrl/UtilsDefine.h index c598ad9f..b1290214 100644 --- a/src/UtilsCtrl/UtilsDefine.h +++ b/src/UtilsCtrl/UtilsDefine.h @@ -43,6 +43,11 @@ using CGRAPH_UNIQUE_LOCK = std::unique_lock; using CGRAPH_WRITE_LOCK = std::lock_guard; #endif +#ifdef CGRAPH_EXPOSE_INTERNALS + #define CGRAPH_INTERNAL_ACCESS public +#else + #define CGRAPH_INTERNAL_ACCESS private +#endif #define __IS_NULLPTR(t) (unlikely(std::is_pointer::value && !(t))) diff --git a/tutorial/MyGNode/MyStageNode.h b/tutorial/MyGNode/MyStageNode.h index e463c237..e01514fb 100644 --- a/tutorial/MyGNode/MyStageNode.h +++ b/tutorial/MyGNode/MyStageNode.h @@ -11,10 +11,11 @@ #include "CGraph.h" -const static char* kStageKey = "stage"; +static auto kStageKey = "stage"; template class MyStageNode : public CGraph::GNode { +public: CStatus run() override { CGRAPH_SLEEP_SECOND(before); CGraph::CGRAPH_ECHO("[%s] wait for stage", getName().c_str());