feat: working parameter creation
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "Engine/Network/NetworkManager.h"
|
||||
#include <optional>
|
||||
#include "Engine/Operator/Context.h"
|
||||
#include "Engine/Parameter/Parameter.h"
|
||||
#include "Engine/Parameter/Template.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace enzo;
|
||||
@@ -23,12 +25,27 @@ void enzo::nt::connectOperators(enzo::nt::OpId inputOpId, unsigned int inputInde
|
||||
outputOp.addInputConnection(newConnection);
|
||||
}
|
||||
|
||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo)
|
||||
: opId_{opId}, opDef_(opinfo.ctorFunc(opId))
|
||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo)
|
||||
: opId_{opId}, opInfo_{opInfo}, opDef_(opInfo.ctorFunc(opId))
|
||||
{
|
||||
// TODO: drive by geometry definition
|
||||
maxInputs_=4;
|
||||
maxOutputs_=4;
|
||||
|
||||
initParameters();
|
||||
}
|
||||
|
||||
void nt::GeometryOperator::initParameters()
|
||||
{
|
||||
for(const prm::Template* t = opInfo_.templates; t->isValid(); ++t)
|
||||
{
|
||||
std::cout << "name: " << t->getName() << "\n";
|
||||
// create parameter
|
||||
parameters_.push_back(
|
||||
std::make_shared<prm::Parameter>(*t)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Engine/Operator/GeometryConnection.h"
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Parameter/Parameter.h"
|
||||
#include "Engine/Types.h"
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
@@ -12,7 +13,7 @@ void connectOperators(enzo::nt::OpId inputOpId, unsigned int inputIndex, enzo::n
|
||||
class GeometryOperator
|
||||
{
|
||||
public:
|
||||
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo);
|
||||
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo);
|
||||
|
||||
// disable copying
|
||||
GeometryOperator(const GeometryOperator&) = delete;
|
||||
@@ -33,12 +34,16 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
void initParameters();
|
||||
|
||||
// TODO: avoid duplicate connections
|
||||
std::vector<std::shared_ptr<nt::GeometryConnection>> inputConnections_;
|
||||
std::vector<std::shared_ptr<nt::GeometryConnection>> outputConnections_;
|
||||
std::vector<std::shared_ptr<prm::Parameter>> parameters_;
|
||||
unsigned int maxInputs_;
|
||||
unsigned int maxOutputs_;
|
||||
std::unique_ptr<enzo::nt::GeometryOpDef> opDef_;
|
||||
enzo::nt::OpId opId_;
|
||||
enzo::op::OpInfo opInfo_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@ struct OpInfo
|
||||
std::string displayName;
|
||||
enzo::nt::opConstructor ctorFunc;
|
||||
enzo::prm::Template* templates;
|
||||
size_t templatesSize;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates)
|
||||
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";
|
||||
std::cout << "tempalate size: " << sizeof(templates) << "\n";
|
||||
enzo::op::OpInfo info {
|
||||
internalName,
|
||||
displayName,
|
||||
ctorFunc,
|
||||
templates
|
||||
templates,
|
||||
sizeof(*templates)
|
||||
};
|
||||
|
||||
opInfoStore_.push_back(info);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace enzo::op
|
||||
class BOOST_SYMBOL_EXPORT OperatorTable
|
||||
{
|
||||
public:
|
||||
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates);
|
||||
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();
|
||||
@@ -22,6 +22,6 @@ public:
|
||||
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