1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: moduledbu.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBAUI_MODULE_DBU_HXX_
35 #include "moduledbu.hxx"
38 #ifndef _TOOLS_RESMGR_HXX
39 #include <tools/resmgr.hxx>
42 #include <svtools/solar.hrc>
44 #ifndef _TOOLS_DEBUG_HXX
45 #include <tools/debug.hxx>
48 #define ENTER_MOD_METHOD() \
49 ::osl::MutexGuard aGuard(s_aMutex); \
52 //.........................................................................
55 //.........................................................................
57 //=========================================================================
59 //=========================================================================
60 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
64 ResMgr
* m_pRessources
;
71 /// get the manager for the ressources of the module
72 ResMgr
* getResManager();
76 //-------------------------------------------------------------------------
77 OModuleImpl::OModuleImpl()
80 DBG_CTOR(OModuleImpl
,NULL
);
84 //-------------------------------------------------------------------------
85 OModuleImpl::~OModuleImpl()
90 DBG_DTOR(OModuleImpl
,NULL
);
93 //-------------------------------------------------------------------------
94 ResMgr
* OModuleImpl::getResManager()
96 // note that this method is not threadsafe, which counts for the whole class !
100 // create a manager with a fixed prefix
101 ByteString aMgrName
= ByteString( "dbu" );
102 m_pRessources
= ResMgr::CreateResMgr(aMgrName
.GetBuffer());
104 return m_pRessources
;
107 //=========================================================================
109 //=========================================================================
110 ::osl::Mutex
OModule::s_aMutex
;
111 sal_Int32
OModule::s_nClients
= 0;
112 OModuleImpl
* OModule::s_pImpl
= NULL
;
113 //-------------------------------------------------------------------------
114 ResMgr
* OModule::getResManager()
117 return s_pImpl
->getResManager();
120 //-------------------------------------------------------------------------
121 void OModule::registerClient()
123 ::osl::MutexGuard
aGuard(s_aMutex
);
127 //-------------------------------------------------------------------------
128 void OModule::revokeClient()
130 ::osl::MutexGuard
aGuard(s_aMutex
);
131 if (!--s_nClients
&& s_pImpl
)
138 //-------------------------------------------------------------------------
139 void OModule::ensureImpl()
143 s_pImpl
= new OModuleImpl();
146 //.........................................................................
148 //.........................................................................