Re: plugin calling code in main app
"'Andreas Mohr' via wx-users" <[email protected]> Sat, 14 Feb 2026 13:00:56 +0100
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
side note:
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
This reference is dead.
On Sat, Feb 14, 2026 at 09:02:57AM +0100, 'Alessandro Bettarini' via wx-users wrote:
> I need some help figuring out how a plugin can call code from classes
> defined in the main app
This topically seems to be a layer / scope concern.
I'd say that this is a producer consumer activity.
A main app (*any* main app!! Not "the" main app -
one might easily end up with *several*...) is supposed to
be able to
properly *consume* a wholesale component [functionality] (as provided by
a library).
Thus, it simply is the library scope's job to
specify *what exactly* it expects (read: all requirements)
any consumer to *provide* for it to be able to
function properly (read: fulfill its [scope-limited] purpose).
IOW, proper interfacing (and scoping).
Thus, one will need to
create a proper[ly minimalist!] interface type definition.
That interface[-based object] will then be *parameterized into*
a library-side component (type, factory, or so) [instantiation].
And that interface def obviously will have to be
*implemented* (derived) by the main app scope, simply in order to
actually *have* something to pass (show!) to
the *required* parameterization specialties of
the library component scope. :)
That's at least how I see it
(but I might be off vs.
some special recommendations in various articles,
especially how to handle interfaces *)).
*) e.g.:
"Inject functions, not interfaces"
https://www.hacklewayne.com/inject-functions-not-interfaces
- DI (Dependency Injection)
- DIP (Dependency Inversion Principle)
- ISP (Interface Separation Principle)
Another topically related very good article:
"Composition Root"
https://blog.ploeh.dk/2011/07/28/CompositionRoot/
> I have created a mockup project
>
> https://bitbucket.org/bettar/mockup/src/origin/
"Conventions
Singletons"
Singletons are an anti-pattern. See e.g.:
- "Why Singleton is an Anti-Pattern?"
https://buraaktasci.medium.com/why-singleton-is-an-anti-pattern-f828c186bd3e
- "Why Singletons are Evil"
https://learn.microsoft.com/en-us/archive/blogs/scottdensmore/why-singletons-are-evil
- "Retiring the Singleton Pattern - Peter Muldoon - Meeting C++ 2019"
https://www.reddit.com/r/cpp/comments/f6vwna/comment/fi7o7jv/
> to show how far I got. Please clone the git repository and suggest the
> proper way for the plugin to use code (C++ classes) defined in the main app.
I only quickly mentioned a couple thoughts here, sorry ;-)
Greetings
Andreas Mohr
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/aZBj-DPR8Oa8aQAM%40rhlx01.hs-esslingen.de.