Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include "../inc/DllOpen.h"
#include "../inc/LibraryManager.h"
#include "../inc/Algorithm.h"
namespace Mantid
{
LibraryManager* LibraryManager::instance = 0;
void* LibraryManager::module = 0;
LibraryManager::LibraryManager()
{
}
LibraryManager::~LibraryManager()
{
//Close lib
DllOpen::CloseDll(module);
module = 0;
}
LibraryManager* LibraryManager::Initialise(const std::string& libName)
{
if (!instance)
{
instance = new LibraryManager;
//Load dynamically loaded library
module = DllOpen::OpenDll(libName.c_str());
if (!module)
{
std::cout << "Could not open library!\n";
return 0;
}
}
return instance;
}
Algorithm* LibraryManager::CreateAlgorithm(const std::string& algName)
{
create_alg* createMyAlg = (create_alg*) DllOpen::GetFunction(module, algName.c_str());
return createMyAlg();
}
void LibraryManager::DestroyAlgorithm(const std::string& algName, Algorithm* obj)
{
destroy_alg* destroyMyAlg = (destroy_alg*) DllOpen::GetFunction(module, algName.c_str());
destroyMyAlg(obj);
}
}