J
JoshforRefugee
heard that we can do automatic code generation using macros, but not
sure how can I pursue this. Here is my problem.
In my env, I have class A,B and C. All of them has constructors, and
few common methods, like reset, and execute.
now my env(main) class actually is where I am creating this objects.
in .h
A myA;
B myB;
C myC;
and later I am calling methods in my .C file
myA.reset();
myB.reset();
myC.reset();
myA.execute();
.....
myC.execute();
now let say if I add Class D, I have to modify my env.h and env.C. And
I am trying to prevent that.
one way i was thinking of doing this, is to write macros:
so I can do:
REGISTER_OBJECT("A","myA");
REGISTER_RESET("A","myA",reset);
REGISTER_EXECUTE("A", "myA", execute)
.............
May be using macros might be one way to do this. I am really confuse
how I can I write this macros. Please guide me.
Thank you,
sure how can I pursue this. Here is my problem.
In my env, I have class A,B and C. All of them has constructors, and
few common methods, like reset, and execute.
now my env(main) class actually is where I am creating this objects.
in .h
A myA;
B myB;
C myC;
and later I am calling methods in my .C file
myA.reset();
myB.reset();
myC.reset();
myA.execute();
.....
myC.execute();
now let say if I add Class D, I have to modify my env.h and env.C. And
I am trying to prevent that.
one way i was thinking of doing this, is to write macros:
so I can do:
REGISTER_OBJECT("A","myA");
REGISTER_RESET("A","myA",reset);
REGISTER_EXECUTE("A", "myA", execute)
.............
May be using macros might be one way to do this. I am really confuse
how I can I write this macros. Please guide me.
Thank you,