Thread: Attaching functions to a class/struct

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Attaching functions to a class/struct

    I'm doing a little experimenting with a COM-like structure but I'm not using COM per se.

    The goal is to be able to add functions to a class/struct or whatever dynamically at run-time.

    struct FuncExp
    {
    void **Funcs;
    void Attach(void *Func);
    void Attach(void **FuncList,int numfuncs);
    };

    Problem is to call these funcs I would have to create a special call function. I would rather call these functions just as you would in normal C code. But, the struct does not 'know' what functions it has nor does it know the prototypes for thoe functions. Essentially I must create my own vtable for this to work. Upon querying the object it should return a pointer to the interface for the object. Sort of like COM. I'm working on this for possible implementation in a new OS and since COM is copyrighted it would not serve to use it.

    The goal is to be able to dynamically attach and detach functions via pointers to and from objects. Perhaps I need to read a book on COM to see how it truly functions underneath the hood - using it and coding something like it are 2 completely diff things.

    And even though the GUID system works for COM I'm not a big fan of it so I would need a way to uniquely identify each object. I know these objects must be pre-compiled and sitting somehwhere for someone to use. As well there must be a mechanism for retrieving pointers to these objects - but this function can not be relative to the object being used. Very simple concept but very confusing.
    Last edited by VirtualAce; 08-04-2003 at 07:19 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM