1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_ 29 #define __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_ 30 31 //_______________________________________ 32 // my own includes 33 34 #include <threadhelp/threadhelpbase.hxx> 35 #include <macros/debug.hxx> 36 #include <general.h> 37 38 //_______________________________________ 39 // interface includes 40 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41 42 //_______________________________________ 43 // other includes 44 #include <rtl/ustring.hxx> 45 #include <fwidllapi.h> 46 47 //_______________________________________ 48 // namespace 49 50 namespace framework{ 51 52 //_______________________________________ 53 // public const 54 55 //_______________________________________ 56 /** 57 @short implements a simple configuration access 58 @descr Sometimes it's better to have direct config access 59 instead of using soecialize config items of the svtools 60 project. This class can wrapp such configuration access. 61 */ 62 class FWI_DLLPUBLIC ConfigAccess : public ThreadHelpBase 63 { 64 //___________________________________ 65 // const 66 67 public: 68 69 /** represent the possible modes of the internal wrapped configuration access */ 70 enum EOpenMode 71 { 72 /// config isn't used yet 73 E_CLOSED, 74 /// config access is open for reading only 75 E_READONLY, 76 /// config access is open for reading/writing data 77 E_READWRITE 78 }; 79 80 //___________________________________ 81 // member 82 83 private: 84 85 /** 86 reference to the uno service manager 87 It's neccessary to instanciate own needed services. 88 */ 89 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 90 91 /** hold an opened configuration alive */ 92 css::uno::Reference< css::uno::XInterface > m_xConfig; 93 94 /** knows the root of the opened config access point */ 95 ::rtl::OUString m_sRoot; 96 97 /** represent the current open mode */ 98 EOpenMode m_eMode; 99 100 //___________________________________ 101 // native interface methods 102 103 public: 104 105 ConfigAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , 106 const ::rtl::OUString& sRoot ); 107 virtual ~ConfigAccess(); 108 109 virtual void open ( EOpenMode eMode ); 110 virtual void close ( ); 111 virtual EOpenMode getMode( ) const; 112 113 virtual const css::uno::Reference< css::uno::XInterface >& cfg(); 114 }; 115 116 } // namespace framework 117 118 #endif // __FRAMEWORK_CONFIG_CONFIGACCESS_HXX_ 119