I am trying to write a framework in C++ which will be used by my team to define various processes. A process will be made up of various fundamental steps. Something like this:
Steps = {Step1, Step2, Step3...StepN}
Processes = {ProcessA, ProcessB, ProcessC..ProcessN}
ProcessA = {Step1, Step3, Step5}
ProcessB = {Step3, Step5, Step7}
I am planning that each step will implement an IStep
interface which will have a Perform()
method. And a process will be a list of steps. In order to complete a process, you would iterate through steps and call the Perform
method. The problem is when a step is performed it changes the state of the process. The variables which would define the state of the process are of different types and they are not fixed.
Example of states of a process
Process A
Pointer to the next empty box (Some pointer)
Number of cylinders (number)
Color of the box (string)
Process B
Process name (string)
Number of boxes (number)
Pointer to list of boxes (Some other pointer type)
Had it been a service, I could have stored this information in JSON format. I think what I am looking for is dynamic
type like we have in C#
(maybe some magic with void pointers but I am not sure if that's the best practice). I read somewhere about using the factory pattern to solve this problem. Is that the best way to do it? Or maybe should I consider changing my design.
Aucun commentaire:
Enregistrer un commentaire