using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RealTimeGraphX.EventArguments;
namespace RealTimeGraphX
{
///
/// Represents a and base class.
///
/// The type of the in.
/// The type of the out.
///
///
///
public abstract class GraphInputOutputComponentBase : GraphObject, IGraphInputComponent, IGraphOutputComponent where TIn : IGraphComponent where TOut : IGraphComponent
{
///
/// Occurs when the property has changed.
///
public event EventHandler> InputChanged;
///
/// Occurs when the property has changed.
///
public event EventHandler> OutputChanged;
private TIn _input;
///
/// Gets the connected input .
///
public TIn Input
{
get { return _input; }
protected set
{
_input = value;
RaisePropertyChangedAuto();
OnInputChanged(_input);
}
}
private TOut _output;
///
/// Gets the connected output .
///
public TOut Output
{
get { return _output; }
protected set
{
_output = value;
RaisePropertyChangedAuto();
OnOutputChanged(_output);
}
}
///
/// Raises the event.
///
/// The input.
protected virtual void OnInputChanged(TIn input)
{
InputChanged?.Invoke(this, new InputChangedEventArgs(input));
}
///
/// Raises the event.
///
/// The output.
protected virtual void OnOutputChanged(TOut output)
{
OutputChanged?.Invoke(this, new OutputChangedEventArgs(output));
}
///
/// Connects the specified component output to this component input.
///
/// The component.
/// Specifies whether this call was made from a component.
public abstract void ConnectInput(TIn component, bool fromInput = false);
///
/// Disconnects this component input from the current connected .
///
/// Specifies whether this call was made from a component.
public abstract void DisconnectInput(bool fromInput = false);
///
/// Connects this component to another .
///
/// The output component.
/// Specifies whether this call was made from a component.
public abstract void ConnectOutput(TOut output, bool fromOutput = false);
///
/// Disconnects this component from the connected .
///
/// Specifies whether this call was made from a component.
public abstract void DisconnectOutput(bool fromOutput = false);
}
}