diff --git a/src/Engine/Operator/OperatorTable.cpp b/src/Engine/Operator/OperatorTable.cpp index cbff63a..0f0df41 100644 --- a/src/Engine/Operator/OperatorTable.cpp +++ b/src/Engine/Operator/OperatorTable.cpp @@ -6,12 +6,19 @@ void enzo::op::OperatorTable::addOperator(const char* internalName, const char* { std::cout << "OPERATOR TABLE ADDED\n"; std::cout << "adding operator: " << displayName << "\n"; - ctorStore_.push_back(ctorFunc); + opInfoStore_.push_back({internalName, displayName, ctorFunc}); } -enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(size_t pos) +enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(std::string name) { - return ctorStore_.at(pos); + for(auto it = opInfoStore_.begin(); it!=opInfoStore_.end(); ++it) + { + if(it->internalName==name) + { + return it->ctorFunc; + } + } + return nullptr; } -std::vector enzo::op::OperatorTable::ctorStore_; +std::vector enzo::op::OperatorTable::opInfoStore_; diff --git a/src/Engine/Operator/OperatorTable.h b/src/Engine/Operator/OperatorTable.h index 1ed6949..2fd4670 100644 --- a/src/Engine/Operator/OperatorTable.h +++ b/src/Engine/Operator/OperatorTable.h @@ -4,15 +4,23 @@ #include "Engine/Network/NetworkManager.h" #include "Engine/Operator/GeometryOpDef.h" + namespace enzo::op { +struct OpInfo +{ + std::string internalName; + std::string displayName; + enzo::nt::opConstructor ctorFunc; +}; + class BOOST_SYMBOL_EXPORT OperatorTable { public: static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc); - static nt::opConstructor getOpConstructor(size_t pos); + static nt::opConstructor getOpConstructor(std::string name); private: - static std::vector ctorStore_; + static std::vector opInfoStore_; }; using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc); } diff --git a/src/Gui/Network/Network.cpp b/src/Gui/Network/Network.cpp index b937841..ee27604 100644 --- a/src/Gui/Network/Network.cpp +++ b/src/Gui/Network/Network.cpp @@ -314,7 +314,7 @@ void Network::keyPressEvent(QKeyEvent *event) } case(Qt::Key_G): { - if(auto newNode = createNode(op::OperatorTable::getOpConstructor(1))) + if(auto newNode = createNode(op::OperatorTable::getOpConstructor("transform"))) { newNode->setPos(viewPos); } @@ -323,7 +323,7 @@ void Network::keyPressEvent(QKeyEvent *event) } case(Qt::Key_F): { - if(auto newNode = createNode(op::OperatorTable::getOpConstructor(0))) + if(auto newNode = createNode(op::OperatorTable::getOpConstructor("house"))) { newNode->setPos(viewPos); }