xref: /trunk/main/dbaccess/source/ui/inc/moduledbu.hxx (revision 2e2212a7)
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 _DBAUI_MODULE_DBU_HXX_
25 #define _DBAUI_MODULE_DBU_HXX_
26 
27 #ifndef _OSL_MUTEX_HXX_
28 #include <osl/mutex.hxx>
29 #endif
30 #ifndef _TOOLS_RESID_HXX
31 #include <tools/resid.hxx>
32 #endif
33 
34 class ResMgr;
35 
36 //.........................................................................
37 namespace dbaui
38 {
39 //.........................................................................
40 
41 //=========================================================================
42 //= OModule
43 //=========================================================================
44 class OModuleImpl;
45 class OModule
46 {
47 	friend class OModuleClient;
48 
49 private:
50 	OModule();
51 		// not implemented. OModule is a static class
52 
53 protected:
54 	static ::osl::Mutex	s_aMutex;		/// access safety
55 	static sal_Int32	s_nClients;		/// number of registered clients
56 	static OModuleImpl*	s_pImpl;		/// impl class. lives as long as at least one client for the module is registered
57 
58 public:
59 	/// get the vcl res manager of the module
60 	static ResMgr*	getResManager();
61 
62 protected:
63 	/// register a client for the module
64 	static void	registerClient();
65 	/// revoke a client for the module
66 	static void	revokeClient();
67 
68 private:
69 	/** ensure that the impl class exists
70 		@precond m_aMutex is guarded when this method gets called
71 	*/
72 	static void ensureImpl();
73 };
74 
75 //=========================================================================
76 //= OModuleClient
77 //=========================================================================
78 /** base class for objects which uses any global module-specific ressources
79 */
80 class OModuleClient
81 {
82 public:
OModuleClient()83 	OModuleClient()		{ OModule::registerClient(); }
~OModuleClient()84 	~OModuleClient()	{ OModule::revokeClient(); }
85 };
86 
87 //=========================================================================
88 //= ModuleRes
89 //=========================================================================
90 /** specialized ResId, using the ressource manager provided by the global module
91 */
92 class ModuleRes : public ::ResId
93 {
94 public:
ModuleRes(sal_uInt16 _nId)95 	ModuleRes(sal_uInt16 _nId) : ResId(_nId, *OModule::getResManager()) { }
96 };
97 
98 //.........................................................................
99 }	// namespace dbaui
100 //.........................................................................
101 
102 #endif // _DBAUI_MODULE_DBU_HXX_
103 
104