1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "moduledbu.hxx"
32 #include <tools/resmgr.hxx>
33 #include <svl/solar.hrc>
34 #include <tools/debug.hxx>
36 #define ENTER_MOD_METHOD() \
37 ::osl::MutexGuard aGuard(s_aMutex); \
40 //.........................................................................
43 //.........................................................................
45 //=========================================================================
47 //=========================================================================
48 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
52 ResMgr
* m_pRessources
;
59 /// get the manager for the ressources of the module
60 ResMgr
* getResManager();
64 //-------------------------------------------------------------------------
65 OModuleImpl::OModuleImpl()
68 DBG_CTOR(OModuleImpl
,NULL
);
72 //-------------------------------------------------------------------------
73 OModuleImpl::~OModuleImpl()
78 DBG_DTOR(OModuleImpl
,NULL
);
81 //-------------------------------------------------------------------------
82 ResMgr
* OModuleImpl::getResManager()
84 // note that this method is not threadsafe, which counts for the whole class !
88 // create a manager with a fixed prefix
89 m_pRessources
= ResMgr::CreateResMgr(rtl::OString("dbu").getStr());
94 //=========================================================================
96 //=========================================================================
97 ::osl::Mutex
OModule::s_aMutex
;
98 sal_Int32
OModule::s_nClients
= 0;
99 OModuleImpl
* OModule::s_pImpl
= NULL
;
100 //-------------------------------------------------------------------------
101 ResMgr
* OModule::getResManager()
104 return s_pImpl
->getResManager();
107 //-------------------------------------------------------------------------
108 void OModule::registerClient()
110 ::osl::MutexGuard
aGuard(s_aMutex
);
114 //-------------------------------------------------------------------------
115 void OModule::revokeClient()
117 ::osl::MutexGuard
aGuard(s_aMutex
);
118 if (!--s_nClients
&& s_pImpl
)
125 //-------------------------------------------------------------------------
126 void OModule::ensureImpl()
130 s_pImpl
= new OModuleImpl();
133 //.........................................................................
135 //.........................................................................
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */