xref: /aoo41x/main/framework/inc/jobs/jobexecutor.hxx (revision f8e07b45)
1*f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e07b45SAndrew Rist  * distributed with this work for additional information
6*f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e07b45SAndrew Rist  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e07b45SAndrew Rist  *
13*f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15*f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18*f8e07b45SAndrew Rist  * under the License.
19*f8e07b45SAndrew Rist  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________
28cdf0e10cSrcweir // my own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <jobs/configaccess.hxx>
31cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
32cdf0e10cSrcweir #include <macros/xinterface.hxx>
33cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
34cdf0e10cSrcweir #include <macros/xserviceinfo.hxx>
35cdf0e10cSrcweir #include <macros/debug.hxx>
36cdf0e10cSrcweir #include <stdtypes.h>
37cdf0e10cSrcweir #include <general.h>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //_______________________________________
40cdf0e10cSrcweir // interface includes
41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42cdf0e10cSrcweir #include <com/sun/star/task/XJobExecutor.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
46cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp>
47cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //_______________________________________
50cdf0e10cSrcweir // other includes
51cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
52cdf0e10cSrcweir #include <rtl/ustring.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //_______________________________________
55cdf0e10cSrcweir // namespace
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace framework{
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //_______________________________________
60cdf0e10cSrcweir // public const
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //_______________________________________
63cdf0e10cSrcweir /**
64cdf0e10cSrcweir     @short  implements a job executor, which can be triggered from any code
65cdf0e10cSrcweir     @descr  It uses the given trigger event to locate any registered job service
66cdf0e10cSrcweir             inside the configuration and execute it. Of course it controls the
67cdf0e10cSrcweir             liftime of such jobs too.
68cdf0e10cSrcweir  */
69cdf0e10cSrcweir class JobExecutor : public  css::lang::XTypeProvider
70cdf0e10cSrcweir                   , public  css::lang::XServiceInfo
71cdf0e10cSrcweir                   , public  css::task::XJobExecutor
72cdf0e10cSrcweir                   , public  css::container::XContainerListener // => lang.XEventListener
73cdf0e10cSrcweir                   , public  css::document::XEventListener
74cdf0e10cSrcweir                   , private ThreadHelpBase
75cdf0e10cSrcweir                   , public  ::cppu::OWeakObject
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     //___________________________________
78cdf0e10cSrcweir     // member
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     private:
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         /** reference to the uno service manager */
83cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         /** reference to the module info service */
86cdf0e10cSrcweir         css::uno::Reference< css::frame::XModuleManager > m_xModuleManager;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         /** cached list of all registered event names of cfg for call optimization. */
89cdf0e10cSrcweir         OUStringList m_lEvents;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         /** we listen at the configuration for changes at the event list. */
92cdf0e10cSrcweir         ConfigAccess m_aConfig;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     //___________________________________
95cdf0e10cSrcweir     // native interface methods
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     public:
98cdf0e10cSrcweir 
99cdf0e10cSrcweir                   JobExecutor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
100cdf0e10cSrcweir          virtual ~JobExecutor(                                                                     );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     //___________________________________
103cdf0e10cSrcweir     // uno interface methods
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     public:
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         // XInterface, XTypeProvider, XServiceInfo
108cdf0e10cSrcweir         FWK_DECLARE_XINTERFACE
109cdf0e10cSrcweir         FWK_DECLARE_XTYPEPROVIDER
110cdf0e10cSrcweir         DECLARE_XSERVICEINFO
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         // task.XJobExecutor
113cdf0e10cSrcweir         virtual void SAL_CALL trigger( const ::rtl::OUString& sEvent ) throw(css::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // document.XEventListener
116cdf0e10cSrcweir         virtual void SAL_CALL notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         // container.XContainerListener
119cdf0e10cSrcweir         virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
120cdf0e10cSrcweir         virtual void SAL_CALL elementRemoved ( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
121cdf0e10cSrcweir         virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         // lang.XEventListener
124cdf0e10cSrcweir         virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir } // namespace framework
128cdf0e10cSrcweir 
129cdf0e10cSrcweir #endif // __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
130