do anyone know (well maybe God truly exist in that case ) if it's possible to embed new cpp classes, compiling it and so on "on the fly" ?
I'm French so excuse my *average ? poor ? choose for yourself* english, I'll try to explain a little more.
Imagine we are using something like a class, let's call it : modelClassA, controllerClassA, graphicalClassA (... a complete MVC view, but an answer for a single graphicalClass is like the Graal actually), and we use it into our main app to be shown.
Practically, is it possible to create children of the classA (complete MVC or graphical only) externally, let's say graphicalChildAClassA.h & .cpp, and integrate it while main app is running..?
For example, main app is a "persistent *persisting ? other word ?* world" (let's say a city), and I would like to add on the fly new models of cars (new children of the Car class). I've heard it's possible in Java, but indeed that's not my language of predilection (indeed it's a kind of... hate, so slow).
Thanks in advance for any help ("it is simply impossible" is considered as useful help... personaly with compiled code I don't see how this could work, I imagined a kind of XML full description of new caracteristics, but it's dead for specific methods I guess).
Regards !
PS : I was first thinking about it about "all-in-one app", extended on the fly and keeping modifications for the next launches, but maybe it could be easier (or possible) to make it via plug-ins...
embed external c++ class
The usual ways to do such stuff is either adding a plugin architecture or adding new modules with a scriptlanguage.
Compiling on the fly is certainly hard to do as you need a compiler for that. You could probably use gcc on linux systems, but on windows most user don't have a compiler installed.
But you can expect that anyone who adds modules will have a compiler and can use it himself. So just adding modules with a plugin-architecture should be fine. I recently found an article series for that which supports adding plugins as static and dynamic libraries and even works platform independent. Check here for the "Building Your Own Plugin Framework" articles: http://www.ddj.com/cpp/archives.jhtml
Another way is adding a script-interface to your code. A good script-interface might make it even easier to add features, as c++ is not such a nice language for high-level programming. Though you can even use c++ for scripting with interpreters like cint http://root.cern.ch/twiki/bin/view/ROOT/CINT. It's not supporting every c++ feature, but it will work for most classes.
If a script-interface is overkill you might also get away with adding a parameter set. Like using xml-files.
Compiling on the fly is certainly hard to do as you need a compiler for that. You could probably use gcc on linux systems, but on windows most user don't have a compiler installed.
But you can expect that anyone who adds modules will have a compiler and can use it himself. So just adding modules with a plugin-architecture should be fine. I recently found an article series for that which supports adding plugins as static and dynamic libraries and even works platform independent. Check here for the "Building Your Own Plugin Framework" articles: http://www.ddj.com/cpp/archives.jhtml
Another way is adding a script-interface to your code. A good script-interface might make it even easier to add features, as c++ is not such a nice language for high-level programming. Though you can even use c++ for scripting with interpreters like cint http://root.cern.ch/twiki/bin/view/ROOT/CINT. It's not supporting every c++ feature, but it will work for most classes.
If a script-interface is overkill you might also get away with adding a parameter set. Like using xml-files.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 2
- Joined: Mon Jan 07, 2008 9:48 am
Thanks a lot
the idea of platform independent libraries/plugins sounds great, while I'm on OS X and use to care about platform independence *-dency ? maybe* Thanks for the link, I'll explore this soon.
The scripting way, I would never have thought about that But clearly it's a possibility to be evaluated, even if more useful in a middle or high-scale development, since the "preparative work" seems to be more important.
XML-like interfaces, I thought about that today (well, at this hour in France, yesterday), I don't think it's a good solution : quick, but I can't see enough flexibility (for specific methods for examples, they only could be a sequencialized set of predefined methods).
Well I'm starting my researches and hope I'll find time to create a prototype of such a system, and add some proto-features in an existing project.
To Dorth : your solution is related with plug-ins, and for the langages I'll be interested in when C# would be fully portable (some "adaptations" exist, but I don't remember any anouncement concerning C# platform independence), and for Java, well, I only see the bad in everything maybe, but now I'm wary of programs requiring virtual machines to run, it's "too nice to be true", I definitely prefer compiled languages, for the less we can control what's included and what's not, added to language quickness *hope it's the good woooooord *.
Time to sleep, have nice coming days people !
The scripting way, I would never have thought about that But clearly it's a possibility to be evaluated, even if more useful in a middle or high-scale development, since the "preparative work" seems to be more important.
XML-like interfaces, I thought about that today (well, at this hour in France, yesterday), I don't think it's a good solution : quick, but I can't see enough flexibility (for specific methods for examples, they only could be a sequencialized set of predefined methods).
Well I'm starting my researches and hope I'll find time to create a prototype of such a system, and add some proto-features in an existing project.
To Dorth : your solution is related with plug-ins, and for the langages I'll be interested in when C# would be fully portable (some "adaptations" exist, but I don't remember any anouncement concerning C# platform independence), and for Java, well, I only see the bad in everything maybe, but now I'm wary of programs requiring virtual machines to run, it's "too nice to be true", I definitely prefer compiled languages, for the less we can control what's included and what's not, added to language quickness *hope it's the good woooooord *.
Time to sleep, have nice coming days people !