Isis 3 Programmer Reference
Plugin.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Plugin.h"
8
9#include <ostream>
10
11#include <QCoreApplication>
12#include <QLibrary>
13#include <QStringList>
14
15#include "FileName.h"
16#include "IException.h"
17
18using namespace std;
19
20namespace Isis {
23 }
24
39 QFunctionPointer Plugin::GetPlugin(const QString &group) {
40 // Get the library and plugin to load
42 QString library = g["Library"];
43
44 QString path = "./";
45 Isis::FileName libraryFile(path + library);
46
47 QString pluginName = g["Routine"];
48
49 // Open the library, resolve the routine name, and return the function
50 // address. The function will stay in memory until the application exists
51 // so the scope of lib does not matter.
52 QLibrary lib(libraryFile.expanded());
53 bool loadedOk = lib.load();
54
55 if(!loadedOk) {
56 path = "$ISISROOT/lib/";
57 libraryFile = path + library;
58 }
59
60 lib.setFileName(libraryFile.expanded());
61
62 QFunctionPointer plugin = lib.resolve(pluginName.toLatin1().data());
63 if (plugin == 0) {
64 QString msg = "Unable to find plugin [" + pluginName +
65 "] in shared library [" + lib.fileName() + "]";
66 throw IException(IException::Unknown, msg, _FILEINFO_);
67 }
68
69 return plugin;
70 }
71} // end namespace isis
File name manipulation and expansion.
Definition FileName.h:100
Isis exception class.
Definition IException.h:91
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
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:39
Plugin()
Constructs a Plugin object.
Definition Plugin.cpp:22
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
PvlGroup & group(const int index)
Return the group at the specified index.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition PvlObject.h:129
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.