PDA

View Full Version : Suggestion about Modules in a foreign language learning program I'm developing



FreddyGod
11th June 2012, 17:43
Hi. I'm developing a program for learning a foreign language, written in Qt with c++, but next thing I'm gonna be working at is "Modules" (the idea of modules came from switchboard (elementary OS system settings) which uses sockets). A module can be connected to the application (by using some kind of a slot system) (I'm thinking of simply copying the module file(s) in a folder, which my application will scan and automatically load every module it finds (unless it's disabled - done from the application).
The module will contain (here I'm not sure, I got some ideas but I'm still thinking how to do this) the module's interface (will have, maybe, 2 interfaces (the interface from where you can take a test / study - loaded separate from main application window (as in: not embed in main app window), and another one which will be embed in main app window, which will have the controls for running it's main interface (the previous mentioned interface), which will have some buttons ("Start test", "Study", maybe some more..), maybe an icon, and a title (so maybe the module could just specify what buttons it has (enable / disable the list of button my app will offer - using XML or txt, and the icon path and the title).
Also each module will have it's own settings page (accesible from the application's settings page (a tab for each module). And also i'm thinking of letting the module manage the statistics interface (again, having a tab for each module, and, in this sittuation, each module will have it's own save file for the statistics), or i could manage the statistics window, and offer a set of predefined interfaces, from which the module will choose (really don't know how to do with statistics).
I got only 2 ideas about how to do this: each module has it's data (widgets start pos / width-height, and all the interface data) saved in one (or more) XML file(s). This has the advantage of being easily tradeable (I want the modules to be easily transfered from one pc to another, without the need to recompile the program or to transfer any other data than the modules files), but the creator of the module can only choose from a set of predefined (in my program) widgets. Also the creator of the module can't define functions in XML.
The other idea is using pre-compiled dll, which creates the interface / classes (possibly defining it's own functions also), and connect it to the main application (to use some of my pre-created functions (like "Next", "Previous", or whichever) using signals (each module would have to define some signals with a predefined name). But the problem here is that the module (.so / .dll) has to be compiled (so the creator of the module has to have Qt for dev installed). I never worked with dll (creating my own and using it in my program directly), so i don't know the pluses or minuses of this approach (from a programming point of view), also the modules have to be loaded automatically, by finding them in a file (so in program i don't know the name of the dll's or anything about them except some fixed signals (and functions maybe)).

After this long description, my question is:
How do you think would be better to implement the modules system (any idea is welcomed, right now i'm just brainstorming), would be better using XML, or precompiled librarys (I'm looking for a good (better) ratio between ease of creating a new module, and the functionality avaible to it) ?
If you have the patience to read the text, then you got a great patience ! :D
Thanks !

Note: I downloaded the code for switchboard and looked in it to try to figure out how they do it, but, except the fact that switchboard is written in vala, not c++, i couldn't really figure much. The 'module' files call GnomeCC name_of_module, and it defines an icon, a title and a category (not needed in my case, for now, I guess). GnomeCC is a 'program' built inside switchboard (it seems), it seems to be the manager that builds these interfaces, but i couldn't figure out How it decides how they look / act...:(

FreddyGod
12th June 2012, 08:41
hmm... couldn't edit this post....
On short is like this: I wanna implement “(learning) Modules”, which will have an interface (maybe some functions also, depending on the solutions chosen), and which will be connected to the main application automatically, by scanning the folder where the modules are found (or maybe connected through the GUI, having something like “Add Module”). (If the modules contain functions, it should define some predefined functions and signals). The solutions I thought of are using XML (can't define functions here), or using a shared library (or something similar, never worked directly with shared libraries.)
How would you suggest implementing the "Modules" system ? Using XML, or using library, or somehow else ...? This is the next item I'll be working at is the modules system, but I still have no idea how should I implement them, so any suggestion is welcome

ChrisW67
12th June 2012, 09:12
Read about Qt Plugins and have a look at the Plug & Paint example