LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - ModuleHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 29 0.0 %
Date: 2014-04-14 Functions: 0 7 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             : #include "ModuleHelper.hxx"
      20             : #include <comphelper/processfactory.hxx>
      21             : #include <osl/thread.h>
      22             : #include <com/sun/star/util/XMacroExpander.hpp>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/uno/XComponentContext.hpp>
      25             : #include <rtl/instance.hxx>
      26             : #include <rtl/uri.hxx>
      27             : #include <tools/debug.hxx>
      28             : #include <svl/solar.hrc>
      29             : 
      30             : #define ENTER_MOD_METHOD()  \
      31             :     ::osl::MutexGuard aGuard(theOModuleMutex::get()); \
      32             :     ensureImpl()
      33             : 
      34             : 
      35             : namespace rptui
      36             : {
      37             : 
      38             :     using namespace ::com::sun::star;
      39             : 
      40             : //= OModuleImpl
      41             : 
      42             : /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner
      43             : */
      44             : class OModuleImpl
      45             : {
      46             :     ResMgr* m_pResources;
      47             : 
      48             : public:
      49             :     /// ctor
      50             :     OModuleImpl();
      51             :     ~OModuleImpl();
      52             : 
      53             :     /// get the manager for the resources of the module
      54             :     ResMgr* getResManager();
      55             : };
      56             : 
      57             : 
      58           0 : OModuleImpl::OModuleImpl()
      59           0 :     :m_pResources(NULL)
      60             : {
      61           0 : }
      62             : 
      63             : 
      64           0 : OModuleImpl::~OModuleImpl()
      65             : {
      66           0 :     if (m_pResources)
      67           0 :         delete m_pResources;
      68           0 : }
      69             : 
      70             : 
      71           0 : ResMgr* OModuleImpl::getResManager()
      72             : {
      73             :     // note that this method is not threadsafe, which counts for the whole class !
      74             : 
      75           0 :     if (!m_pResources)
      76             :     {
      77             :         // create a manager with a fixed prefix
      78           0 :         m_pResources = ResMgr::CreateResMgr("rptui");
      79             :     }
      80           0 :     return m_pResources;
      81             : }
      82             : 
      83             : 
      84             : //= OModule
      85             : 
      86             : 
      87             : namespace
      88             : {
      89             :     // access safety
      90             :     struct theOModuleMutex : public rtl::Static< osl::Mutex, theOModuleMutex > {};
      91             : }
      92             : 
      93             : sal_Int32       OModule::s_nClients = 0;
      94             : OModuleImpl*    OModule::s_pImpl = NULL;
      95             : 
      96           0 : ResMgr* OModule::getResManager()
      97             : {
      98           0 :     ENTER_MOD_METHOD();
      99           0 :     return s_pImpl->getResManager();
     100             : }
     101             : 
     102             : 
     103           0 : void OModule::registerClient()
     104             : {
     105           0 :     ::osl::MutexGuard aGuard(theOModuleMutex::get());
     106           0 :     ++s_nClients;
     107           0 : }
     108             : 
     109             : 
     110           0 : void OModule::revokeClient()
     111             : {
     112           0 :     ::osl::MutexGuard aGuard(theOModuleMutex::get());
     113           0 :     if (!--s_nClients && s_pImpl)
     114             :     {
     115           0 :         delete s_pImpl;
     116           0 :         s_pImpl = NULL;
     117           0 :     }
     118           0 : }
     119             : 
     120             : 
     121           0 : void OModule::ensureImpl()
     122             : {
     123           0 :     if (s_pImpl)
     124           0 :         return;
     125           0 :     s_pImpl = new OModuleImpl();
     126             : }
     127             : 
     128             : 
     129             : }   // namespace dbaui
     130             : 
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10