I need to implement the concept of task in my application. In my project, the task is an operation that must be performed and is identified by a name: each task also has input parameters (types and values) and produces one or more outputs.
Having to implement the Task class, how can I express the concept of "operation that has some kind of result"? I could store the name of the operation in a string attribute, but how do I express the type returned by this operation? Similarly, how can I implement a list of input parameters of the operation, when these parameters may also be of different types?
The goal is to serialize the Task object and send it to another node. The receiver analyzes the received Task object, reads the name of the operation and executes the corresponding function.
For example, suppose that node A and node B "have" the following methods...
Service of node A:
- double getAreaOfRectangle(double length, double width);
- double getAreaOfTriangle(double base, double height);
- double getAreaOfParallelogram(double base, double height).
Service of node B:
- double getAreaOfCircle(double radius);
- double getAreaOfTrapezoid(double base1, double base2, double height).
If the node C needs to calculate the area of a rectangle, it knows it must contact the node A and send a message to node A by specifying the operation (double areaOfRectangle) and the inputs (double width and double height). Similarly, if the node C needs to calculate the area of a circle, it must send a message to node B, specifying the operation and the length of the radius. In order to send the inputs, since they could be different types (or even new user-defined types), I could use an array of object...
Some tasks may depend on other tasks, ie, as input parameters may have at least one output of another task, and so I would need to implement also the link between the output of a task and the input of another.
How should I proceed to define the class?