-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.h
More file actions
65 lines (55 loc) · 1.58 KB
/
Module.h
File metadata and controls
65 lines (55 loc) · 1.58 KB
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
58
59
60
61
62
63
64
/*
* Module.h
*
* Created on: Sept. 28, 2015
* \copyright 2015 DCBlaha. Distributed under the Mozilla Public License 2.0.
*/
#ifndef MODULE_H
#define MODULE_H
#include "Module.h"
#define MODULE_IMPORT extern
#ifdef __linux__
#define MODULE_EXPORT
#else
#define MODULE_EXPORT __declspec(dllexport)
//#include "windef.h"
//#include "WinBase.h"
#include "Windows.h"
#endif
#ifdef __linux__
typedef void *ModuleProcPtr;
#else
typedef FARPROC ModuleProcPtr;
#endif
/// A class that encapsulates a run time or dynamic library.
/// This encapsulates something similar to GLib's GModule.
// This class was originally written to avoid the use of GLib. This only uses
// Windows functions on MS-Windows. It uses the dl... functions on linux.
// undefined reference to symbol 'dlclose@@GLIBC_2.2.5' on Ubuntu 14-04
class Module
{
public:
Module():
mModule(nullptr)
{}
// This releases the module.
~Module()
{ close(); }
/// @param The file name of the run time library. For both Windows and
/// linux, a relative filename may search multiple directories.
bool open(char const *fileName);
void close();
/// Load a symbol for the module.
/// @param symbolName The name of the function/symbol.
/// @param symbol The pointer to the symbol function.
void loadModuleSymbol(char const *symbolName, ModuleProcPtr *symbol) const;
bool isOpen()
{ return(mModule != 0); }
private:
#ifdef __linux__
void *mModule;
#else
HMODULE mModule;
#endif
};
#endif