help with automatic code generation

Discussion in 'C++' started by JoshforRefugee, Jan 31, 2007.

  1. 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,
    JoshforRefugee, Jan 31, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rasmus Fogh

    Automatic Code Generation

    Rasmus Fogh, Oct 5, 2003, in forum: Python
    Replies:
    0
    Views:
    319
    Rasmus Fogh
    Oct 5, 2003
  2. Rasmus Fogh

    Re: Automatic Code Generation

    Rasmus Fogh, Oct 6, 2003, in forum: Python
    Replies:
    1
    Views:
    305
    John J. Lee
    Oct 6, 2003
  3. JoshforRefugee

    help with automatic code generation

    JoshforRefugee, Jan 31, 2007, in forum: C++
    Replies:
    6
    Views:
    308
    JoshforRefugee
    Feb 1, 2007
  4. fpga_designe

    Automatic VHDL generation from C code

    fpga_designe, May 15, 2009, in forum: VHDL
    Replies:
    1
    Views:
    679
    fpga_designe
    May 15, 2009
  5. John W. Long

    HTML Generation (Next Generation CGI)

    John W. Long, Nov 22, 2003, in forum: Ruby
    Replies:
    4
    Views:
    316
    John W. Long
    Nov 24, 2003
Loading...

Share This Page