00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef INCLUDED_AIDAANALYZER_H
00012 #include "AIDA_Analyzer/AIDAAnalyzer.h"
00013 #endif
00014
00015 #include <dlfcn.h>
00016 #include <stdio.h>
00017
00018 #include "Interfaces/IHistoManager.h"
00019 #include "Interfaces/INtupleManager.h"
00020 #include "Interfaces/IVectorManager.h"
00021
00022 IAnalyzer * createIAnalyzer() { return new AIDAAnalyzer(); }
00023
00024 void AIDAAnalyzer::doIt(IHistoManager * hm, INtupleManager * ntm, IVectorManager * vm)
00025 {
00026
00027
00028 typedef void* (*tdI) (IHistoManager *, INtupleManager * , IVectorManager * );
00029 char *error;
00030
00031 tdI doItSym = (tdI) dlsym(handle, "doIt");
00032 if ((error = dlerror()) != NULL) {
00033 fputs(error, stderr);
00034 exit(1);
00035 }
00036
00037 (*doItSym)(hm, ntm, vm);
00038
00039 }
00040
00041 AIDAAnalyzer::AIDAAnalyzer() : handle(0)
00042 {
00043 }
00044
00045 void AIDAAnalyzer::loadLibrary(const char * libName)
00046 {
00047 if (handle != 0) unLoadLibrary();
00048
00049 handle = dlopen (libName, RTLD_NOW);
00050 if (!handle) {
00051 fputs (dlerror(), stderr);
00052 exit(1);
00053 }
00054
00055 }
00056 void AIDAAnalyzer::unLoadLibrary()
00057 {
00058 if (handle != 0) {
00059 dlclose(handle);
00060 handle = 0;
00061 }
00062 }
00063
00064 AIDAAnalyzer::~AIDAAnalyzer()
00065 {
00066 if (handle != 0) dlclose(handle);
00067 }