I have an application comprising a bootstrapper executable, a core library and several plugins (shared libraries). The core library is implicitely linked to all components, the plugins get linked/loaded explicitely by the core library. When the plugins functions get called, I pass several objects defined in the core library. Now I ask myself which is the best way to design the interface of these classes.
There are three ways I can think of.
- Design a simple class and pass it. This is the current approach, but the interface is messy because the core needs additional functions on this object, currently realized with friend relationships and private access modifier so that the clients/plugnis cant access it. I think this is the worst approach since the client interface is really ugly.
- Create an ABC (interface) and add the core functionality in the concrete subclass and pass the object as the ABC to the plugins. This looks fine, but somehow I am not sure if this is good design since on the one hand interfaces are not really a C++ concept and theres only one class that inherts the ABC (seems like a smell to me) and on the other hand the compiler complains about weak vtables emitted in all TUs. (I tried but I dont get this)
- Create a mediator/facade class and hide the interface needed by the core library. The con in this approach beeing the extra indirection.
Would be nice if somebody could complement this list and elaborate the pros and cons of the approaches. Finally if it is possible I'd appreciate a recommendation. Thank you.