fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / misc / moduledbu.cxx
blob63502fbf7bd29fe7e64cc6049dbf655e5273f69a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "moduledbu.hxx"
22 #include <tools/resmgr.hxx>
23 #include <svl/solar.hrc>
24 #include <tools/debug.hxx>
26 #define ENTER_MOD_METHOD() \
27 ::osl::MutexGuard aGuard(s_aMutex); \
28 ensureImpl()
30 namespace dbaui
33 // OModuleImpl
34 /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner
36 class OModuleImpl
38 ResMgr* m_pResources;
40 public:
41 /// ctor
42 OModuleImpl();
43 ~OModuleImpl();
45 /// get the manager for the resources of the module
46 ResMgr* getResManager();
49 OModuleImpl::OModuleImpl()
50 :m_pResources(NULL)
55 OModuleImpl::~OModuleImpl()
57 if (m_pResources)
58 delete m_pResources;
62 ResMgr* OModuleImpl::getResManager()
64 // note that this method is not threadsafe, which counts for the whole class !
66 if (!m_pResources)
68 // create a manager with a fixed prefix
69 m_pResources = ResMgr::CreateResMgr("dbu");
71 return m_pResources;
74 // OModule
75 ::osl::Mutex OModule::s_aMutex;
76 sal_Int32 OModule::s_nClients = 0;
77 OModuleImpl* OModule::s_pImpl = NULL;
78 ResMgr* OModule::getResManager()
80 ENTER_MOD_METHOD();
81 return s_pImpl->getResManager();
84 void OModule::registerClient()
86 ::osl::MutexGuard aGuard(s_aMutex);
87 ++s_nClients;
90 void OModule::revokeClient()
92 ::osl::MutexGuard aGuard(s_aMutex);
93 if (!--s_nClients && s_pImpl)
95 delete s_pImpl;
96 s_pImpl = NULL;
100 void OModule::ensureImpl()
102 if (s_pImpl)
103 return;
104 s_pImpl = new OModuleImpl();
107 } // namespace dbaui
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */