feat: variable socket counts
This commit is contained in:
@@ -13,35 +13,43 @@ bool enzo::nt::GeometryOpDef::outputRequested(unsigned int outputIndex)
|
||||
return true;
|
||||
}
|
||||
|
||||
const enzo::geo::Geometry& enzo::nt::GeometryOpDef::getInputGeoView(unsigned int inputIndex)
|
||||
{
|
||||
// TODO: implement
|
||||
return enzo::geo::Geometry();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void enzo::nt::GeometryOpDef::setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry)
|
||||
{
|
||||
if(outputIndex>maxOutputs_)
|
||||
if(outputIndex>getMaxOutputs())
|
||||
{
|
||||
throw std::runtime_error("Cannot set output geometry to index > maxOutputs");
|
||||
}
|
||||
outputGeometry_[outputIndex] = geometry;
|
||||
}
|
||||
|
||||
enzo::nt::GeometryOpDef::GeometryOpDef(enzo::nt::OpId opId)
|
||||
: opId_{opId}
|
||||
unsigned int enzo::nt::GeometryOpDef::getMinInputs() const
|
||||
{
|
||||
minInputs_=1;
|
||||
maxInputs_=4;
|
||||
maxOutputs_=4;
|
||||
outputGeometry_ = std::vector<enzo::geo::Geometry>(4, enzo::geo::Geometry());
|
||||
return opInfo_.minInputs;
|
||||
|
||||
}
|
||||
|
||||
unsigned int enzo::nt::GeometryOpDef::getMaxInputs() const
|
||||
{
|
||||
return opInfo_.maxInputs;
|
||||
}
|
||||
|
||||
unsigned int enzo::nt::GeometryOpDef::getMaxOutputs() const
|
||||
{
|
||||
return opInfo_.maxOutputs;
|
||||
}
|
||||
|
||||
|
||||
enzo::nt::GeometryOpDef::GeometryOpDef(nt::NetworkManager* network, op::OpInfo opInfo)
|
||||
: opInfo_{opInfo}, network_{network}
|
||||
{
|
||||
outputGeometry_ = std::vector<enzo::geo::Geometry>(getMaxOutputs(), enzo::geo::Geometry());
|
||||
}
|
||||
|
||||
enzo::geo::Geometry& enzo::nt::GeometryOpDef::getOutputGeo(unsigned outputIndex)
|
||||
{
|
||||
if(outputIndex>maxOutputs_)
|
||||
if(outputIndex>getMaxOutputs())
|
||||
{
|
||||
throw std::runtime_error("Cannot set output geometry to index > maxOutputs");
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
#include "Engine/Operator/Context.h"
|
||||
#include "Engine/Types.h"
|
||||
#include <boost/config.hpp>
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
|
||||
|
||||
// forward declaration
|
||||
namespace enzo::nt {class NetworkManager;}
|
||||
|
||||
namespace enzo::nt
|
||||
{
|
||||
class NetworkManager;
|
||||
@@ -12,24 +16,25 @@ class NetworkManager;
|
||||
class BOOST_SYMBOL_EXPORT GeometryOpDef
|
||||
{
|
||||
public:
|
||||
GeometryOpDef(enzo::nt::OpId opId);
|
||||
GeometryOpDef(nt::NetworkManager* network, op::OpInfo opInfo);
|
||||
virtual void cookOp(op::Context context) = 0;
|
||||
geo::Geometry& getOutputGeo(unsigned outputIndex);
|
||||
|
||||
unsigned int getMinInputs() const;
|
||||
unsigned int getMaxInputs() const;
|
||||
unsigned int getMaxOutputs() const;
|
||||
private:
|
||||
std::vector<enzo::geo::Geometry> outputGeometry_;
|
||||
unsigned int minInputs_;
|
||||
unsigned int maxInputs_;
|
||||
unsigned int maxOutputs_;
|
||||
|
||||
protected:
|
||||
enzo::nt::OpId opId_;
|
||||
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex);
|
||||
const op::OpInfo opInfo_;
|
||||
nt::NetworkManager* network_;
|
||||
bool outputRequested(unsigned int outputIndex);
|
||||
|
||||
// TODO: std::move geometry instead of copying
|
||||
void setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry);
|
||||
};
|
||||
|
||||
using opConstructor = GeometryOpDef* (*)(enzo::nt::OpId);
|
||||
using opConstructor = GeometryOpDef* (*)(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,11 +27,8 @@ void enzo::nt::connectOperators(enzo::nt::OpId inputOpId, unsigned int inputInde
|
||||
}
|
||||
|
||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo)
|
||||
: opId_{opId}, opInfo_{opInfo}, opDef_(opInfo.ctorFunc(opId))
|
||||
: opId_{opId}, opInfo_{opInfo}, opDef_(opInfo.ctorFunc(&nt::nm(), opInfo))
|
||||
{
|
||||
// TODO: drive by geometry definition
|
||||
maxInputs_=4;
|
||||
maxOutputs_=4;
|
||||
|
||||
initParameters();
|
||||
}
|
||||
@@ -165,9 +162,13 @@ std::optional<const nt::GeometryConnection> nt::GeometryOperator::getInputConnec
|
||||
|
||||
unsigned int nt::GeometryOperator::getMaxInputs() const
|
||||
{
|
||||
return maxInputs_;
|
||||
return opDef_->getMaxInputs();
|
||||
}
|
||||
unsigned int nt::GeometryOperator::getMaxOutputs() const
|
||||
{
|
||||
return maxOutputs_;
|
||||
return opDef_->getMaxOutputs();
|
||||
}
|
||||
unsigned int nt::GeometryOperator::getMinInputs() const
|
||||
{
|
||||
return opDef_->getMinInputs();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
|
||||
|
||||
unsigned int getMaxInputs() const;
|
||||
unsigned int getMinInputs() const;
|
||||
unsigned int getMaxOutputs() const;
|
||||
|
||||
// signals
|
||||
@@ -50,8 +51,6 @@ private:
|
||||
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_;
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Parameter/Template.h"
|
||||
|
||||
// forward declaration
|
||||
namespace enzo::op
|
||||
{
|
||||
struct OpInfo;
|
||||
}
|
||||
namespace enzo::nt
|
||||
{
|
||||
class GeometryOpDef;
|
||||
class NetworkManager;
|
||||
using opConstructor = GeometryOpDef* (*)(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo);
|
||||
}
|
||||
|
||||
namespace enzo::op
|
||||
{
|
||||
struct OpInfo
|
||||
@@ -11,6 +22,9 @@ struct OpInfo
|
||||
std::string displayName;
|
||||
enzo::nt::opConstructor ctorFunc;
|
||||
enzo::prm::Template* templates;
|
||||
size_t templatesSize;
|
||||
unsigned int minInputs=0;
|
||||
unsigned int maxInputs=1;
|
||||
unsigned int maxOutputs=1;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
#include "Engine/Operator/OperatorTable.h"
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include <boost/dll/import.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templates[])
|
||||
void enzo::op::OperatorTable::addOperator(enzo::op::OpInfo info)
|
||||
{
|
||||
std::cout << "OPERATOR TABLE ADDED\n";
|
||||
std::cout << "adding operator: " << displayName << "\n";
|
||||
std::cout << "adding operator: " << info.displayName << "\n";
|
||||
|
||||
for(const prm::Template* t = templates; t->isValid(); ++t)
|
||||
for(const prm::Template* t = info.templates; t->isValid(); ++t)
|
||||
{
|
||||
std::cout << "name: " << t->getName() << "\n";
|
||||
}
|
||||
|
||||
enzo::op::OpInfo info {
|
||||
internalName,
|
||||
displayName,
|
||||
ctorFunc,
|
||||
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(enzo::op::OpInfo info);
|
||||
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 (*)(OpInfo);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user