LCOV - code coverage report
Current view: top level - connectivity/source/drivers/firebird - SubComponent.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 19 0.0 %
Date: 2014-04-14 Functions: 0 4 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             : #ifndef CONNECTIVITY_FIREBIRD_SUBCOMPONENT_HXX
      21             : #define CONNECTIVITY_FIREBIRD_SUBCOMPONENT_HXX
      22             : 
      23             : #include <cppuhelper/interfacecontainer.h>
      24             : #include <cppuhelper/propshlp.hxx>
      25             : #include <cppuhelper/weak.hxx>
      26             : #include <osl/diagnose.h>
      27             : #include <osl/mutex.hxx>
      28             : 
      29             : #include <com/sun/star/lang/DisposedException.hpp>
      30             : 
      31             : namespace cppu {
      32             :     class IPropertyArrayHelper;
      33             : }
      34             : 
      35             : namespace com
      36             : {
      37             :     namespace sun
      38             :     {
      39             :         namespace star
      40             :         {
      41             :             namespace lang
      42             :             {
      43             :                 class XComponent;
      44             :             }
      45             :         }
      46             :     }
      47             : }
      48             : namespace connectivity
      49             : {
      50             : 
      51             :     namespace firebird
      52             :     {
      53             :         void release(oslInterlockedCount& _refCount,
      54             :                      ::cppu::OBroadcastHelper& rBHelper,
      55             :                      ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
      56             :                      ::com::sun::star::lang::XComponent* _pObject);
      57             : 
      58             :         void checkDisposed(sal_Bool _bThrow) throw ( ::com::sun::star::lang::DisposedException );
      59             : 
      60             : 
      61             :         template <class TYPE>
      62             :         class OPropertyArrayUsageHelper
      63             :         {
      64             :         protected:
      65             :             static sal_Int32                        s_nRefCount;
      66             :             static ::cppu::IPropertyArrayHelper*    s_pProps;
      67             :             static ::osl::Mutex                     s_aMutex;
      68             : 
      69             :         public:
      70             :             OPropertyArrayUsageHelper();
      71           0 :             virtual ~OPropertyArrayUsageHelper()
      72             :             {   // ARGHHHHHHH ..... would like to implement this in proparrhlp_impl.hxx (as we do with all other methods)
      73             :                 // but SUNPRO 5 compiler (linker) doesn't like this
      74           0 :                 ::osl::MutexGuard aGuard(s_aMutex);
      75             :                 OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
      76           0 :                 if (!--s_nRefCount)
      77             :                 {
      78           0 :                     delete s_pProps;
      79           0 :                     s_pProps = NULL;
      80           0 :                 }
      81           0 :             }
      82             : 
      83             :             /** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
      84             :                 class, which is created if necessary.
      85             :             */
      86             :             ::cppu::IPropertyArrayHelper*   getArrayHelper();
      87             : 
      88             :         protected:
      89             :             /** used to implement the creation of the array helper which is shared amongst all instances of the class.
      90             :                 This method needs to be implemented in derived classes.
      91             :                 <BR>
      92             :                 The method gets called with s_aMutex acquired.
      93             :                 <BR>
      94             :                 as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
      95             :                 assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
      96             :                 @return                         an pointer to the newly created array helper. Must not be NULL.
      97             :             */
      98             :             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const = 0;
      99             :         };
     100             : 
     101             :         template<class TYPE>
     102             :         sal_Int32                       OPropertyArrayUsageHelper< TYPE >::s_nRefCount  = 0;
     103             : 
     104             :         template<class TYPE>
     105             :         ::cppu::IPropertyArrayHelper*   OPropertyArrayUsageHelper< TYPE >::s_pProps = NULL;
     106             : 
     107             :         template<class TYPE>
     108           0 :         ::osl::Mutex                    OPropertyArrayUsageHelper< TYPE >::s_aMutex;
     109             : 
     110             : 
     111             :         template <class TYPE>
     112           0 :         OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
     113             :         {
     114           0 :             ::osl::MutexGuard aGuard(s_aMutex);
     115           0 :             ++s_nRefCount;
     116           0 :         }
     117             : 
     118             : 
     119             :         template <class TYPE>
     120           0 :         ::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
     121             :         {
     122             :             OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
     123           0 :             if (!s_pProps)
     124             :             {
     125           0 :                 ::osl::MutexGuard aGuard(s_aMutex);
     126           0 :                 if (!s_pProps)
     127             :                 {
     128           0 :                     s_pProps = createArrayHelper();
     129             :                     OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
     130           0 :                 }
     131             :             }
     132           0 :             return s_pProps;
     133             :         }
     134             : 
     135             :         class OBase_Mutex
     136             :         {
     137             :         public:
     138             :             ::osl::Mutex m_aMutex;
     139             :         };
     140             : 
     141             : 
     142             : 
     143             : 
     144             :     }
     145             : }
     146             : #endif // CONNECTIVITY_FIREBIRD_SUBCOMPONENT_HXX
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10