Isis 3 Programmer Reference
Plugin.cpp
Go to the documentation of this file.
1 
23 #include "Plugin.h"
24 
25 #include <ostream>
26 
27 #include <QCoreApplication>
28 #include <QLibrary>
29 #include <QStringList>
30 
31 #include "FileName.h"
32 #include "IException.h"
33 
34 using namespace std;
35 
36 namespace Isis {
38  Plugin::Plugin() : Pvl() {
39  }
40 
55  QFunctionPointer Plugin::GetPlugin(const QString &group) {
56  // Get the library and plugin to load
57  PvlGroup &g = findGroup(group);
58  QString library = g["Library"];
59 
60  QString path = "./";
61  Isis::FileName libraryFile(path + library);
62 
63  QString pluginName = g["Routine"];
64 
65  // Open the library, resolve the routine name, and return the function
66  // address. The function will stay in memory until the application exists
67  // so the scope of lib does not matter.
68  QLibrary lib(libraryFile.expanded());
69  bool loadedOk = lib.load();
70 
71  if(!loadedOk) {
72  path = "$ISISROOT/lib/";
73  libraryFile = path + library;
74  }
75 
76  lib.setFileName(libraryFile.expanded());
77 
78  QFunctionPointer plugin = lib.resolve(pluginName.toLatin1().data());
79  if (plugin == 0) {
80  QString msg = "Unable to find plugin [" + pluginName +
81  "] in shared library [" + lib.fileName() + "]";
83  }
84 
85  return plugin;
86  }
87 } // end namespace isis
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
File name manipulation and expansion.
Definition: FileName.h:116
Namespace for the standard library.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:134
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
Container for cube-like labels.
Definition: Pvl.h:135
PvlGroup & group(const int index)
Return the group at the specified index.
Definition: PvlObject.cpp:423
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QFunctionPointer GetPlugin(const QString &group)
This method returns a void pointer to a C function (i.e., the plugin) It does this by looking in itse...
Definition: Plugin.cpp:55