best way to implement dynamic design

J

jonathan

hey all,

I'd like to implement an application that is truly dynamic: the
components are not only just known at runtime, but also the components
are unknown at runtime: ie: some don't even ship with the application.

When a new component is shipped, the application 'picks up' that
component and drops it in to the interface (in this case a GUI button
as well as an associated class with that gui buttion). The application
then uses the code in that interface to customize the behaviour of the
application.

Sort of like a 'skin' - except instead of having external data
customizing the look of an application, there is external code
customizing the *behaviour* of an application. However, since there

Also, I need this to be cross-platform so, if there is no internal
solution to this problem (the language doesn't support it) I'm
interested in solutions that work on MacOSX/Linux/Win. I'm using
wxWindows as my GUI platform.

Or - should I maybe go with wxPython instead?

jon
 
S

Shane Beasley

(e-mail address removed) (jonathan) wrote in message
This is an ISO C++ newsgroup, which doesn't even support GUIs, let
alone loading arbitrary code at run-time (which some systems do not
support).

Then again, I'm not sure if there *is* a forum for this, so I'll start
rambling so that you have some stuff to look up, at least.

Anyone interested only in ISO C++ should probably stop reading now. :)
I'd like to implement an application that is truly dynamic: the
components are not only just known at runtime, but also the components
are unknown at runtime: ie: some don't even ship with the application.

There must be, at least, a published interface/protocol so that you
can ask the module what it can do and how to get it to do that.
Also, I need this to be cross-platform so, if there is no internal
solution to this problem (the language doesn't support it) I'm
interested in solutions that work on MacOSX/Linux/Win. I'm using
wxWindows as my GUI platform.

Java apps use a feature called "reflection" for this purpose; but C++
doesn't support anything like reflection (yet), so this has to be done
by the programmer. Further, ISO C++ doesn't support dynamic modules,
since not all systems support dynamic modules (ISO C++ is designed to
run on just about any computer). So, you're left with OS-specific
technologies.

On Windows, COM and ActiveX are commonly used for this sort of thing.
On Linux, GNOME uses Bonobo, which is a CORBA-based technology; and
KDE uses KParts.

I have no idea about MacOS X. :) Maybe, if you're lucky, one of the
Linux technologies is also portable there.

You might be able to use one or more of these technologies, perhaps
using different ones on different platforms. Alternatively, it may be
possible to write your own component architecture, but such will be
non-trivial (for a place to start, look up LoadLibrary on Windows and
dlopen on Linux [and possibly MacOS X via its FreeBSD heritage]).
Or - should I maybe go with wxPython instead?

That sounds like the easiest way to do it, if that'll work for you. It
certainly makes sense to use a dynamic language like Python to add
dynamic behavior to a program.

In fact, you might be able to write the program and modules in C++ and
use Python to glue them together -- those wacky people at boost.org
have a C++/Python reflection library, which may be of some use here.
It officially supports Windows and Linux, but it may be portable to
MacOS X if someone (you?) makes it happen.

I have no idea if any of this is relevant to you, but hopefully it'll
lead you in the right direction.

Good luck!

- Shane
 
K

Kevin Goodsell

jonathan said:
Fair enough, but I maintain that what I asked in fact *was* a C++
question - it dealt with the limitations of the language. The extra
stuff (about guis, etc.) is just context.

I don't really see a question about C++. The whole thing with drop-in
components can't possibly be done in standard C++ since there's no
concept of dynamic linking or anything like that. Unless maybe the
components were interpreted by the main app somehow.

-Kevin
 
R

Rolf Magnus

jonathan said:
Fair enough, but I maintain that what I asked in fact *was* a C++
question - it dealt with the limitations of the language. The extra
stuff (about guis, etc.) is just context.

In this case, the answer is "what you want cannot be done".
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top