GeezerVison is showing github.com — [bugfix] fix python version GGroup no isHold and so on function bug · feiyunwill/CGraph@778e4cd
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: python/PyCGraph.cpp +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -286,21 +286,23 @@ PYBIND11_MODULE(PyCGraph, m) { | 286 | 286 | py::arg("name") = CGRAPH_EMPTY, | 287 | 287 | py::arg("loop") = CGRAPH_DEFAULT_LOOP_TIMES); | 288 | 288 |
| 289 | | - py::class_<PyGCluster, GElement, std::unique_ptr<PyGCluster, py::nodelete> >(m, "GCluster") | | 289 | + py::class_<PywGCluster, GElement, std::unique_ptr<PywGCluster, py::nodelete> >(m, "GCluster") | 290 | 290 | .def(py::init<const GElementPtrArr&>(), | 291 | 291 | py::arg("elements") = GElementPtrArr{}, | 292 | 292 | py::keep_alive<1, 2>()) | 293 | | - .def("addGElements", &PyGCluster::__addGElements_4py, | | 293 | + .def("addGElements", &PywGCluster::__addGElements_4py, | 294 | 294 | py::arg("elements"), | 295 | 295 | py::keep_alive<1, 2>()); | | 296 | + PYCGRAPH_DECLARE_GGROUP_PYBIND11_FUNCTIONS(GClusterInterface); | 296 | 297 |
| 297 | | - py::class_<PyGRegion, GElement, std::unique_ptr<PyGRegion, py::nodelete> >(m, "GRegion") | | 298 | + py::class_<PywGRegion, GElement, std::unique_ptr<PywGRegion, py::nodelete> >(m, "GRegion") | 298 | 299 | .def(py::init<const GElementPtrArr&>(), | 299 | 300 | py::arg("elements") = GElementPtrArr{}, | 300 | 301 | py::keep_alive<1, 2>()) | 301 | | - .def("addGElements", &PyGRegion::__addGElements_4py, | | 302 | + .def("addGElements", &PywGRegion::__addGElements_4py, | 302 | 303 | py::arg("elements"), | 303 | 304 | py::keep_alive<1, 2>()); | | 305 | + PYCGRAPH_DECLARE_GGROUP_PYBIND11_FUNCTIONS(GRegionInterface); | 304 | 306 |
| 305 | 307 | py::class_<PywGCondition, GElement, std::unique_ptr<PywGCondition, py::nodelete> >(m, "GCondition") | 306 | 308 | .def(py::init<const GElementPtrArr&>(), | @@ -310,6 +312,7 @@ PYBIND11_MODULE(PyCGraph, m) { | 310 | 312 | .def("addGElements", &PywGCondition::__addGElements_4py, | 311 | 313 | py::arg("elements"), | 312 | 314 | py::keep_alive<1, 2>()); | | 315 | + PYCGRAPH_DECLARE_GGROUP_PYBIND11_FUNCTIONS(GConditionInterface); | 313 | 316 |
| 314 | 317 | py::class_<PyGMultiCondition<GMultiConditionType::SERIAL>, | 315 | 318 | GElement, std::unique_ptr<PyGMultiCondition<GMultiConditionType::SERIAL>, | |
Collapse file Copy file name to clipboardExpand all lines: python/tutorial/MyGNode/MyHoldNode.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,4 +24,4 @@ def run(self): | 24 | 24 | def isHold(self): | 25 | 25 | param: MyParam = self.getGParam(self._param_key) | 26 | 26 | print('enter hold path, value is {0}'.format(param.value)) | 27 | | - return param.value < 5 | | 27 | + return param.value < 3 |
Collapse file Copy file name to clipboardExpand all lines: python/wrapper/PyGCluster.h -23Lines changed: 0 additions & 23 deletions Collapse file Copy file name to clipboardExpand all lines: python/wrapper/PyGRegion.h -23Lines changed: 0 additions & 23 deletions Collapse file Copy file name to clipboard +57Lines changed: 57 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/*************************** | | 2 | +@Author: Chunel | | 3 | + | | 4 | +@File: PyWrapperDefine.h | | 5 | +@Time: 2025/4/6 14:48 | | 6 | +@Desc: | | 7 | +***************************/ | | 8 | + | | 9 | +#ifndef CGRAPH_PYWRAPPERDEFINE_H | | 10 | +#define CGRAPH_PYWRAPPERDEFINE_H | | 11 | + | | 12 | +#include <pybind11/pybind11.h> | | 13 | + | | 14 | +#include "CGraph.h" | | 15 | + | | 16 | +#define PYCGRAPH_DECLARE_GELEMENT_COMMON_FUNCTIONS(PCGE) \ | | 17 | + CBool isHold() override { \ | | 18 | + PYBIND11_OVERLOAD(CBool, PCGE, isHold); \ | | 19 | + } \ | | 20 | + \ | | 21 | + CBool isMatch() override { \ | | 22 | + PYBIND11_OVERLOAD(CBool, PCGE, isMatch); \ | | 23 | + } \ | | 24 | + \ | | 25 | + CStatus prepareRun() override { \ | | 26 | + PYBIND11_OVERLOAD(CStatus, PCGE, prepareRun); \ | | 27 | + } \ | | 28 | + \ | | 29 | + CStatus checkRunResult() override { \ | | 30 | + PYBIND11_OVERLOAD(CStatus, PCGE, checkRunResult); \ | | 31 | + } \ | | 32 | + \ | | 33 | + | | 34 | + | | 35 | +#define PYCGRAPH_DECLARE_GGROUP_INTERFACE_CLASS(PCGG, PVFunc) \ | | 36 | +class PCGG##Interface : public PCGG { \ | | 37 | +public: \ | | 38 | + explicit PCGG##Interface(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) : PCGG(elements) {}; \ | | 39 | + ~PCGG##Interface() override = default; \ | | 40 | +protected: \ | | 41 | + PYCGRAPH_DECLARE_GELEMENT_COMMON_FUNCTIONS(PCGG##Interface) \ | | 42 | + PVFunc \ | | 43 | +}; \ | | 44 | + \ | | 45 | + | | 46 | + | | 47 | +#define PYCGRAPH_DECLARE_GGROUP_PYBIND11_FUNCTIONS(PCGG) \ | | 48 | + py::class_<Pyw##PCGG, GElement, std::unique_ptr<Pyw##PCGG, py::nodelete> >(m, #PCGG) \ | | 49 | + .def(py::init<const GElementPtrArr&>(), \ | | 50 | + py::arg("elements") = GElementPtrArr{}, \ | | 51 | + py::keep_alive<1, 2>()) \ | | 52 | + .def("addGElements", &Pyw##PCGG::__addGElements_4py, \ | | 53 | + py::arg("elements"), \ | | 54 | + py::keep_alive<1, 2>()) \ | | 55 | + \ | | 56 | + | | 57 | +#endif //CGRAPH_PYWRAPPERDEFINE_H |
Collapse file Copy file name to clipboardExpand all lines: python/wrapper/PyWrapperInclude.h +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | #define CGRAPH_PYWRAPPERINCLUDE_H | 11 | 11 |
| 12 | 12 | #include "PyGPipeline.h" | | 13 | +#include "PyGMultiCondition.h" | 13 | 14 | #include "PywGElement.h" | 14 | 15 | #include "PywGNode.h" | 15 | | -#include "PyGCluster.h" | 16 | | -#include "PyGRegion.h" | | 16 | +#include "PywGCluster.h" | | 17 | +#include "PywGRegion.h" | 17 | 18 | #include "PywGCondition.h" | 18 | | -#include "PyGMultiCondition.h" | 19 | 19 | #include "PywGParam.h" | 20 | 20 | #include "PywGAspect.h" | 21 | 21 | #include "PywGEvent.h" | |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/*************************** | | 2 | +@Author: Chunel | | 3 | + | | 4 | +@File: PywGCluster.h | | 5 | +@Time: 2025/4/6 19:00 | | 6 | +@Desc: | | 7 | +***************************/ | | 8 | + | | 9 | +#ifndef CGRAPH_PYWGCLUSTER_H | | 10 | +#define CGRAPH_PYWGCLUSTER_H | | 11 | + | | 12 | +#include "CGraph.h" | | 13 | +#include "PyWrapperDefine.h" | | 14 | + | | 15 | +class PywGCluster : public CGraph::GCluster { | | 16 | +public: | | 17 | + explicit PywGCluster(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { | | 18 | + __addGElements_4py(elements); | | 19 | + } | | 20 | + | | 21 | + ~PywGCluster() override = default; | | 22 | +}; | | 23 | + | | 24 | +PYCGRAPH_DECLARE_GGROUP_INTERFACE_CLASS(PywGCluster, ;); | | 25 | + | | 26 | +#endif //CGRAPH_PYWGCLUSTER_H |
Collapse file Copy file name to clipboardExpand all lines: python/wrapper/PywGCondition.h +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | #include <pybind11/pybind11.h> | 13 | 13 |
| 14 | 14 | #include "CGraph.h" | | 15 | +#include "PyWrapperDefine.h" | 15 | 16 |
| 16 | 17 | class PywGCondition : public CGraph::GCondition { | 17 | 18 | public: | @@ -25,4 +26,9 @@ class PywGCondition : public CGraph::GCondition { | 25 | 26 | } | 26 | 27 | }; | 27 | 28 |
| | 29 | +PYCGRAPH_DECLARE_GGROUP_INTERFACE_CLASS(PywGCondition, | | 30 | + CIndex choose() override { | | 31 | + PYBIND11_OVERLOAD_PURE(CIndex, PywGConditionInterface, choose); | | 32 | + }); | | 33 | + | 28 | 34 | #endif //CGRAPH_PYWGCONDITION_H |
Collapse file Copy file name to clipboardExpand all lines: python/wrapper/PywGNode.h +2-15Lines changed: 2 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | #include <pybind11/pybind11.h> | 13 | 13 |
| 14 | 14 | #include "CGraph.h" | | 15 | +#include "PyWrapperDefine.h" | 15 | 16 |
| 16 | 17 | class PywGNode : public CGraph::GNode { | 17 | 18 | public: | @@ -44,21 +45,7 @@ class PywGNode : public CGraph::GNode { | 44 | 45 | PYBIND11_OVERLOAD(CStatus, GNode, destroy); | 45 | 46 | } | 46 | 47 |
| 47 | | - CBool isHold() override { | 48 | | - PYBIND11_OVERLOAD(CBool, GNode, isHold); | 49 | | - } | 50 | | - | 51 | | - CBool isMatch() override { | 52 | | - PYBIND11_OVERLOAD(CBool, GNode, isMatch); | 53 | | - } | 54 | | - | 55 | | - CStatus prepareRun() override { | 56 | | - PYBIND11_OVERLOAD(CStatus, GNode, prepareRun); | 57 | | - } | 58 | | - | 59 | | - CStatus checkRunResult() override { | 60 | | - PYBIND11_OVERLOAD(CStatus, GNode, checkRunResult); | 61 | | - } | | 48 | + PYCGRAPH_DECLARE_GELEMENT_COMMON_FUNCTIONS(CGraph::GNode) | 62 | 49 | }; | 63 | 50 |
| 64 | 51 | #endif //CGRAPH_PYWGNODE_H |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/*************************** | | 2 | +@Author: Chunel | | 3 | + | | 4 | +@File: PywGRegion.h | | 5 | +@Time: 2025/4/6 19:03 | | 6 | +@Desc: | | 7 | +***************************/ | | 8 | + | | 9 | +#ifndef CGRAPH_PYWGREGION_H | | 10 | +#define CGRAPH_PYWGREGION_H | | 11 | + | | 12 | +#include "CGraph.h" | | 13 | +#include "PyWrapperDefine.h" | | 14 | + | | 15 | +class PywGRegion : public CGraph::GRegion { | | 16 | +public: | | 17 | + explicit PywGRegion(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) { | | 18 | + __addGElements_4py(elements); | | 19 | + }; | | 20 | + | | 21 | + ~PywGRegion() override = default; | | 22 | +}; | | 23 | + | | 24 | +PYCGRAPH_DECLARE_GGROUP_INTERFACE_CLASS(PywGRegion, ;); | | 25 | + | | 26 | +#endif //CGRAPH_PYWGREGION_H |
|