xref: /trunk/main/framework/inc/jobs/configaccess.hxx (revision f8e07b45)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
25 #define __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
26 
27 //_______________________________________
28 // my own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/debug.hxx>
32 #include <general.h>
33 
34 //_______________________________________
35 // interface includes
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 
38 //_______________________________________
39 // other includes
40 #include <rtl/ustring.hxx>
41 #include <fwidllapi.h>
42 
43 //_______________________________________
44 // namespace
45 
46 namespace framework{
47 
48 //_______________________________________
49 // public const
50 
51 //_______________________________________
52 /**
53     @short  implements a simple configuration access
54     @descr  Sometimes it's better to have direct config access
55             instead of using soecialize config items of the svtools
56             project. This class can wrapp such configuration access.
57  */
58 class FWI_DLLPUBLIC ConfigAccess : public ThreadHelpBase
59 {
60     //___________________________________
61     // const
62 
63     public:
64 
65         /** represent the possible modes of the internal wrapped configuration access */
66         enum EOpenMode
67         {
68             /// config isn't used yet
69             E_CLOSED,
70             /// config access is open for reading only
71             E_READONLY,
72             /// config access is open for reading/writing data
73             E_READWRITE
74         };
75 
76     //___________________________________
77     // member
78 
79     private:
80 
81         /**
82             reference to the uno service manager
83             It's neccessary to instanciate own needed services.
84          */
85         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
86 
87         /** hold an opened configuration alive */
88         css::uno::Reference< css::uno::XInterface > m_xConfig;
89 
90         /** knows the root of the opened config access point */
91         ::rtl::OUString m_sRoot;
92 
93         /** represent the current open mode */
94         EOpenMode m_eMode;
95 
96     //___________________________________
97     // native interface methods
98 
99     public:
100 
101                  ConfigAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
102                                const ::rtl::OUString&                                        sRoot );
103         virtual ~ConfigAccess();
104 
105         virtual void      open   ( EOpenMode eMode );
106         virtual void      close  (                 );
107         virtual EOpenMode getMode(                 ) const;
108 
109         virtual const css::uno::Reference< css::uno::XInterface >& cfg();
110 };
111 
112 } // namespace framework
113 
114 #endif // __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_
115