Sign in to follow this  

Modular app design

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I've got a question about making modular applications. At least that what I call them. Basically, I have a bunch of classes, or rather just headers. Now for the implementations, I want to be able to create multiple implementaions of any class, and not have to recompile the whole program. So basically, say I have a class cWindowMaker. It has a Create_Window(x, y, width, height) function, and maybe some callbacks, but lets say it just has the Create_Window function. Now, I make an implementation that basically creates a window with all the bells and whistles, like the title bar, all the titlebar buttons, resizable, etc. And then I somehoe compile that implementation in a DLL file. Then, I load that DLL dynaically, create an instance of the class and call my Crete_Window function. Now, imagine I make another implementation, that basically makes a window without anything, no border etc. Make another DLL and now I want to use it. Well, obviously I jus have to replace the old DLL and restart my app and voila. The hard part? HOW do I make all that work?? Can't wrap myu head around it. Can anybody please help? Im sure this kind of stuff has been done by somebody here before... Thanks in advance, Anton.

Share this post


Link to post
Share on other sites
Research: abstract base classes, interfaces, and polymorphism.

Once you're familiar with that, do this:

Make your EXE load a DLL and call a "pre-shared name" DLL function that returns a pointer to the base class. The DLL can create any kind of derived class it wants to. As long as there are virtual functions, the pointer that the DLL returns will have a vtable that accurately points to the functions in the DLL.

You can use LoadLibrary and GetProcAddress to do the DLL loading and function-finding on the fly without restarting your EXE (but you will still have to recompile any new DLL you want to use).

Share this post


Link to post
Share on other sites

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this