Пример #1
0
        internal static void Resize <TDefinition, TType>(ref PortArray <DataInput <TDefinition, TType> > portArray, ushort newSize, void *blankPage, Allocator allocator)
            where TDefinition : NodeDefinition
            where TType : struct
        {
#if DFG_ASSERTIONS
            if (newSize == MaxSize)
            {
                throw new AssertionException("Requested array size is too large");
            }
#endif

            if (newSize == portArray.Size)
            {
                return;
            }

            // Release any owned memory if downsizing.
            for (ushort i = newSize; i < portArray.Size; ++i)
            {
                var     inputPortPatch = portArray.NthInputPortPointer(i);
                ref var ownership      = ref DataInputUtility.GetMemoryOwnership(inputPortPatch);
                if (ownership == DataInputUtility.Ownership.OwnedByPort)
                {
                    UnsafeUtility.Free(*inputPortPatch, allocator);
                }
            }
Пример #2
0
 /// <summary>
 /// See <see cref="ForwardInput{TDefinition,TForwardedDefinition,TMsg}(MessageInput{TDefinition,TMsg}, NodeHandle{TForwardedDefinition}, MessageInput{TForwardedDefinition,TMsg})"/>.
 /// </summary>
 public void ForwardInput <TDefinition, TForwardedDefinition, TMsg>(PortArray <MessageInput <TDefinition, TMsg> > origin, NodeHandle <TForwardedDefinition> replacedNode, PortArray <MessageInput <TForwardedDefinition, TMsg> > replacement)
     where TDefinition : NodeDefinition, IMsgHandler <TMsg>, new()
     where TForwardedDefinition : NodeDefinition, IMsgHandler <TMsg>
 {
     CommonChecks <TDefinition>(replacedNode, (InputPortID)origin);
     GetForwardingBuffer().Add(ForwardedPort.Unchecked.Input(origin.Port, replacedNode, replacement.Port));
 }
Пример #3
0
 /// <summary>
 /// See <see cref="ForwardInput{TDefinition,TForwardedDefinition,TMsg}(MessageInput{TDefinition,TMsg}, NodeHandle{TForwardedDefinition}, MessageInput{TForwardedDefinition,TMsg})"/>.
 /// </summary>
 public void ForwardInput <TDefinition, TForwardedDefinition, TType>(PortArray <DataInput <TDefinition, TType> > origin, NodeHandle <TForwardedDefinition> replacedNode, PortArray <DataInput <TForwardedDefinition, TType> > replacement)
     where TDefinition : NodeDefinition
     where TForwardedDefinition : NodeDefinition
     where TType : struct
 {
     CommonChecks <TDefinition>(replacedNode, (InputPortID)origin);
     GetForwardingBuffer().Add(ForwardedPort.Unchecked.Input(origin.Port, replacedNode, replacement.Port));
 }
 /// <summary>
 /// Overload of <see cref="Connect(NodeHandle, OutputPortID, NodeHandle, InputPortID, ConnectionType)"/>
 /// targeting a destination port array with an index parameter.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of range with respect to the port array.</exception>
 public void Connect <TMsg, TSource, TDestination>(
     NodeHandle <TSource> sourceHandle,
     MessageOutput <TSource, TMsg> sourcePort,
     NodeHandle <TDestination> destHandle,
     PortArray <MessageInput <TDestination, TMsg> > destPortArray,
     int index
     )
     where TSource : NodeDefinition
     where TDestination : NodeDefinition, IMsgHandler <TMsg>
 {
     Connect((PortDescription.Category.Message, typeof(TMsg), ConnectionType.Normal), new OutputPair(this, sourceHandle, sourcePort.Port), new InputPair(this, destHandle, new InputPortArrayID(destPortArray.Port, index)));
 }
 /// <summary>
 /// Overload of <see cref="Disconnect(NodeHandle, OutputPortID, NodeHandle, InputPortID)"/>
 /// targeting a destination port array with an index parameter.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of range with respect to the port array.</exception>
 public void Disconnect <TMsg, TSource, TDestination>(
     NodeHandle <TSource> sourceHandle,
     MessageOutput <TSource, TMsg> sourcePort,
     NodeHandle <TDestination> destHandle,
     PortArray <MessageInput <TDestination, TMsg> > destPortArray,
     int index
     )
     where TSource : NodeDefinition
     where TDestination : NodeDefinition, IMsgHandler <TMsg>
 {
     Disconnect(new OutputPair(this, sourceHandle, sourcePort.Port), new InputPair(this, destHandle, new InputPortArrayID(destPortArray.Port, index)));
 }
 /// <summary>
 /// Overload of <see cref="DisconnectAndRetainValue(NodeHandle, OutputPortID, NodeHandle, InputPortID)"/>
 /// targeting a port array with an index parameter.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of range with respect to the port array.</exception>
 public void DisconnectAndRetainValue <TType, TSource, TDestination>(
     NodeHandle <TSource> sourceHandle,
     DataOutput <TSource, TType> sourcePort,
     NodeHandle <TDestination> destHandle,
     PortArray <DataInput <TDestination, TType> > destPortArray,
     int index
     )
     where TSource : NodeDefinition, new()
     where TDestination : NodeDefinition, new()
     where TType : struct
 {
     DisconnectAndRetainValue(sourceHandle, sourcePort, destHandle, new InputPortArrayID(destPortArray.Port, index));
 }
 /// <summary>
 /// Overload of <see cref="Disconnect(NodeHandle, OutputPortID, NodeHandle, InputPortID)"/>
 /// targeting a destination port array with an index parameter.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of range with respect to the port array.</exception>
 public void Disconnect <TType, TSource, TDestination>(
     NodeHandle <TSource> sourceHandle,
     DataOutput <TSource, TType> sourcePort,
     NodeHandle <TDestination> destHandle,
     PortArray <DataInput <TDestination, TType> > destPortArray,
     int index
     )
     where TSource : NodeDefinition
     where TDestination : NodeDefinition
     where TType : struct
 {
     Disconnect(new OutputPair(this, sourceHandle, sourcePort.Port), new InputPair(this, destHandle, new InputPortArrayID(destPortArray.Port, index)));
 }
 /// <summary>
 /// Overload of <see cref="Connect(NodeHandle, OutputPortID, NodeHandle, InputPortID, ConnectionType)"/>
 /// targeting a destination port array with an index parameter.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the index is out of range with respect to the port array.</exception>
 public void Connect <TType, TSource, TDestination>(
     NodeHandle <TSource> sourceHandle,
     DataOutput <TSource, TType> sourcePort,
     NodeHandle <TDestination> destHandle,
     PortArray <DataInput <TDestination, TType> > destPortArray,
     int index,
     ConnectionType connectionType = ConnectionType.Normal
     )
     where TSource : NodeDefinition
     where TDestination : NodeDefinition
     where TType : struct
 {
     Connect((PortDescription.Category.Data, typeof(TType), connectionType), new OutputPair(this, sourceHandle, sourcePort.Port), new InputPair(this, destHandle, new InputPortArrayID(destPortArray.Port, index)));
 }