LCOV - code coverage report
Current view: top level - dbaccess/source/ui/inc - moduledbu.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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                 :            : #ifndef _DBAUI_MODULE_DBU_HXX_
      21                 :            : #define _DBAUI_MODULE_DBU_HXX_
      22                 :            : 
      23                 :            : #include <osl/mutex.hxx>
      24                 :            : #include <tools/resid.hxx>
      25                 :            : 
      26                 :            : class ResMgr;
      27                 :            : 
      28                 :            : //.........................................................................
      29                 :            : namespace dbaui
      30                 :            : {
      31                 :            : //.........................................................................
      32                 :            : 
      33                 :            : //=========================================================================
      34                 :            : //= OModule
      35                 :            : //=========================================================================
      36                 :            : class OModuleImpl;
      37                 :            : class OModule
      38                 :            : {
      39                 :            :     friend class OModuleClient;
      40                 :            : 
      41                 :            : private:
      42                 :            :     OModule();
      43                 :            :         // not implemented. OModule is a static class
      44                 :            : 
      45                 :            : protected:
      46                 :            :     static ::osl::Mutex s_aMutex;       /// access safety
      47                 :            :     static sal_Int32    s_nClients;     /// number of registered clients
      48                 :            :     static OModuleImpl* s_pImpl;        /// impl class. lives as long as at least one client for the module is registered
      49                 :            : 
      50                 :            : public:
      51                 :            :     /// get the vcl res manager of the module
      52                 :            :     static ResMgr*  getResManager();
      53                 :            : 
      54                 :            : protected:
      55                 :            :     /// register a client for the module
      56                 :            :     static void registerClient();
      57                 :            :     /// revoke a client for the module
      58                 :            :     static void revokeClient();
      59                 :            : 
      60                 :            : private:
      61                 :            :     /** ensure that the impl class exists
      62                 :            :         @precond m_aMutex is guarded when this method gets called
      63                 :            :     */
      64                 :            :     static void ensureImpl();
      65                 :            : };
      66                 :            : 
      67                 :            : //=========================================================================
      68                 :            : //= OModuleClient
      69                 :            : //=========================================================================
      70                 :            : /** base class for objects which uses any global module-specific resources
      71                 :            : */
      72                 :            : class OModuleClient
      73                 :            : {
      74                 :            : public:
      75                 :         16 :     OModuleClient()     { OModule::registerClient(); }
      76                 :         16 :     ~OModuleClient()    { OModule::revokeClient(); }
      77                 :            : };
      78                 :            : 
      79                 :            : //=========================================================================
      80                 :            : //= ModuleRes
      81                 :            : //=========================================================================
      82                 :            : /** specialized ResId, using the resource manager provided by the global module
      83                 :            : */
      84                 :            : class ModuleRes : public ::ResId
      85                 :            : {
      86                 :            : public:
      87                 :         30 :     ModuleRes(sal_uInt16 _nId) : ResId(_nId, *OModule::getResManager()) { }
      88                 :            : };
      89                 :            : 
      90                 :            : //.........................................................................
      91                 :            : }   // namespace dbaui
      92                 :            : //.........................................................................
      93                 :            : 
      94                 :            : #endif // _DBAUI_MODULE_DBU_HXX_
      95                 :            : 
      96                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10