#include <interface.h>
Public Attributes | |
const char * | name |
const char * | version |
Factory | factory |
To be able to load libsax via dlopen it is needed to provide a global entrypoint symbol which can be found using dlsym(). Once the entrypoint has been created the structure variable provides access to a function named factory() which creates a global saxPluglib object while called. Using the saxPluglib object will provide access to all constructors of all interface class types implemented in libsax. See the following loader.cpp example for information how to dynamically load libsax
#include <stdio.h> #include <stdlib.h> #include <dlfcn.h> #include <sax/sax.h> using namespace LML; saxPluglib* loadLibrary (void) { void* handle = dlopen ( "/usr/lib/libsax.so", RTLD_LAZY | RTLD_GLOBAL ); if (! handle) { printf ("%s\n", dlerror ()); exit ( EXIT_FAILURE ); } EntryPoint* entrypoint = (EntryPoint*)dlsym (handle, "entrypoint"); if (! entrypoint) { printf ("%s\n", dlerror ()); exit ( EXIT_FAILURE ); } saxPluglib* LiMal = (saxPluglib*)entrypoint->factory(); return LiMal; } int main (void) { saxPluglib* LiMal = loadLibrary(); LiMal->setDebug(); int importID[7] = { SAX_CARD, SAX_DESKTOP, SAX_POINTERS, SAX_KEYBOARD, SAX_LAYOUT, SAX_PATH, SAX_EXTENSIONS }; QList<SaXImport> section; SaXConfig* config = LiMal->saxConfig(); for (int id=0; id<7; id++) { printf ("Importing data...\n"); SaXImport* import = LiMal->saxImport (importID[id]); import->setSource (SAX_AUTO_PROBE); import->doImport(); config->addImport (import); section.append (import); } printf ("writing configuration\n"); config->setMode (SAX_NEW); if ( ! config->createConfiguration() ) { printf ("%s\n",config->getParseErrorValue().ascii()); } delete LiMal; return 0; }
Important Note:
Because of the fact that libsax is using Qt a wide set of Q-Objects are created. To know about the constructors of those Q-Objects it is needed to link against qt-mt while compiling the loader. This of course results in a loader binary which is linked against qt-mt which you should have in mind and first check if that fits into your needs:
g++ loader.cpp -o loader \ -Wall -O2 -I$QTDIR/include -I/usr/X11R6/include \ -L$QTDIR/lib/ -ldl -lqt-mt
Definition at line 127 of file interface.h.