update dev300-m58
[ooovba.git] / framework / inc / classes / servicemanager.hxx
blob2c9f9a551f0958944d1690145e6637897c266001
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: servicemanager.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #ifndef __FRAMEWORK_CLASSES_SERVICEMANAGER_HXX_
32 #define __FRAMEWORK_CLASSES_SERVICEMANAGER_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <macros/debug.hxx>
40 //_________________________________________________________________________________________________________________
41 // interface includes
42 //_________________________________________________________________________________________________________________
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 //_________________________________________________________________________________________________________________
46 // other includes
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/uno/Reference.hxx>
49 #include <rtl/ustring.hxx>
50 #include <osl/mutex.hxx>
52 //_________________________________________________________________________________________________________________
53 // namespace
54 //_________________________________________________________________________________________________________________
56 namespace framework{
58 #define REFERENCE ::com::sun::star::uno::Reference
59 #define XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory
60 #define OUSTRING ::rtl::OUString
61 #define MUTEX ::osl::Mutex
63 //_________________________________________________________________________________________________________________
64 // exported const
65 //_________________________________________________________________________________________________________________
67 //_________________________________________________________________________________________________________________
68 // exported definitions
69 //_________________________________________________________________________________________________________________
71 /*-************************************************************************************************************//**
72 @short create a new global servicemanager
73 @descr A global servicemanager is neccessary to instanciate UNO-services. To do this, you need
74 a factory to create new objects with special type. That's the reason for a servicemanager.
76 @implements -
77 @base -
79 @devstatus ready to use
80 *//*-*************************************************************************************************************/
82 class ServiceManager
84 //-------------------------------------------------------------------------------------------------------------
85 // public methods
86 //-------------------------------------------------------------------------------------------------------------
88 public:
90 //---------------------------------------------------------------------------------------------------------
91 // constructor / destructor
92 //---------------------------------------------------------------------------------------------------------
94 /*-****************************************************************************************************//**
95 @short standard constructor
96 @descr This method don't initialize the new global servicemanager!
97 But we increase an internal ref count. These is needed in dtor to release
98 all created static references to created service mamanger!
100 @seealso dtor
102 @param -
103 @return -
105 @onerror -
106 *//*-*****************************************************************************************************/
108 ServiceManager();
110 /*-****************************************************************************************************//**
111 @short standard destructor to delete instance
112 @descr Here is a good place to destroy the global manager instances!
114 @seealso ctor
116 @param -
117 @return -
119 @onerror -
120 *//*-*****************************************************************************************************/
122 virtual ~ServiceManager();
124 /*-****************************************************************************************************//**
125 @short initialize global uno service manager and return it
126 @descr This method create a new manager only at first call. We confiscate this with a static
127 pointer, which will be initialized only, if it NULL!
128 Then you can call this method everytime to get a reference to the manager.
129 If you will initialize an uno application you must set returned reference in ::comphelper::setProcessServiceFactory()!
130 The created manager use "applicat.rdb" and "userXX.rdb" automaticly.
132 @seealso -
134 @param -
135 @return A reference to the global servicemanager. It can be NULL!
137 @onerror We return a null-reference.
138 *//*-*****************************************************************************************************/
140 REFERENCE< XMULTISERVICEFACTORY > getGlobalUNOServiceManager();
142 /*-****************************************************************************************************//**
143 @short initialize global uno service manager and return it
144 @descr Do the same like getGlobalUNOServiceManager() before, but use "applicat.rdb" only!
146 @seealso -
148 @param -
149 @return A reference to the global servicemanager. It can be NULL!
151 @onerror We return a null-reference.
152 *//*-*****************************************************************************************************/
154 REFERENCE< XMULTISERVICEFACTORY > getSimpleGlobalUNOServiceManager();
156 /*-****************************************************************************************************//**
157 @short return a reference to a uno servicemanager instance which use your specified user registry file
158 @descr This do the same like method before - but instead of "userXX.rdb" we use your file.
159 These is neccessary, if you will run more then one uno application at the same time in same environment!
160 All created servicemanager use the same "applicat.rdb" but different user registries.
162 @ATTENTION Given file name must be a full qualified system file name. If file not already exist we create a new one!
163 "applicat.rdb", "userXX.rdb" are not valid values!
165 @seealso method generateGlobalUNOServiceManager()
166 @seealso method generatePrivateUNOServiceManager()
168 @param "sUserRegistryFile", full qualified system file name of user registry
169 @return A reference to the created servicemanager. It can be NULL!
171 @onerror We return a null-reference.
172 *//*-*****************************************************************************************************/
174 REFERENCE< XMULTISERVICEFACTORY > getSharedUNOServiceManager( const OUSTRING& sUserRegistryFile );
176 /*-****************************************************************************************************//**
177 @short return a reference to a uno servicemanager instance which use your specified user registry file only
178 @descr This do the same like methods before - but use your file as the only one registry.
179 "applicat.rdb" is used here!
181 @ATTENTION Given file name must be a full qualified system file name. If file not already exist we create a new one!
182 "applicat.rdb", "userXX.rdb" are not valid values!
183 If file was new created - you must register services at runtime himself.
184 Otherwise no service could be created by these manager ...
186 @seealso method generateGlobalUNOServiceManager()
187 @seealso method generateSharedUNOServiceManager()
189 @param "sUserRegistryFile", full qualified system file name of user registry
190 @return A reference to the created servicemanager. It can be NULL!
192 @onerror We return a null-reference.
193 *//*-*****************************************************************************************************/
195 REFERENCE< XMULTISERVICEFACTORY > getPrivateUNOServiceManager( const OUSTRING& sUserRegistryFile );
197 //-------------------------------------------------------------------------------------------------------------
198 // protected methods
199 //-------------------------------------------------------------------------------------------------------------
201 protected:
203 //-------------------------------------------------------------------------------------------------------------
204 // private methods
205 //-------------------------------------------------------------------------------------------------------------
207 private:
209 /*-****************************************************************************************************//**
210 @short create our own global mutex to prevent us against multithreaded problems
211 @descr We use some static member. For correct access to it we must use the global osl mutex ...
212 but its not fine to do so! These block ALL other operations, which need these mutex too.
213 That's the reason to create our own static mutex. Only first creation is protected
214 by the global mutex, using isn't it!
216 @seealso using
218 @param -
219 @return reference to created static own global mutex
221 @onerror No error should occure.
222 *//*-*****************************************************************************************************/
224 MUTEX& impl_getOwnGlobalMutex();
226 /*-****************************************************************************************************//**
227 @short create a new global servicemanager instance
228 @descr Is a helper-method for getManager().
230 @seealso method getManager()
232 @param "sRegistryFile", file name of user registry.
233 @return A reference to a new initialized servicemanager with a valid registry.
234 It can be NULL, if an error occured.
236 @onerror Return a NULL-reference.
237 *//*-*****************************************************************************************************/
239 REFERENCE< XMULTISERVICEFACTORY > impl_createManager( const OUSTRING& sRegistryFile );
241 //-------------------------------------------------------------------------------------------------------------
242 // debug methods
243 // (should be private everyway!)
244 //-------------------------------------------------------------------------------------------------------------
246 /*-****************************************************************************************************//**
247 @short debug-method to check incoming parameter of some other mehods of this class
248 @descr The following methods are used to check parameters for other methods
249 of this class. The return value is used directly for an ASSERT(...).
251 @seealso ASSERTs in implementation!
253 @param references to checking variables
254 @return sal_False on invalid parameter<BR>
255 sal_True otherway
257 @onerror -
258 *//*-*****************************************************************************************************/
260 #ifdef ENABLE_ASSERTIONS
262 private:
264 #endif // #ifdef ENABLE_ASSERTIONS
266 //-------------------------------------------------------------------------------------------------------------
267 // private variables
268 // (should be private everyway!)
269 //-------------------------------------------------------------------------------------------------------------
271 private:
273 static REFERENCE< XMULTISERVICEFACTORY >* m_pGlobalServiceManager ;
274 static REFERENCE< XMULTISERVICEFACTORY >* m_pSimpleGlobalServiceManager ;
275 static REFERENCE< XMULTISERVICEFACTORY >* m_pSharedServiceManager ;
276 static REFERENCE< XMULTISERVICEFACTORY >* m_pPrivateServiceManager ;
277 static sal_Int32 m_nRefCount ;
279 }; // class ServiceManager
281 } // namespace framework
283 #endif // #ifndef __FRAMEWORK_CLASSES_SERVICEMANAGER_HXX_