We are developing a small C ++ program in which I would like to implement a system of modules. It doesn't matter if they are in Python, Lua, or C ++ (personally, I would prefer C ++ or Python).

It is planned that the system will consist of modules that could refer to the already existing functions of this application or define their own. In particular, modules must be able to, for example, invoke or create GUI elements. The application is written using ImGui, the module must be able to use this graphical interface.

It would be ideal if the module system could be installed and removed dynamically. I know that this can be done in Python or Java, but how to implement it in C ++? I wondered about the need for boost.python, but I could not find how to do it.

Once again: the module should be able to create interface elements (in particular ImGui) in an already open 3D window. In particular, I would like to be able to add applications (mini-games) that would use the functions of the application or create new ones and still draw into the window of this large program.

Question: How to implement dynamic modular application systems in C ++


Here is the amendment / addition:

I apologize, lately (16 years) I speak little Russian, I can make mistakes.

I use Linux (Ubuntu). I am thinking about implementing in the form of dynamically loadable libraries (.so). I want to use C ++ (already sure).

How I think it over, but I have no idea if this is possible:

I will click on the button ("mini-games"), the application will look at which modules (mini-games) are in the modules folder (for example, in / opt / app / minigames / .so *) and show all of them in a list. I will choose one of them. An application must (each module have one Interafce) load this module and launch it, for example:

if(selected){ interface::module modul = load(selected) ; modul.run(); } 

As I understand it, for this you probably need to write an SDK?

I intend, during module initialization, to transfer an object to it (application context through which a module can call internal application functions) eg:

 context->gui->createAlertDialog(...); 

Is that so correct? (I do not know English. Therefore, I hoped that they would help me here, since what Russian wonderful hackers are saying everywhere :))

  • Reread 2 times. The question is where? - Bald
  • Why give a minus? I have not yet learned to ask. Or do you think that if you give a minus you will help? You can’t look for questions, don’t spoil the mood ... - Petrovich Denis
  • one
    let's start with the fact that my minus is not here. Do not take a minus at your own expense, it is nothing more than an assessment of the question / answer from the point of view of a particular participant. even after editing, the question did not get much better. Try to rewrite it again: for now it's just a background that is not needed and a question. 3 minuses talk about it - Bald
  • I apologize ...: - / - Petrovich Denis
  • okay, I was a newcomer not too long ago. if you really want to get an answer, then try to rethink your question and ask more specifically. good luck - Bald

1 answer 1

Denis, the question is really asked well, very crumpled. As they say, “not to disassemble without a pallitra”)) Try to rephrase it succinctly, in the “eat / guess + need” style. And only then state your guesses of solutions / decision attempts.

Question: How to implement dynamic modular systems of applications written in C ++

All that you want in your whites - called plugins . It doesn’t matter how you implement it, although a bunch of С++ + Lua/LuaJIT would be nice for your topic. Although it is quite possible С++ + C++ , where the second part is "processed" by dynamically loadable libraries ( *.dll or *.so )

How to implement a plugin system?

I did not search the net, but I am sure that there should be more than enough materials. Further, very briefly describe the main milestones:

  • the main program should be able to provide its API to plugins
  • the main program should be able to load plugins
  • the main program should be able to register additional functionality provided by plug-ins, if one is provided by the plug-in

Everything else is at the discretion of the developer.

  • The path is marked correctly. Yes, the plugin will give additional functionality. Visual and systemic. Visual as context->gui->createAlertDialog(...); System as context->signal("name_of_module")->push<string>("hello"); Or like ... - Petrovich Denis
  • Here is a revelation. Comments are not for kids. - Petrovich Denis