![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
#include <FXDLL.h>
Public Methods | |
FXDLL (const FXString &filename="") | |
void | setFilename (const FXString &filename) |
FXString | getFilename () const |
FXString | getLoadedFilename () const |
FXbool | open () |
void | close () |
FXbool | isOpen () |
FXDLLHandle | getHandle () |
virtual void * | getFunction (const FXString &function) |
virtual | ~FXDLL () |
Includes a macro so as to make dynamic loading of classes simpler than would be otherwise.
Notes: When dynamically loading a dll, most OS's automatically load a default library function if it it exists (DllMain on Win32, _init on Linux). The problem is two-fold in that a) they are different names for different platforms, b) they are only called once, even if they opened a second time, for a second thread (this is a particularly nasty problem since the second thread wont initialise and thread specific variables).
To combat this, I have written the class so that if your library contains a C function FXDLL_load, it will be called the first time a library is loaded (for a given FXDLL object), thus solving the platform problem. Also, if you load it from a second thread (and thus from a second FXDLL objects), it calls FXDLL_load in that thread too (the OS specific auto-exec functions dont do this), thus correctly initialising thread specific variables.
Conversly, when you unload the library, if you have a library function called FXDLL_unload, it is called before unloading the library (for each FXDLL instance).
Definition at line 47 of file FXDLL.h.
|
create a dll object, using specified filename.
|
|
close library.
|
|
set to new filename - fails silently if library is already loaded.
|
|
get the filename.
|
|
get the name of the file actually loaded.
|
|
open library file.
|
|
close library.
|
|
indicates if the library is already open.
|
|
get handle.
|
|
return a pointer to a function you will need to do something like this:. double (*calc)(double a,double b); calc = dll.getFunction("power"); result = (*calc)(val1,val2); |