I read some questions related to my problem, but I found them quite specific for a specific program design, so I hope to get some tips on my specific case ...
I am working on a program that allows you to perform logical operations based on the node graph, for example, you have different types of nodes; CostantNode and node addition, you can draw two constants and associate them with node addition, so this last one will process the inputs and produce the result. So far, the node class has had a virtual method for processing:
//Node Logic public virtual float Process(Dictionary<Guid, Node> allNodes) { //Override logic on child nodes. return Value; }
This method is overridden for each nodeType type received, for example, in the add-on:
/// <summary> /// We pass Allnodes in so the Node doesnt need any static reference to all the nodes. /// </summary> /// <param name="allNodes"></param> /// <returns>Addition result (float)</returns> public override float Process(Dictionary<Guid, Node> allNodes) { //We concatenate the different input values in here: float Result = 0; if (Input.Count >= 2) { for (int i = 0; i < Input.Count; i++) { var _floatValue = allNodes[Input[i].TailNodeGuid].Value; Result += _floatValue; } Console.WriteLine("Log: " + this.Name + "|| Processed an operation with " + Input.Count + " input elements the result was " + Result); this.Value = Result; // Return the result, so DrawableNode which called this Process(), can update its display label return Result; } return 0f; }
Until now, everything worked fine until I tried to implement a Hysteris node, which basically should evaluate the input and return TRUE or FALSE, it was stuck as I need to return a boolean value, not a float value, I ran it. Having analyzed the return to Bool on the View side in the program, but I want to be able to configure the types of the returned Process () processes in certain child nodes, the nodes also store the result of the process in a float variable called Value, which in Hysteris I will need node value for True or False ...
Hope you guys can give me some tips on how to approach this problem, I have not worked deeply with POO.
Thanks in advance.