LCOV - code coverage report
Current view: top level - dbaccess/source/ui/misc - moduledbu.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 31 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "moduledbu.hxx"
      21             : 
      22             : #include <tools/resmgr.hxx>
      23             : #include <svl/solar.hrc>
      24             : #include <tools/debug.hxx>
      25             : 
      26             : #define ENTER_MOD_METHOD()  \
      27             :     ::osl::MutexGuard aGuard(s_aMutex); \
      28             :     ensureImpl()
      29             : 
      30             : namespace dbaui
      31             : {
      32             : 
      33             : // OModuleImpl
      34             : /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner
      35             : */
      36             : class OModuleImpl
      37             : {
      38             :     ResMgr* m_pResources;
      39             : 
      40             : public:
      41             :     /// ctor
      42             :     OModuleImpl();
      43             :     ~OModuleImpl();
      44             : 
      45             :     /// get the manager for the resources of the module
      46             :     ResMgr* getResManager();
      47             : };
      48             : 
      49           0 : OModuleImpl::OModuleImpl()
      50           0 :     :m_pResources(NULL)
      51             : {
      52             : 
      53           0 : }
      54             : 
      55           0 : OModuleImpl::~OModuleImpl()
      56             : {
      57           0 :     if (m_pResources)
      58           0 :         delete m_pResources;
      59             : 
      60           0 : }
      61             : 
      62           0 : ResMgr* OModuleImpl::getResManager()
      63             : {
      64             :     // note that this method is not threadsafe, which counts for the whole class !
      65             : 
      66           0 :     if (!m_pResources)
      67             :     {
      68             :         // create a manager with a fixed prefix
      69           0 :         m_pResources = ResMgr::CreateResMgr("dbu");
      70             :     }
      71           0 :     return m_pResources;
      72             : }
      73             : 
      74             : // OModule
      75           0 : ::osl::Mutex    OModule::s_aMutex;
      76             : sal_Int32       OModule::s_nClients = 0;
      77             : OModuleImpl*    OModule::s_pImpl = NULL;
      78           0 : ResMgr* OModule::getResManager()
      79             : {
      80           0 :     ENTER_MOD_METHOD();
      81           0 :     return s_pImpl->getResManager();
      82             : }
      83             : 
      84           0 : void OModule::registerClient()
      85             : {
      86           0 :     ::osl::MutexGuard aGuard(s_aMutex);
      87           0 :     ++s_nClients;
      88           0 : }
      89             : 
      90           0 : void OModule::revokeClient()
      91             : {
      92           0 :     ::osl::MutexGuard aGuard(s_aMutex);
      93           0 :     if (!--s_nClients && s_pImpl)
      94             :     {
      95           0 :         delete s_pImpl;
      96           0 :         s_pImpl = NULL;
      97           0 :     }
      98           0 : }
      99             : 
     100           0 : void OModule::ensureImpl()
     101             : {
     102           0 :     if (s_pImpl)
     103           0 :         return;
     104           0 :     s_pImpl = new OModuleImpl();
     105             : }
     106             : 
     107           0 : }   // namespace dbaui
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10