private static IVariableProperty <T> ToVariableProperty <T>( InputDataPort port , [NotNull] GraphInstance instance , [NotNull] GraphDefinition definition , [NotNull] Func <IVariableProperty <T> > createGraphVariable ) where T : unmanaged { var inputPortIndex = (int)port.Port.Index; Assert.IsTrue(inputPortIndex < definition.PortInfoTable.Count); var dataIndex = (int)definition.PortInfoTable[inputPortIndex].DataIndex; Assert.IsTrue(dataIndex < definition.DataPortTable.Count); var nodeIndex = (int)definition.DataPortTable[dataIndex].GetIndex(); Assert.IsTrue(nodeIndex < definition.NodeTable.Count); var dataNode = definition.NodeTable[nodeIndex]; if (dataNode is IVisualVariablePropertyNode propertyNode) { return(propertyNode.GetVariableProperty <T>(dataIndex, instance, definition)); } if (dataNode is IVisualVariablePropertyNode <T> genericPropertyNode) { return(genericPropertyNode.GetVariableProperty(instance, definition)); } if (dataNode is IConstantNode) { return(ToConstVariable <T>(instance, port)); } return(createGraphVariable()); }
public void ReadReadValue(ref NativeStream.Reader reader, out Value value, out InputDataPort inputDataPort) { inputDataPort = new InputDataPort { Port = new Port { Index = reader.Read <uint>() } }; value = reader.Read <Value>(); }
private static unsafe IVariableProperty <T> ToConstVariable <T>([NotNull] GraphInstance instance, InputDataPort port) where T : unmanaged { T data; void *ptr = &data; var value = instance.ReadValue(port); Value.SetPtrToValue(ptr, value.Type, value); return(new CustomVariableProperty <T> { CustomValue = data }); }
public static IVariableProperty <T> ToVariablePropertyReadWrite <T>(this InputDataPort port, [NotNull] GraphInstance instance, [NotNull] GraphDefinition definition) where T : unmanaged { return(ToVariableProperty(port, instance, definition, () => ToConstVariable <T>(instance, port))); }
public void RecordReadValue(Value value, InputDataPort inputDataPort) { _writer.Write(StepType.ReadValue); _writer.Write(inputDataPort.Port.Index); _writer.Write(value); }
public Reader(InputDataPort port) => _port = port;
public GraphVariableProperty(InputDataPort port) { _port = port; }
public static IVariantReader <T> ToVariantReader <T>(this InputDataPort port, [NotNull] GraphInstance instance, [NotNull] GraphDefinition definition) where T : unmanaged { return(ToVariantReader(port, instance, definition, () => new GraphVariant.Reader <T>(port))); }
public DataPortReaderAndWriter(bool isLinked, InputDataPort input, OutputDataPort output) { IsLinked = isLinked; Input = input; Output = output; }