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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* File: DLL_interface.h
*
* Author: Beat Forster (bfo@synthesis.ch)
*
*
* General interface to access the routines
* of a DLL.
*
* Copyright (c) 2004-2011 by Synthesis AG + plan44.ch
*
*
*/
#ifndef DLL_INTERFACE_H
#define DLL_INTERFACE_H
#include "target_options.h"
#include "platform_DLL.h"
#include <string>
using namespace std;
#include "generic_types.h"
#include "syerror.h"
#ifdef __cplusplus
namespace sysync {
#endif
// base class for (internal) routine access
class TAccess
{
public:
TAccess() { fMod= NULL;
fJNI= false;
fLIB= false; }
virtual ~TAccess() { }; // virtual destructor
virtual bool Connect ( cAppCharP aModName, ErrReport, void* ref= NULL )
{
fModName= aModName;
ref= NULL; // dummy to avoid warning
return true;
} // Connect
virtual bool GetFunction ( cAppCharP aFuncName, cAppCharP,
appPointer &aFunc, ErrMReport, void* ref= NULL )
{
if (aFuncName!=NULL) aFunc= (appPointer)aFuncName; // interpret it as address
ref= NULL; // dummy to avoid warning
return true;
} // GetFunction
virtual bool Disconnect () { return true; }
bool fJNI;
bool fLIB;
protected:
appPointer fMod;
string fModName;
}; // TAccess
#ifdef PLUGIN_DLL
//! derived class for DLL access
class TDLL : public TAccess
{
public:
virtual bool Connect ( cAppCharP aModName, ErrReport aReport, void* ref= NULL );
virtual bool GetFunction( cAppCharP aFuncName, cAppCharP aParams,
appPointer &aFunc, ErrMReport aReport, void* ref= NULL );
virtual bool Disconnect ();
}; // TDLL
#endif // PLUGIN_DLL
// --------------------------------------------------------------------------
/*! General error reporting */
void Report_Error( cAppCharP aText, ... );
/*! Error output, if <aModName> can't be found */
void ModuleConnectionError( void* /* ref */, cAppCharP aModName );
/*! Error output, if <aFuncName> can't be found */
void FuncConnectionError ( void* /* ref */, cAppCharP aFuncName, cAppCharP aModName );
/*! Connects library/DLL/JNI <aModName>.
* <aMod> is the module reference pointer.
*/
TSyError ConnectModule( appPointer &aMod, cAppCharP aModName, bool is_jni= false );
/*! Connects a list of functions to module <aMod>.
* The functions will be filled into <aField> with <aFieldSize>. An error will be
* returned if the list of functions is too long or too short.
* The open parameter list will be interpreted - as function names for DLLs
* (or if module name is LIB/JNI) - as function pointers for libraries
* <aMod> is the module reference pointer.
* <aParamInfo> must be true, if each element contains a second param with parameter info.
*/
TSyError ConnectFunctions( appPointer aMod, appPointer aField, memSize aFieldSize,
bool aParamInfo, ... );
/*! Disconnect a connected unit
* If mode is a library, <aMod>=NULL can be passed
*/
TSyError DisconnectModule( appPointer &aMod );
#ifdef __cplusplus
} // namespace
#endif
#endif /* DLL_INTERFACE_H */
/* eof */
|