mardi 25 janvier 2022

How to get all the public methods of a c++ subclass and put them in a vector?

I'm building a c++ aplication where the user create a class like that:

class MyClass : public FrameworkClass {
/** Some user attributes and methods
 * 
 */

class ROUTINE {
   private:
    void privateMethod();

   public:
    void method1();
    void foo();
    void AnyName();
}};

The idea is that all public methods of the ROUTINE subclass are executed on separate threads in a loop. Currently, the user himself has to register all the methods pushing them in a vector that the framework will iterate starting the threads, but I want to know if there is any way to make this process automatic, that is, create the array automatically since all the methods inside the ROUTINE subclass should always run this way, preferably in a non-intrusive way like a macro.

OBS:

the loop is something simple like:

void routineLoop() {
    while(Framework::IsRunning) {
        //call the method
    }
}

and it's alreandy working, the only problem it's the usability.





Aucun commentaire:

Enregistrer un commentaire