feat: pass node info with template
This commit is contained in:
@@ -23,8 +23,8 @@ void enzo::nt::connectOperators(enzo::nt::OpId inputOpId, unsigned int inputInde
|
||||
outputOp.addInputConnection(newConnection);
|
||||
}
|
||||
|
||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, nt::opConstructor ctorFunc)
|
||||
: opId_{opId}, opDef_(ctorFunc(opId))
|
||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo)
|
||||
: opId_{opId}, opDef_(opinfo.ctorFunc(opId))
|
||||
{
|
||||
// TODO: drive by geometry definition
|
||||
maxInputs_=4;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "Engine/Operator/GeometryConnection.h"
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Types.h"
|
||||
#include <optional>
|
||||
@@ -11,7 +12,7 @@ void connectOperators(enzo::nt::OpId inputOpId, unsigned int inputIndex, enzo::n
|
||||
class GeometryOperator
|
||||
{
|
||||
public:
|
||||
GeometryOperator(enzo::nt::OpId opId, nt::opConstructor ctorFunc);
|
||||
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo);
|
||||
|
||||
// disable copying
|
||||
GeometryOperator(const GeometryOperator&) = delete;
|
||||
|
||||
15
src/Engine/Operator/OpInfo.h
Normal file
15
src/Engine/Operator/OpInfo.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Parameter/Template.h"
|
||||
|
||||
namespace enzo::op
|
||||
{
|
||||
struct OpInfo
|
||||
{
|
||||
std::string internalName;
|
||||
std::string displayName;
|
||||
enzo::nt::opConstructor ctorFunc;
|
||||
enzo::prm::Template* templates;
|
||||
};
|
||||
}
|
||||
@@ -3,11 +3,18 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templateList[])
|
||||
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates)
|
||||
{
|
||||
std::cout << "OPERATOR TABLE ADDED\n";
|
||||
std::cout << "adding operator: " << displayName << "\n";
|
||||
opInfoStore_.push_back({internalName, displayName, ctorFunc});
|
||||
enzo::op::OpInfo info {
|
||||
internalName,
|
||||
displayName,
|
||||
ctorFunc,
|
||||
templates
|
||||
};
|
||||
|
||||
opInfoStore_.push_back(info);
|
||||
}
|
||||
|
||||
enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(std::string name)
|
||||
@@ -22,6 +29,18 @@ enzo::nt::opConstructor enzo::op::OperatorTable::getOpConstructor(std::string na
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::optional<enzo::op::OpInfo> enzo::op::OperatorTable::getOpInfo(std::string name)
|
||||
{
|
||||
for(auto it = opInfoStore_.begin(); it!=opInfoStore_.end(); ++it)
|
||||
{
|
||||
if(it->internalName==name)
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
|
||||
{
|
||||
return opInfoStore_;
|
||||
|
||||
@@ -3,29 +3,25 @@
|
||||
#include <boost/config.hpp>
|
||||
#include "Engine/Network/NetworkManager.h"
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include "Engine/Parameter/Template.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, prm::Template templateList[]);
|
||||
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates);
|
||||
static nt::opConstructor getOpConstructor(std::string name);
|
||||
static const std::optional<op::OpInfo> getOpInfo(std::string name);
|
||||
static std::vector<OpInfo> getData();
|
||||
// TODO: move to better spot (maybe engine class)
|
||||
static void initPlugins();
|
||||
private:
|
||||
static std::vector<OpInfo> opInfoStore_;
|
||||
};
|
||||
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templateList[]);
|
||||
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templateList);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user