xref: /AOO41X/main/framework/inc/jobs/configaccess.hxx (revision f8e07b45f7e1fb69563504f404bb0b75210f0be6)
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
10cdf0e10cSrcweir  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________
28cdf0e10cSrcweir // my own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
31cdf0e10cSrcweir #include <macros/debug.hxx>
32cdf0e10cSrcweir #include <general.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //_______________________________________
35cdf0e10cSrcweir // interface includes
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_______________________________________
39cdf0e10cSrcweir // other includes
40cdf0e10cSrcweir #include <rtl/ustring.hxx>
41cdf0e10cSrcweir #include <fwidllapi.h>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //_______________________________________
44cdf0e10cSrcweir // namespace
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace framework{
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //_______________________________________
49cdf0e10cSrcweir // public const
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //_______________________________________
52cdf0e10cSrcweir /**
53cdf0e10cSrcweir     @short  implements a simple configuration access
54cdf0e10cSrcweir     @descr  Sometimes it's better to have direct config access
55cdf0e10cSrcweir             instead of using soecialize config items of the svtools
56cdf0e10cSrcweir             project. This class can wrapp such configuration access.
57cdf0e10cSrcweir  */
58cdf0e10cSrcweir class FWI_DLLPUBLIC ConfigAccess : public ThreadHelpBase
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     //___________________________________
61cdf0e10cSrcweir     // const
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     public:
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         /** represent the possible modes of the internal wrapped configuration access */
66cdf0e10cSrcweir         enum EOpenMode
67cdf0e10cSrcweir         {
68cdf0e10cSrcweir             /// config isn't used yet
69cdf0e10cSrcweir             E_CLOSED,
70cdf0e10cSrcweir             /// config access is open for reading only
71cdf0e10cSrcweir             E_READONLY,
72cdf0e10cSrcweir             /// config access is open for reading/writing data
73cdf0e10cSrcweir             E_READWRITE
74cdf0e10cSrcweir         };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     //___________________________________
77cdf0e10cSrcweir     // member
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     private:
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         /**
82cdf0e10cSrcweir             reference to the uno service manager
83cdf0e10cSrcweir             It's neccessary to instanciate own needed services.
84cdf0e10cSrcweir          */
85cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         /** hold an opened configuration alive */
88cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > m_xConfig;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         /** knows the root of the opened config access point */
91cdf0e10cSrcweir         ::rtl::OUString m_sRoot;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         /** represent the current open mode */
94cdf0e10cSrcweir         EOpenMode m_eMode;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     //___________________________________
97cdf0e10cSrcweir     // native interface methods
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     public:
100cdf0e10cSrcweir 
101cdf0e10cSrcweir                  ConfigAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
102cdf0e10cSrcweir                                const ::rtl::OUString&                                        sRoot );
103cdf0e10cSrcweir         virtual ~ConfigAccess();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         virtual void      open   ( EOpenMode eMode );
106cdf0e10cSrcweir         virtual void      close  (                 );
107cdf0e10cSrcweir         virtual EOpenMode getMode(                 ) const;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         virtual const css::uno::Reference< css::uno::XInterface >& cfg();
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir } // namespace framework
113cdf0e10cSrcweir 
114cdf0e10cSrcweir #endif // __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
115