Hello,
i want to extend a program of mine with a plugin architecture.
I can load and use the shared libs which are implementations of a
abstract base class without any problems. But what i need is a
bi-directional interface, the plugins have to acess objects of the
main programm (pointers to them are passed at plugin initialisation) .
This works too - but only if i include the header and .cpp files of
these api objects into every plugin - and that is bloated bullshit !
is there a way to include the api .h files only and uses the
implementation code from the main-application (gcc 3.2 linux 2.4) ??
if i try to do that library loading fails with unresolved symbols
.....
Thanx C.S. 4 4210
"listigerBi ber" <c.********@urz .uni-heidelberg.de> wrote... i want to extend a program of mine with a plugin architecture. I can load and use the shared libs which are implementations of a abstract base class without any problems. But what i need is a bi-directional interface, the plugins have to acess objects of the main programm (pointers to them are passed at plugin initialisation) . This works too - but only if i include the header and .cpp files of these api objects into every plugin - and that is bloated bullshit !
is there a way to include the api .h files only and uses the implementation code from the main-application (gcc 3.2 linux 2.4) ?? if i try to do that library loading fails with unresolved symbols ....
What you need is to provide an SDK to the writers of plug-ins. You
have determined what classes plug-ins need, now you have to expose
those classes. The most convenient way is to create "pure abstract"
interfaces. The real objects that will do the work you will create
on demand in some kind of factory function. The plug-ins will call
your factory or will receive the pointers to base classes some other
way, then will call the methods of those base classes, which will
resolve in calls to the implementations through polymorphism.
So, you basically on the right track. Simply extract the interface
the plug-ins will use into the base class, declare those functions
virtual and pure. Make your classes derive from those interfaces,
create the instances of your classes and pass the addresses as base
class pointers to plug-ins.
Victor
Hi listigerBiber, all, One way to implement a C interface which I have used quite a lot is to
make each plugin have only one function. The function returns a pointer to a C struct which has nothing but function pointers.
id's QuakeII engine (GPL) uses a very similar method. The loading
module and loaded module exchange references through one function call.
struct import
{
//lots of pointers to funcs in other module
} Ii;
struct export
{
//lots more pointers to funcs in current module
}Ie;
//init pointers in Ie to local functions you want to access in other module
__declspec(dlle xport) import GetAPI(export Ie); //defined in other
module--platform specific interface
Ii = GetAPI(Ie); //this func saves off the Ie info and then inits the Ii
pointers to its local funcs to be accessed in the calling module
I have a different method for doing the same thing. I made a global
data tree where each node looks like:
struct Glob
{
char szName[MAX_STRING];
DWORD dwFlags; //valid fields and requests
char szValue[MAX_STRING];
int iValue;
float fValue;
void* pVoid;
PGLOB pParentGlob;
PGLOB pLeftGlob;
PGLOB pRightGlob;
};
Then, pointers to my equivalent of the above import/export structs would
be placed in Glob::pVoid for all to access.
HTH
--
Best wishes,
Allen
No SPAM in my email !!
"Allen" <al************ @att.SPAM.net> wrote in message
news:WM******** *************@b gtnsc04-news.ops.worldn et.att.net... Hi listigerBiber, all,
One way to implement a C interface which I have used quite a lot is to make each plugin have only one function. The function returns a pointer to a
C struct which has nothing but function pointers.
id's QuakeII engine (GPL) uses a very similar method. The loading module and loaded module exchange references through one function call.
struct import { //lots of pointers to funcs in other module } Ii;
struct export { //lots more pointers to funcs in current module }Ie;
//init pointers in Ie to local functions you want to access in other
module __declspec(dlle xport) import GetAPI(export Ie); //defined in other module--platform specific interface Ii = GetAPI(Ie); //this func saves off the Ie info and then inits the
Ii pointers to its local funcs to be accessed in the calling module
I have a different method for doing the same thing. I made a global data tree where each node looks like:
struct Glob { char szName[MAX_STRING]; DWORD dwFlags; //valid fields and requests char szValue[MAX_STRING]; int iValue; float fValue; void* pVoid; PGLOB pParentGlob; PGLOB pLeftGlob; PGLOB pRightGlob; };
Then, pointers to my equivalent of the above import/export structs
would be placed in Glob::pVoid for all to access.
HTH --
Best wishes, Allen
No SPAM in my email !!
Funny you should mention QuakeII. I'm the author of the QuakeII mods WoD7
and WoD8. :) But as you say, it was iD software that wrote the stuff you're
talking about.
Guess in this context I'll use my real sig, including my QuakeII clan name
LOL
--
Cycho{HHR} http://home.rochester.rr.com/cyhome/
Thank you very much !
your hint with the abstract base class for the pluginfactory worked
....
of course the pluginfactory or application api must have a pure
virtual base class !!
"Victor Bazarov" <v.********@att Abi.com> wrote in message news:<9l******* ************@rw crnsc51.ops.asp .att.net>... "listigerBi ber" <c.********@urz .uni-heidelberg.de> wrote... i want to extend a program of mine with a plugin architecture. I can load and use the shared libs which are implementations of a abstract base class without any problems. But what i need is a bi-directional interface, the plugins have to acess objects of the main programm (pointers to them are passed at plugin initialisation) . This works too - but only if i include the header and .cpp files of these api objects into every plugin - and that is bloated bullshit !
is there a way to include the api .h files only and uses the implementation code from the main-application (gcc 3.2 linux 2.4) ?? if i try to do that library loading fails with unresolved symbols ....
What you need is to provide an SDK to the writers of plug-ins. You have determined what classes plug-ins need, now you have to expose those classes. The most convenient way is to create "pure abstract" interfaces. The real objects that will do the work you will create on demand in some kind of factory function. The plug-ins will call your factory or will receive the pointers to base classes some other way, then will call the methods of those base classes, which will resolve in calls to the implementations through polymorphism.
So, you basically on the right track. Simply extract the interface the plug-ins will use into the base class, declare those functions virtual and pure. Make your classes derive from those interfaces, create the instances of your classes and pass the addresses as base class pointers to plug-ins.
Victor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil |
last post by:
I realize this is the php group, but I have a question that recurses
back to my php install.
My objective is a pure 64 bit shared object installation of php 5.0 on
UltraSparc Solaris 9 compiled with the Sun Compiler version 8.
My problem is that EVERYTHING builds great EXCEPT that the 6b
distribution of JPEG will NOT build a shared object, thus gd cannot
include support for JPEG, thus php loses that functionality.
|
by: AH |
last post by:
I have two functions in my shared library which are declared as
follows:
void setName(const std::string& str);
std::vector<std::string> getInfo();
Since the code is compiled and in shared library. Every thing is great
if the customer of my shared library is using the same compiler
version (and same STL version). I am wondering if the customer changes
their compiler version (or STL version) which may have same interface
|
by: Invalidlastname |
last post by:
Hi,
We developed some assemblies which use EnterpriseServices queued components.
In order to use EnterpriseServices, these assemblies need to be installed
into GAC. I used the pre-build and post-build events to automate GAC
installation processes and the asp.net application has "copy to local" set
to false for the references of these shared assemblies.
However, every time we made the changes to the shared assemblies, we had to
restart...
|
by: Jeff |
last post by:
Hi -
I understand how to create a directory folder, but how can I programatically
create a _shared_ directory folder and set its permissions?? (I'm using
VB.NET.)
Thanks for your help.
- Jeff
|
by: Matt Kowalczyk |
last post by:
I hope I am posting this to the right newsgroup. I tried submitting this to the
autoconf@gnu.org mailing list, but I see no activity. If this is the wrong
newsgroup, I would appriciate a reference to a different source.
My question was:
One of my source files uses the library:
#include <openssl/md5.h>
| |
by: zztlhb |
last post by:
Hi,
I currently hit an issue that I would like to use a function statically linked to a shared library but my program use the same function from another shared library. Here is what I do:
1. I have toto.cxx that has one function called: toto() {cout << "static toto" << endl;}
2. I create an archive say toto.a has the toto.o
3. I have toto1.cxx that has one functin called toto() {cout cout <<"shared toto"<<endl;}
4. I create a shared...
|
by: abhi147 |
last post by:
Hi ,
I am trying to create a shared library and trying to load it
usinf dlopen() function . My code and steps to create and load the *.so
is :
/*** test.c ***/
#include <stdio.h>
void test()
{
|
by: David T. Ashley |
last post by:
I've occasionally had trouble compiling and linking programs that use shared
libraries. That never made a lot of sense to me, because I thought the
operating system went hunting for the symbols and libraries at runtime (and
not before).
Questions:
a)How do the development tools know that a given symbol (a function entry
point, for example) is located in a shared library and won't be linked in
statically?
|
by: gopan |
last post by:
I want to call the 'stat' system call dynamically.
In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.
My questions are:
0) Given a function name, how can I fiund out if it is available in a
shared library (.so) or only in a static library(.a)?
1) Given a function name, how can I find which shared library...
|
by: sunil |
last post by:
Hi ,
Am facing one problem while deploying the shared library in different
boxes.
I devoloped one shared library for TAM suite ( This is a IBM product
for different authentication mechanisms) to customise that product for
a different scenario.
We deployed the TAM in different boxex and the same library file is
deployed in all the machines.
It is working in three boxes perfectly fine but in one box it is not
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |