removed all dependence on NodeOutputs

If Nodes only have the one output, we don't need to do so much differentiation
between them. Previous iteration used outputs as like a distinct function
within a Node (e.g. length output would return one result, buffer output would
produce a different result - each run different code to produce their results).
Now in this iteration, it's more accurate to say a Node is just one function
(which seems more appropriate for a node system anyway).
This commit is contained in:
itsmattkc
2019-12-06 00:23:26 +11:00
parent f424d8b44e
commit d25dda5275
45 changed files with 253 additions and 407 deletions
+19 -15
View File
@@ -56,14 +56,28 @@ NodeValueTable::NodeValueTable()
{
}
QVariant NodeValueTable::Get(const NodeParam::DataType &type, const QString &tag)
QVariant NodeValueTable::Get(const NodeParam::DataType &type, const QString &tag) const
{
return GetInternal(type, tag, false);
int value_index = GetInternal(type, tag);
if (value_index >= 0) {
return values_.at(value_index).data();
}
return QVariant();
}
QVariant NodeValueTable::Take(const NodeParam::DataType &type, const QString &tag)
{
return GetInternal(type, tag, true);
int value_index = GetInternal(type, tag);
if (value_index >= 0) {
QVariant val = values_.at(value_index).data();
values_.removeAt(value_index);
return val;
}
return QVariant();
}
void NodeValueTable::Push(const NodeValue &value)
@@ -113,8 +127,6 @@ NodeValueTable NodeValueTable::Merge(QList<NodeValueTable> tables)
NodeValueTable merged_table;
QHash<QString, NodeValueTable>::const_iterator iterator;
// Slipstreams all tables together
// FIXME: I don't actually know if this is the right approach...
foreach (const NodeValueTable& t, tables) {
@@ -130,7 +142,7 @@ NodeValueTable NodeValueTable::Merge(QList<NodeValueTable> tables)
return merged_table;
}
QVariant NodeValueTable::GetInternal(const NodeParam::DataType &type, const QString &tag, bool remove)
int NodeValueTable::GetInternal(const NodeParam::DataType &type, const QString &tag) const
{
int index = -1;
@@ -146,13 +158,5 @@ QVariant NodeValueTable::GetInternal(const NodeParam::DataType &type, const QStr
}
}
if (index >= 0) {
if (remove) {
values_.removeAt(index);
}
return values_.at(index).data();
}
return QVariant();
return index;
}