forked from Infactum/addin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathComponentBase.h
243 lines (217 loc) · 7.44 KB
/
ComponentBase.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
* Warning!!!
* DO NOT ALTER THIS FILE!
*/
#ifndef __COMPONENT_BASE_H__
#define __COMPONENT_BASE_H__
#include "types.h"
////////////////////////////////////////////////////////////////////////////////
/**
* The given interface is intended for initialization and
* uninitialization of component and its adjustments
*/
/// Interface of component initialization.
class IInitDoneBase
{
public:
virtual ~IInitDoneBase() {}
/// Initializes component
/**
* @param disp - 1C:Enterpise interface
* @return the result of
*/
virtual bool ADDIN_API Init(void* disp) = 0;
/// Sets the memory manager
/*
* @param mem - pointer to memory manager interface.
* @return the result of
*/
virtual bool ADDIN_API setMemManager(void* mem) = 0;
/// Returns component version
/**
* @return - component version (2000 - version 2)
*/
virtual long ADDIN_API GetInfo() = 0;
/// Uninitializes component
/**
* Component here should release all consumed resources.
*/
virtual void ADDIN_API Done() = 0;
};
///////////////////////////////////////////////////////////////////////////
/**
* The given interface defines methods that are intented to be used by the Platform
*/
/// Interface describing extension of language.
class ILanguageExtenderBase
{
public:
virtual ~ILanguageExtenderBase(){}
/// Registers language extension
/**
* @param wsExtensionName - extension name
* @return the result of
*/
virtual bool ADDIN_API RegisterExtensionAs(WCHAR_T** wsExtensionName) = 0;
/// Returns number of component properties
/**
* @return number of properties
*/
virtual long ADDIN_API GetNProps() = 0;
/// Finds property by name
/**
* @param wsPropName - property name
* @return property index or -1, if it is not found
*/
virtual long ADDIN_API FindProp(const WCHAR_T* wsPropName) = 0;
/// Returns property name
/**
* @param lPropNum - property index (starting with 0)
* @param lPropAlias - 0 - international alias,
* 1 - russian alias. (International alias is required)
* @return proeprty name or 0 if it is not found
*/
virtual const WCHAR_T* ADDIN_API GetPropName(long lPropNum,
long lPropAlias) = 0;
/// Returns property value
/**
* @param lPropNum - property index (starting with 0)
* @param pvarPropVal - the pointer to a variable for property value
* @return the result of
*/
virtual bool ADDIN_API GetPropVal(const long lPropNum,
tVariant* pvarPropVal) = 0;
/// Sets the property value
/**
* @param lPropNum - property index (starting with 0)
* @param varPropVal - the pointer to a variable for property value
* @return the result of
*/
virtual bool ADDIN_API SetPropVal(const long lPropNum,
tVariant* varPropVal) = 0;
/// Is property readable?
/**
* @param lPropNum - property index (starting with 0)
* @return true if property is readable
*/
virtual bool ADDIN_API IsPropReadable(const long lPropNum) = 0;
/// Is property writable?
/**
* @param lPropNum - property index (starting with 0)
* @return true if property is writable
*/
virtual bool ADDIN_API IsPropWritable(const long lPropNum) = 0;
/// Returns number of component methods
/**
* @return number of component methods
*/
virtual long ADDIN_API GetNMethods() = 0;
/// Finds a method by name
/**
* @param wsMethodName - method name
* @return - method index
*/
virtual long ADDIN_API FindMethod(const WCHAR_T* wsMethodName) = 0;
/// Returns method name
/**
* @param lMethodNum - method index(starting with 0)
* @param lMethodAlias - 0 - international alias,
* 1 - russian alias. (International alias is required)
* @return method name or 0 if method is not found
*/
virtual const WCHAR_T* ADDIN_API GetMethodName(const long lMethodNum,
const long lMethodAlias) = 0;
/// Returns number of method parameters
/**
* @param lMethodNum - method index (starting with 0)
* @return number of parameters
*/
virtual long ADDIN_API GetNParams(const long lMethodNum) = 0;
/// Returns default value of method parameter
/**
* @param lMethodNum - method index(starting with 0)
* @param lParamNum - parameter index (starting with 0)
* @param pvarParamDefValue - the pointer to a variable for default value
* @return the result of
*/
virtual bool ADDIN_API GetParamDefValue(const long lMethodNum,
const long lParamNum,
tVariant *pvarParamDefValue) = 0;
/// Does the method have a return value?
/**
* @param lMethodNum - method index (starting with 0)
* @return true if the method has a return value
*/
virtual bool ADDIN_API HasRetVal(const long lMethodNum) = 0;
/// Calls the method as a procedure
/**
* @param lMethodNum - method index (starting with 0)
* @param paParams - the pointer to array of method parameters
* @param lSizeArray - the size of array
* @return the result of
*/
virtual bool ADDIN_API CallAsProc(const long lMethodNum,
tVariant* paParams,
const long lSizeArray) = 0;
/// Calls the method as a function
/**
* @param lMethodNum - method index (starting with 0)
* @param pvarRetValue - the pointer to returned value
* @param paParams - the pointer to array of method parameters
* @param lSizeArray - the size of array
* @return the result of
*/
virtual bool ADDIN_API CallAsFunc(const long lMethodNum,
tVariant* pvarRetValue,
tVariant* paParams,
const long lSizeArray) = 0;
};
///////////////////////////////////////////////////////////////////////////
/**
* This interface is used to change component locale
*/
/// Base interface for component localization.
class LocaleBase
{
public:
virtual ~LocaleBase(){}
/// Changes component locale
/**
* @param loc - new locale (for Windows - rus_RUS,
* for Linux - ru_RU, etc...)
*/
virtual void ADDIN_API SetLocale(const WCHAR_T* loc) = 0;
};
///////////////////////////////////////////////////////////////////////////
/**
* The given interface is generalized, for its obligatory inheritance
* in implementing components.
*/
/// Base interface describing object as a set of properties and methods.
class IComponentBase :
public IInitDoneBase,
public ILanguageExtenderBase,
public LocaleBase
{
public:
virtual ~IComponentBase(){}
};
enum AppCapabilities
{
eAppCapabilitiesInvalid = -1,
eAppCapabilities1 = 1,
eAppCapabilitiesLast = eAppCapabilities1,
};
/// Announcements of exported functions
/**
* These functions should be implemented that component can be loaded and created.
*/
extern "C" long GetClassObject(const WCHAR_T*, IComponentBase** pIntf);
extern "C" long DestroyObject(IComponentBase** pIntf);
extern "C" const WCHAR_T* GetClassNames();
extern "C" AppCapabilities SetPlatformCapabilities(const AppCapabilities capabilities);
typedef long (*GetClassObjectPtr)(const WCHAR_T* wsName, IComponentBase** pIntf);
typedef long (*DestroyObjectPtr)(IComponentBase** pIntf);
typedef const WCHAR_T* (*GetClassNamesPtr)();
typedef AppCapabilities (*SetPlatformCapabilitiesPtr)(const AppCapabilities capabilities);
#endif //__COMPONENT_BASE_H__