From 34a1df859aa50d414925be300f52afb168fa25dc Mon Sep 17 00:00:00 2001 From: parker Date: Sun, 13 Jul 2025 17:39:52 +0100 Subject: [PATCH] feat: working operatorDef transfer --- src/Engine/Operator/OperatorTable.cpp | 2 ++ src/Engine/Operator/OperatorTable.h | 5 +++-- src/OpDefs/main.cpp | 4 ++-- tests/main-tests.cpp | 6 ++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Engine/Operator/OperatorTable.cpp b/src/Engine/Operator/OperatorTable.cpp index e3ef910..043663a 100644 --- a/src/Engine/Operator/OperatorTable.cpp +++ b/src/Engine/Operator/OperatorTable.cpp @@ -8,3 +8,5 @@ void enzo::op::OperatorTable::addOperator(nt::opConstructor ctorFunc) // ctorFunc(5); ctorStore_.push_back(ctorFunc); } + +std::vector enzo::op::OperatorTable::ctorStore_; diff --git a/src/Engine/Operator/OperatorTable.h b/src/Engine/Operator/OperatorTable.h index 26292a7..f8fbc5e 100644 --- a/src/Engine/Operator/OperatorTable.h +++ b/src/Engine/Operator/OperatorTable.h @@ -8,8 +8,9 @@ namespace enzo::op class BOOST_SYMBOL_EXPORT OperatorTable { public: - void addOperator(nt::opConstructor ctorFunc); + static void addOperator(nt::opConstructor ctorFunc); private: - std::vector ctorStore_; + static std::vector ctorStore_; }; } + diff --git a/src/OpDefs/main.cpp b/src/OpDefs/main.cpp index beab512..228d841 100644 --- a/src/OpDefs/main.cpp +++ b/src/OpDefs/main.cpp @@ -8,9 +8,9 @@ extern "C" { BOOST_SYMBOL_EXPORT std::string myVar = "hello world"; - BOOST_SYMBOL_EXPORT void newSopOperator(enzo::op::OperatorTable* table) + BOOST_SYMBOL_EXPORT void newSopOperator(void (*addOperator)(enzo::nt::opConstructor)) { - table->addOperator( + addOperator( &GopTransform::ctor ); } diff --git a/tests/main-tests.cpp b/tests/main-tests.cpp index 8af8c51..2e3260f 100644 --- a/tests/main-tests.cpp +++ b/tests/main-tests.cpp @@ -2,6 +2,8 @@ #include #include #include +#include "Engine/Network/NetworkManager.h" +#include "Engine/Operator/OperatorTable.h" TEST_CASE("foo") { @@ -33,10 +35,10 @@ TEST_CASE("boost dll") ); std::cout << "VAR: " << *cpp_var << "\n"; - auto cpp11_func = boost::dll::import_symbol( + auto cpp11_func = boost::dll::import_symbol( "build/src/OpDefs/libenzoOps1.so", "newSopOperator" ); - cpp11_func(5); + cpp11_func(enzo::op::OperatorTable::addOperator); }