LCOV - code coverage report
Current view: top level - libreoffice/stoc/source/registry_tdprovider - tdsingleton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 34 0.0 %
Date: 2012-12-27 Functions: 0 8 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 <osl/diagnose.h>
      21             : #include "base.hxx"
      22             : 
      23             : #include "com/sun/star/uno/RuntimeException.hpp"
      24             : 
      25             : using namespace com::sun::star;
      26             : 
      27             : namespace stoc_rdbtdp
      28             : {
      29             : 
      30           0 : void SingletonTypeDescriptionImpl::init() {
      31             :     {
      32           0 :         MutexGuard guard(getMutex());
      33           0 :         if (_xInterfaceTD.is() || _xServiceTD.is()) {
      34           0 :             return;
      35           0 :         }
      36             :     }
      37           0 :     Reference< XTypeDescription > base;
      38             :     try {
      39             :         base = Reference< XTypeDescription >(
      40           0 :             _xTDMgr->getByHierarchicalName(_aBaseName), UNO_QUERY_THROW);
      41           0 :     } catch (NoSuchElementException const & e) {
      42             :         throw RuntimeException(
      43             :             (OUString(
      44             :                 RTL_CONSTASCII_USTRINGPARAM(
      45             :                     "com.sun.star.container.NoSuchElementException: "))
      46           0 :              + e.Message),
      47           0 :             static_cast< OWeakObject * >(this));
      48             :     }
      49           0 :     MutexGuard guard(getMutex());
      50           0 :     if (!_xInterfaceTD.is() && !_xServiceTD.is()) {
      51           0 :         if (resolveTypedefs(base)->getTypeClass() == TypeClass_INTERFACE) {
      52           0 :             _xInterfaceTD = base;
      53           0 :         } else if (base->getTypeClass() == TypeClass_SERVICE) {
      54             :             _xServiceTD = Reference< XServiceTypeDescription >(
      55           0 :                 base, UNO_QUERY_THROW);
      56             :         } else {
      57             :             throw RuntimeException(
      58             :                 OUString(
      59             :                     RTL_CONSTASCII_USTRINGPARAM(
      60             :                         "Singleton is based on neither interface nor service")),
      61           0 :                 static_cast< OWeakObject * >(this));
      62             :         }
      63             :     }
      64           0 :     OSL_ASSERT(_xInterfaceTD.is() ^ _xServiceTD.is());
      65             : }
      66             : 
      67             : //__________________________________________________________________________________________________
      68             : // virtual
      69           0 : SingletonTypeDescriptionImpl::~SingletonTypeDescriptionImpl()
      70             : {
      71           0 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
      72           0 : }
      73             : 
      74             : // XTypeDescription
      75             : //__________________________________________________________________________________________________
      76             : // virtual
      77           0 : TypeClass SingletonTypeDescriptionImpl::getTypeClass()
      78             :     throw(::com::sun::star::uno::RuntimeException)
      79             : {
      80           0 :     return TypeClass_SINGLETON;
      81             : }
      82             : //__________________________________________________________________________________________________
      83             : // virtual
      84           0 : OUString SingletonTypeDescriptionImpl::getName()
      85             :     throw(::com::sun::star::uno::RuntimeException)
      86             : {
      87           0 :     return _aName;
      88             : }
      89             : 
      90             : // XSingletonTypeDescription
      91             : //__________________________________________________________________________________________________
      92             : // virtual
      93             : Reference< XServiceTypeDescription > SAL_CALL
      94           0 : SingletonTypeDescriptionImpl::getService()
      95             :     throw(::com::sun::star::uno::RuntimeException)
      96             : {
      97           0 :     init();
      98           0 :     return _xServiceTD;
      99             : }
     100             : 
     101             : // XSingletonTypeDescription2
     102             : //______________________________________________________________________________
     103             : // virtual
     104             : sal_Bool SAL_CALL
     105           0 : SingletonTypeDescriptionImpl::isInterfaceBased()
     106             :     throw(::com::sun::star::uno::RuntimeException)
     107             : {
     108           0 :     init();
     109           0 :     return _xInterfaceTD.is();
     110             : }
     111             : 
     112             : //______________________________________________________________________________
     113             : // virtual
     114             : Reference< XTypeDescription > SAL_CALL
     115           0 : SingletonTypeDescriptionImpl::getInterface()
     116             :     throw(::com::sun::star::uno::RuntimeException)
     117             : {
     118           0 :     init();
     119           0 :     return _xInterfaceTD;
     120             : }
     121             : 
     122             : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10