This repository has been archived by the owner on May 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule.h
107 lines (85 loc) · 2.36 KB
/
Module.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
This file is part of MasterServer.
MasterServer is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MasterServer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with MasterServer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MASTERSERVER_MODULE_H
#define _MASTERSERVER_MODULE_H
#include <MDK/ModuleEntryPoint.h>
// MAX_PATH in Windows
#define MAX_MODULENAME 255
// Callbacks and typedef
typedef CThreadServer* (* Module_EntryPoint)(void);
/*
This class rappresents a dynamic module that will
be loaded into RetroSpy Main Server
*/
class CModule
{
public:
CModule();
~CModule();
/*
Function: Load
Descrption: Load a dynamic module
Parameters:
name => Name of the module to be loaded (without .dll/.so)
Return: true if the library is loaded
*/
bool Load(const char *name);
/*
Function: Load
Descrption: Load a dynamic module
Parameters:
name => Name of the module to be loaded (without .dll/.so)
cfg => A map to the configuration parameters
Return: true if the library is loaded
*/
bool Load(const char *name, ModuleConfigMap cfg);
/*
Function: Start
Description: Starts the module
Parameters:
db => A pointer to a current database connection, pass NULL to let the module create one by himself
*/
bool Start(CDatabase* db);
/*
Function: Stop
Description: Stop the module
*/
void Stop();
/*
Function: GetName
Description: Get the thread name
Return: the thread name
*/
inline const char *GetName() { return m_szName; }
/*
Function: GetDatabaseStatus
Description: Get the database status
Return: the database status
*/
const char *GetDatabaseStatus();
int GetExitCode();
bool IsRunning();
private:
char m_szName[MAX_MODULENAME+1];
Module_EntryPoint m_cbMain;
CDatabase* m_lpDatabase;
CThreadServer* m_lpServer;
ModuleConfigMap m_cfg;
#ifdef _WIN32
HMODULE m_lpDLL;
#else
void* m_lpDLL;
#endif
};
#endif