mardi 16 juin 2020

How to implement a basic state/lifecycle management for an application

I want to develop an application skeleton in C++ which has 4 states: init, waiting_to_run, running, terminating

There are 4 functions which I can implement and change depends on the functionalities of each application.

class ApplicationImpl {
    init();
    waiting_to_run();
    running();
    terminating();
}

How shall I implement this ? Later I may add a new state or remove one. At that time I want the other developers who use this structure only need to work with 1 new function e.g. timeout() , and do not need to bother with state transition ...

Thank you very much for any reply !

Aucun commentaire:

Enregistrer un commentaire