feat(opTable): store op info in table, convert table pos getter to name getter
This commit is contained in:
@@ -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::nt::opConstructor> enzo::op::OperatorTable::ctorStore_;
|
||||
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_;
|
||||
|
||||
@@ -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<nt::opConstructor> ctorStore_;
|
||||
static std::vector<OpInfo> opInfoStore_;
|
||||
};
|
||||
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user