update dev300-m58
[ooovba.git] / cppu / inc / uno / environment.h
blob3b64cdf8127963d8b4668384fe04d9a3659cb727
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: environment.h,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _UNO_ENVIRONMENT_H_
31 #define _UNO_ENVIRONMENT_H_
33 #include <sal/types.h>
34 #include <rtl/ustring.h>
36 #include <stdarg.h>
38 #ifdef __cplusplus
39 extern "C"
41 #endif
43 struct _uno_ExtEnvironment;
44 struct _typelib_InterfaceTypeDescription;
46 #if defined( SAL_W32)
47 #pragma pack(push, 8)
48 #elif defined(SAL_OS2)
49 #pragma pack(push, 8)
50 #endif
52 /** The binary specification of an UNO environment.
54 typedef struct _uno_Environment
56 /** reserved for future use (0 if not used)
58 void * pReserved;
60 /** type name of environment
62 rtl_uString * pTypeName;
64 /** free context pointer to be used for specific classes of environments (e.g., a jvm pointer)
66 void * pContext;
68 /** pointer to extended environment (interface registration functionality), if supported
70 struct _uno_ExtEnvironment * pExtEnv;
72 /** Acquires this environment.
74 @param pEnv this environment
76 void (SAL_CALL * acquire)( struct _uno_Environment * pEnv );
78 /** Releases this environment; last release of environment will revoke the environment from
79 runtime.
81 @param pEnv this environment
83 void (SAL_CALL * release)( struct _uno_Environment * pEnv );
85 /** Acquires this environment weakly. You can only harden a weakly held environment if it
86 is still acquired hard (acquire()).
88 @param pEnv this environment
90 void (SAL_CALL * acquireWeak)( struct _uno_Environment * pEnv );
92 /** Releases this environment weakly in correspondence to acquireWeak().
94 @param pEnv this environment
96 void (SAL_CALL * releaseWeak)( struct _uno_Environment * pEnv );
98 /** Makes hard reference out of weak referenced environment. You can only harden a weakly
99 held environment if it is still acquired hard (acquire()).
101 @param ppHardEnv inout hard referenced environment (has to be released via release())
102 @param pEnv environment (may be weak referenced)
104 void (SAL_CALL * harden)(
105 struct _uno_Environment ** ppHardEnv,
106 struct _uno_Environment * pEnv );
108 /** Call this function to EXPLICITLY dispose this environment (e.g., release all
109 interfaces). You may want to call this function before shutting down due to a runtime error.
111 @param pEnv this environment
113 void (SAL_CALL * dispose)( struct _uno_Environment * pEnv );
115 /* ===== the following part will be late initialized by a matching bridge ===== *
116 * ===== and is NOT for public use. ===== */
118 /** CALLBACK function pointer: Disposing callback function pointer that can be set to get
119 signalled before the environment is destroyed.
121 @param pEnv environment that is being disposed
123 void (SAL_CALL * environmentDisposing)( struct _uno_Environment * pEnv );
124 } uno_Environment;
126 /** Generic function pointer declaration to free a proxy object if it is not needed by the
127 environment anymore.
128 Any proxy object must register itself on first acquire() call and revoke itself on last
129 release() call. This can happen several times because the environment caches proxy objects
130 until the environment explicitly frees the proxy object calling this function.
132 @param pEnv environment
133 @param pProxy proxy pointer
135 typedef void (SAL_CALL * uno_freeProxyFunc)( struct _uno_ExtEnvironment * pEnv, void * pProxy );
137 /** Generic function pointer declaration to allocate memory. Used with getRegisteredInterfaces().
139 @param nBytes amount of memory in bytes
140 @return pointer to allocated memory
142 typedef void * (SAL_CALL * uno_memAlloc)( sal_Size nBytes );
144 /** The binary specification of an UNO environment supporting interface registration.
146 typedef struct _uno_ExtEnvironment
148 /** inherits all members of an uno_Environment
150 uno_Environment aBase;
152 /** Registers an interface of this environment.
154 @param pEnv this environment
155 @param ppInterface inout parameter of interface to be registered
156 @param pOId object id of interface
157 @param pTypeDescr type description of interface
159 void (SAL_CALL * registerInterface)(
160 struct _uno_ExtEnvironment * pEnv,
161 void ** ppInterface,
162 rtl_uString * pOId,
163 struct _typelib_InterfaceTypeDescription * pTypeDescr );
165 /** Registers a proxy interface of this environment that can be reanimated and is freed
166 explicitly by this environment.
168 @param pEnv this environment
169 @param ppInterface inout parameter of interface to be registered
170 @param freeProxy function to free proxy object
171 @param pOId object id of interface
172 @param pTypeDescr type description of interface
174 void (SAL_CALL * registerProxyInterface)(
175 struct _uno_ExtEnvironment * pEnv,
176 void ** ppProxy,
177 uno_freeProxyFunc freeProxy,
178 rtl_uString * pOId,
179 struct _typelib_InterfaceTypeDescription * pTypeDescr );
181 /** Revokes an interface from this environment. You have to revoke any interface that has
182 been registered via this method.
184 @param pEnv this environment
185 @param pInterface interface to be revoked
187 void (SAL_CALL * revokeInterface)(
188 struct _uno_ExtEnvironment * pEnv,
189 void * pInterface );
191 /** Provides the object id of a given interface.
193 @param ppOut inout oid
194 @param pInterface interface of object
196 void (SAL_CALL * getObjectIdentifier)(
197 struct _uno_ExtEnvironment * pEnv,
198 rtl_uString ** ppOId,
199 void * pInterface );
201 /** Retrieves an interface identified by its object id and type from this environment.
202 Interfaces are retrieved in the same order as they are registered.
204 @param pEnv this environment
205 @param ppInterface inout parameter for the registered interface; (0) if none was found
206 @param pOId object id of interface to be retrieved
207 @param pTypeDescr type description of interface to be retrieved
209 void (SAL_CALL * getRegisteredInterface)(
210 struct _uno_ExtEnvironment * pEnv,
211 void ** ppInterface,
212 rtl_uString * pOId,
213 struct _typelib_InterfaceTypeDescription * pTypeDescr );
215 /** Returns all currently registered interfaces of this environment. The memory block
216 allocated might be slightly larger than (*pnLen * sizeof(void *)).
218 @param pEnv this environment
219 @param pppInterfaces out param; pointer to array of interface pointers
220 @param pnLen out param; length of array
221 @param memAlloc function for allocating memory that is passed back
223 void (SAL_CALL * getRegisteredInterfaces)(
224 struct _uno_ExtEnvironment * pEnv,
225 void *** pppInterfaces,
226 sal_Int32 * pnLen,
227 uno_memAlloc memAlloc );
229 /* ===== the following part will be late initialized by a matching bridge ===== */
231 /** Computes an object id of the given interface; is called by the environment implementation.
233 @param pEnv corresponding environment
234 @param ppOId out param: computed id
235 @param pInterface an interface
237 void (SAL_CALL * computeObjectIdentifier)(
238 struct _uno_ExtEnvironment * pEnv,
239 rtl_uString ** ppOId, void * pInterface );
241 /** Function to acquire an interface.
243 @param pEnv corresponding environment
244 @param pInterface an interface
246 void (SAL_CALL * acquireInterface)(
247 struct _uno_ExtEnvironment * pEnv,
248 void * pInterface );
250 /** Function to release an interface.
252 @param pEnv corresponding environment
253 @param pInterface an interface
255 void (SAL_CALL * releaseInterface)(
256 struct _uno_ExtEnvironment * pEnv,
257 void * pInterface );
259 } uno_ExtEnvironment;
261 #if defined( SAL_W32) || defined(SAL_OS2)
262 #pragma pack(pop)
263 #endif
265 /** Function exported by some bridge library providing acquireInterface(), releaseInterface();
266 may set a disposing callback.
268 @param pEnv environment to be initialized
270 typedef void (SAL_CALL * uno_initEnvironmentFunc)( uno_Environment * pEnv );
271 #define UNO_INIT_ENVIRONMENT "uno_initEnvironment"
273 /** Gets a specific environment. If the specified environment does not exist, then a default one
274 is created and registered. The environment revokes itself on last release() call.
276 @param ppEnv inout parameter of environment; given environment will be released
277 @param pEnvDcp descriptor of environment
278 @param pContext some context pointer (e.g., to distinguish java vm; set 0 if not needed)
280 void SAL_CALL uno_getEnvironment(
281 uno_Environment ** ppEnv, rtl_uString * pEnvDcp, void * pContext )
282 SAL_THROW_EXTERN_C();
284 /** Gets all specified environments. Caller has to release returned environments and free allocated
285 memory.
287 @param pppEnvs out param; pointer to array of environments
288 @param pnLen out param; length of array
289 @param memAlloc function for allocating memory that is passed back
290 @param pEnvDcp descriptor of environments; 0 defaults to all
292 void SAL_CALL uno_getRegisteredEnvironments(
293 uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
294 rtl_uString * pEnvDcp )
295 SAL_THROW_EXTERN_C();
297 /** Creates an environment. The new environment is anonymous (NOT publicly registered/ accessible).
299 @param ppEnv out parameter of environment; given environment will be released
300 @param pEnvDcp descriptor of environment
301 @param pContext context pointer (e.g., to distinguish java vm); set 0 if not needed
303 void SAL_CALL uno_createEnvironment(
304 uno_Environment ** ppEnv, rtl_uString * pEnvDcp, void * pContext )
305 SAL_THROW_EXTERN_C();
307 /** Dumps out environment information, i.e. registered interfaces.
309 @param stream output stream (FILE *)
310 @param pEnv environment to be dumped
311 @param pFilter if not null, filters output
313 void SAL_CALL uno_dumpEnvironment(
314 void * stream, uno_Environment * pEnv, const sal_Char * pFilter )
315 SAL_THROW_EXTERN_C();
316 /** Dumps out environment information, i.e. registered interfaces.
318 @param stream output stream (FILE *)
319 @param pEnvDcp descritpro of environment to be dumped
320 @param pFilter if not null, filters output
322 void SAL_CALL uno_dumpEnvironmentByName(
323 void * stream, rtl_uString * pEnvDcp, const sal_Char * pFilter )
324 SAL_THROW_EXTERN_C();
328 /** Returns the current Environment.
329 In case no Environment has explicitly been entered, a purpose free
330 default environment gets returned (e.g. the "uno" or "gcc3" Environment).
332 @param ppEnv inout parameter; a given environment will be released
333 @param pTypeName the optional type of the environment, falls back to "uno"
334 @since UDK 3.2.7
336 void SAL_CALL uno_getCurrentEnvironment(uno_Environment ** ppEnv, rtl_uString * pTypeName)
337 SAL_THROW_EXTERN_C();
339 /** Typedef for variable argument function.
341 typedef void SAL_CALL uno_EnvCallee(va_list * pParam);
343 /** Invoke the passed function in the given environment.
345 @param pEnv the target environment
346 @param pCallee the function to call
347 @param pParam the parameter pointer passed to the function
348 @since UDK 3.2.7
350 void SAL_CALL uno_Environment_invoke_v(uno_Environment * pEnv, uno_EnvCallee * pCallee, va_list * pParam)
351 SAL_THROW_EXTERN_C();
353 /** Invoke the passed function in the given environment.
355 @param pEnv the target environment
356 @param pCallee the function to call
357 @param ... the parameters passed to the function
358 @since UDK 3.2.7
360 void SAL_CALL uno_Environment_invoke (uno_Environment * pEnv, uno_EnvCallee * pCallee, ...)
361 SAL_THROW_EXTERN_C();
363 /** Enter an environment explicitly.
365 @param pEnv the environment to enter; NULL leaves all environments
366 @since UDK 3.2.7
368 void SAL_CALL uno_Environment_enter(uno_Environment * pEnv)
369 SAL_THROW_EXTERN_C();
371 /** Check if a particular environment is currently valid, so
372 that objects of that environment might be called.
374 @param pEnv the environment
375 @param rtl_uString ** pReason the reason, if it is not valid
376 @return 1 == valid, 0 == invalid
377 @since UDK 3.2.7
379 int SAL_CALL uno_Environment_isValid(uno_Environment * pEnv, rtl_uString ** pReason)
380 SAL_THROW_EXTERN_C();
384 #ifdef __cplusplus
386 #endif
388 #endif