update dev300-m58
[ooovba.git] / framework / inc / services / detectorfactory.hxx
blobcf7b9824fe688a2ed8d648e24d9e27b2a957d4cb
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: detectorfactory.hxx,v $
10 * $Revision: 1.4 $
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_SERVICES_DETECTORFACTORY_HXX_
32 #define __FRAMEWORK_SERVICES_DETECTORFACTORY_HXX_
34 //_______________________________________________
35 // includes of own project
37 #include <classes/filtercache.hxx>
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/xinterface.hxx>
40 #include <macros/xtypeprovider.hxx>
41 #include <macros/xserviceinfo.hxx>
42 #include <macros/generic.hxx>
43 #include <macros/debug.hxx>
44 #include <general.h>
46 //_______________________________________________
47 // includes of interfaces
48 #include <com/sun/star/beans/PropertyValue.hpp>
49 #include <com/sun/star/lang/XInitialization.hpp>
50 #include <com/sun/star/lang/WrappedTargetException.hpp>
51 #include <com/sun/star/lang/IllegalArgumentException.hpp>
52 #include <com/sun/star/container/ElementExistException.hpp>
53 #include <com/sun/star/container/NoSuchElementException.hpp>
54 #include <com/sun/star/container/XNameContainer.hpp>
55 #include <com/sun/star/container/NoSuchElementException.hpp>
56 #include <com/sun/star/io/XInputStream.hpp>
57 #include <com/sun/star/util/XFlushable.hpp>
59 //_______________________________________________
60 // includes of other projects
61 #include <cppuhelper/interfacecontainer.hxx>
62 #include <cppuhelper/weak.hxx>
64 //_______________________________________________
65 // namespace
67 namespace framework{
69 //_______________________________________________
70 // exported const
72 //_______________________________________________
73 // exported definitions
75 /// @HTML
76 /** @short factory to create detect service objects and initialize it in the right way.
78 @descr This class can be used to create new detect services for specified contents.
79 It uses cached values of the configuration to lay down, which detector match
80 a given name. Further this class provides full access to the configuration data
81 of such detect services and following implementations will support some special
82 query modes.
84 @author as96863
86 @docdate 07.03.2003 by as96863
88 @todo <ul>
89 <li>implementation of query mode</li>
90 <li>simple restore mechanism of last consistent cache state,
91 if flush failed</li>
92 </ul>
94 /// @NOHTML
96 class DetectorFactory : // interfaces
97 public css::lang::XTypeProvider ,
98 public css::lang::XServiceInfo ,
99 public css::lang::XMultiServiceFactory ,
100 public css::container::XNameContainer , // => XNameReplace => XNameAccess => XElementAccess
101 public css::util::XFlushable ,
102 // base classes
103 // Order is neccessary for right initialization of it!
104 private ThreadHelpBase ,
105 public ::cppu::OWeakObject
107 //-------------------------------------------
108 // member
110 private:
112 /** reference to the global uno service manager.
113 It will be used to create own needed services on demand. */
114 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
116 /** singleton, which contains all needed configuration data and provides
117 read/write access on it. */
118 FilterCache m_aCache;
120 /** contains all registered listener. */
121 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer;
123 //-------------------------------------------
124 // interface
126 public:
128 //---------------------------------------
129 // XInterface, XTypeProvider, XServiceInfo
131 DECLARE_XINTERFACE
132 DECLARE_XTYPEPROVIDER
133 DECLARE_XSERVICEINFO
135 #ifdef ENABLE_AUTODOC_FIX
137 #endif
139 //---------------------------------------
141 /** @short initialize new instance of this class.
143 @param xSMGR
144 reference to the global uno service manager, which created this new factory instance.
145 It must be used during runtime to create own needed services.
148 DetectorFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
150 //---------------------------------------
152 /** @short release internal structures.
155 virtual ~DetectorFactory();
157 //---------------------------------------
158 // XMultiServiceFactory
160 /** @short create a new detect service and initialize it with it's own configuration data.
162 @param sName
163 means the uno implementation name of a detect service.
165 @exception com::sun::star::uno::Exception
166 if the requested service could not be created or initialized.
169 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& sName )
170 throw(css::uno::Exception ,
171 css::uno::RuntimeException);
173 //---------------------------------------
174 // XMultiServiceFactory
176 /** @short does the same as createInstance() method, but initialize created detect service with some
177 additional data.
179 @param sName
180 means the uno implementation name of a detect service.
182 @param lArguments
183 the optional arguments, which are passed to the created detect service against
184 it's own configuration data.
186 @exception com::sun::star::uno::Exception
187 if the requested service could not be created or initialized.
190 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& sName ,
191 const css::uno::Sequence< css::uno::Any >& lArguments )
192 throw(css::uno::Exception ,
193 css::uno::RuntimeException);
195 //---------------------------------------
196 // XMultiServiceFactory
198 /** @short return list of all well know detect services, which can be created by this factory.
200 @attention Because this service implements read/write access to the configuration too,
201 this list is dynamic. Means: in multithreaded environments some items of this
202 return list could be invalid next time!
204 @return A list of all registered detect services.
207 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames()
208 throw(css::uno::RuntimeException);
210 //---------------------------------------
211 // XNameContainer
213 /** @short add new detect service entry to this container.
215 @descr This will change all internal structures only!
216 Updating of the configuration layer and notify of all registered
217 listener will be done inside API call XFlushable::flush() on this
218 container.
220 @param sName
221 means the uno implementation name of this new detect service entry.
223 @param aPropertySet [sequence< com::sun::star::beans::PropertyValue >!]
224 describe this new entry. For a list of all supported properties
225 have a look on method >>getByName()<<.
226 Note: Missing values will be created with defaults!
228 @exception com::sun::star::lang::IllegalArgumentException
229 if one of the incoming parameters seams to be invalid.
230 That doesn't include the check, if this item already exist!
232 @exception com::sun::star::container::ElementExistException
233 if this item already exist inside this container.
235 @exception com::sun::star::lang::WrappedTargetException
236 f creation of the internal structures failed.
239 virtual void SAL_CALL insertByName( const ::rtl::OUString& sName ,
240 const css::uno::Any& aPropertySet )
241 throw(css::lang::IllegalArgumentException ,
242 css::container::ElementExistException,
243 css::lang::WrappedTargetException ,
244 css::uno::RuntimeException );
246 //---------------------------------------
247 // XNameContainer
249 /** @short remove a detect service entry from this container.
251 @descr This will change all internal structures only!
252 Updating of the configuration layer and notify of all registered
253 listener will be done inside API call XFlushable::flush() on this
254 container.
256 @param sName
257 means the uno implementation name of a detect service entry.
259 @exception com::sun::star::container::NoSuchElementException
260 if the requested item does not exist inside this container.
262 @exception com::sun::star::lang::WrappedTargetException
263 if creation of the internal structures failed.
266 virtual void SAL_CALL removeByName( const ::rtl::OUString& sName )
267 throw(css::container::NoSuchElementException,
268 css::lang::WrappedTargetException ,
269 css::uno::RuntimeException );
271 //---------------------------------------
272 // XNameReplace
274 /** @short change a detect service entry inside this container.
276 @descr This will change all internal structures only!
277 Updating of the configuration layer and notify of all registered
278 listener will be done inside API call XFlushable::flush() on this
279 container.
281 @param sName
282 means the uno implementation name of a detect service entry.
284 @param aPropertySet [sequence< com::sun::star::beans::PropertyValue >!]
285 describe the changes on this entry. For a list of all supported properties
286 have a look on method getByName().
287 Note: Missing properties will be untouched.
289 @exception com::sun::star::lang::IllegalArgumentException
290 if one of the incoming parameters seams to be invalid.
291 That doesn't include the check, if this item exist!
293 @exception com::sun::star::container::NoSuchElementException
294 if the requested item does not exist inside this container.
296 @exception com::sun::star::lang::WrappedTargetException
297 if updating of the internal structures failed.
300 virtual void SAL_CALL replaceByName( const ::rtl::OUString& sName ,
301 const css::uno::Any& aPropertySet )
302 throw(css::lang::IllegalArgumentException ,
303 css::container::NoSuchElementException,
304 css::lang::WrappedTargetException ,
305 css::uno::RuntimeException );
307 //---------------------------------------
308 // XNameAccess
310 /// @HTML
311 /** @short return properties of queried detector item.
313 @descr Use this method to get all informations about a detector item of this cache.
314 A sequence< com::sun::star::beans::PropertyValue > packed inside an Any will be returned.
315 Following properties are defined:
316 <table border=1>
317 <tr>
318 <td><b>Property</b></td>
319 <td><b>Value<b></td>
320 <td><b>Description<b></td>
321 </tr>
322 <tr>
323 <td>Name</td>
324 <td>[string]</td>
325 <td>the uno implementation name for this detect service</td>
326 </tr>
327 <tr>
328 <td>Types</td>
329 <td>[sequence< string >]</td>
330 <td>a list of all internbal type names, which this detect service is registered for</td>
331 </tr>
332 </table>
334 @param sName
335 the uno implementation name the requested detector.
337 @return A property set, which describe this detect service.
338 It uses a sequence< com::sun::star::beans::PropertyValue > internaly.
340 @exception com::sun::star::container::NoSuchElementException
341 if the requested entry does not exist inside this container.
343 /// @NOHTML
345 virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& sName )
346 throw(css::container::NoSuchElementException,
347 css::lang::WrappedTargetException ,
348 css::uno::RuntimeException );
350 //---------------------------------------
351 // XNameAccess
353 /** @short return list of all well know container entries available on this container.
355 @attention Because this service implements read/write access to the configuration too,
356 this list is dynamic. Means: in multithreaded environments some items of this
357 return list could be invalid next time!
359 @return A list of all well known container items.
362 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
363 throw(css::uno::RuntimeException);
365 //---------------------------------------
366 // XNameAccess
368 /** @short check if searched entry exist inside this container.
370 @attention In multithreaded environments it's not guaranteed, that a
371 queried item exist next time realy! It can be deleted by
372 another thread ...
374 @param sName
375 the name of the queried container entry.
377 @return TRUE if the requested item exist; FALSE otherwise.
380 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& sName )
381 throw(css::uno::RuntimeException);
383 //---------------------------------------
384 // XElementAccess
386 /** @short return the uno type, which is used for all container items.
388 @return Type of sequence< com::sun::star::beans::PropertyValue > everytime - because it's fix.
391 virtual css::uno::Type SAL_CALL getElementType()
392 throw(css::uno::RuntimeException);
394 //---------------------------------------
395 // XElementAccess
397 /** @short return fill state of this cache.
399 @return TRUE if any item exist inside this conatiner; FALSE otherwhise.
402 virtual sal_Bool SAL_CALL hasElements()
403 throw(css::uno::RuntimeException);
405 //---------------------------------------
406 // XFlushable
408 /** @short update the configuration layer and notify all registered listener.
410 @descr All container interface methods update the internal structures of
411 this container only. But the underlying configuration layer and
412 may some possible other caches was not updated.
413 Calling of flush() will do that.
414 At the same time all currently registered flush listener will be informed,
415 so they can update her structures too.
416 Note: Before all these operations are started realy, all changes will be
417 verified and if neccessary some corrections will be done.
418 In case the cache will be invalid and could not be repaired an exception is thrown!
419 Normaly this container will not work correctly afterwards ...
421 @exception com::sun::star::uno::RuntimeException
422 if the changes on this container was invald and could not be repaired.
425 virtual void SAL_CALL flush()
426 throw(css::uno::RuntimeException);
428 //---------------------------------------
429 // XFlushable
431 /** @short register listener for container updates.
433 @param xListener
434 reference to listener, which wish to be registered.
436 @exception com::sun::star::uno::RuntimeException
437 if the given listener is an invalid reference.
438 Note: multiple calls of this method for the same listener won't be checked!
441 virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener )
442 throw(css::uno::RuntimeException);
444 //---------------------------------------
445 // XFlushable
447 /** @short deregister listener for container updates.
449 @param xListener
450 reference to listener, which wish to be deregistered.
452 @exception com::sun::star::uno::RuntimeException
453 if the given listener is an invalid reference.
454 Note: multiple calls of this method for the same listener won't be checked!
457 virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener )
458 throw(css::uno::RuntimeException);
460 }; // class DetectorFactory
462 } // namespace framework
464 #endif // #ifndef __FRAMEWORK_SERVICES_DETECTORFACTORY_HXX_