LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/comphelper - proxyaggregation.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2 0.0 %
Date: 2012-12-27 Functions: 0 1 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 COMPHELPER_PROXY_AGGREGATION
      21             : #define COMPHELPER_PROXY_AGGREGATION
      22             : 
      23             : #include <com/sun/star/uno/XAggregation.hpp>
      24             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25             : #include <com/sun/star/lang/XComponent.hpp>
      26             : #include <cppuhelper/implbase1.hxx>
      27             : #include <cppuhelper/interfacecontainer.hxx>
      28             : #include <comphelper/uno3.hxx>
      29             : #include <comphelper/broadcasthelper.hxx>
      30             : #include <cppuhelper/compbase_ex.hxx>
      31             : #include "comphelper/comphelperdllapi.h"
      32             : 
      33             : /* class hierarchy herein:
      34             : 
      35             :          +-------------------+          helper class for aggregating the proxy to another object
      36             :          | OProxyAggregation |          - not ref counted
      37             :          +-------------------+          - no UNO implementation, i.e. not derived from XInterface
      38             :                    ^                      (neither direct nor indirect)
      39             :                    |
      40             :                    |
      41             :   +----------------------------------+  helper class for aggregating a proxy to an XComponent
      42             :   | OComponentProxyAggregationHelper |  - life time coupling: if the inner component (the "aggregate")
      43             :   +----------------------------------+    is disposed, the outer (the delegator) is disposed, too, and
      44             :                    ^                      vice versa
      45             :                    |                    - UNO based, implementing XEventListener
      46             :                    |
      47             :      +----------------------------+     component aggregating another XComponent
      48             :      | OComponentProxyAggregation |     - life time coupling as above
      49             :      +----------------------------+     - ref-counted
      50             :                                         - implements an XComponent itself
      51             : 
      52             :   If you need to
      53             : 
      54             :   - wrap a foreign object which is a XComponent
      55             :     => use OComponentProxyAggregation
      56             :        - call componentAggregateProxyFor in your ctor
      57             :        - call implEnsureDisposeInDtor in your dtor
      58             : 
      59             :   - wrap a foreign object which is a XComponent, but already have ref-counting mechanisms
      60             :     inherited from somewhere else
      61             :     => use OComponentProxyAggregationHelper
      62             :        - override dispose - don't forget to call the base class' dispose!
      63             :        - call componentAggregateProxyFor in your ctor
      64             : 
      65             :   - wrap a foreign object which is no XComponent
      66             :     => use OProxyAggregation
      67             :        - call baseAggregateProxyFor in your ctor
      68             : */
      69             : 
      70             : //.............................................................................
      71             : namespace comphelper
      72             : {
      73             : //.............................................................................
      74             : 
      75             :     //=========================================================================
      76             :     //= OProxyAggregation
      77             :     //=========================================================================
      78             :     /** helper class for aggregating a proxy for a foreign object
      79             :     */
      80             :     class OProxyAggregation
      81             :     {
      82             :     private:
      83             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >             m_xProxyAggregate;
      84             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider >           m_xProxyTypeAccess;
      85             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
      86             : 
      87             :     protected:
      88           0 :         inline const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& getComponentContext()
      89             :         {
      90           0 :             return m_xContext;
      91             :         }
      92             : 
      93             :     protected:
      94             :         OProxyAggregation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
      95             :         ~OProxyAggregation();
      96             : 
      97             :         /// to be called from within your ctor
      98             :         void baseAggregateProxyFor(
      99             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
     100             :             oslInterlockedCount& _rRefCount,
     101             :             ::cppu::OWeakObject& _rDelegator
     102             :         );
     103             : 
     104             :         // XInterface and XTypeProvider
     105             :         ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
     106             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
     107             : 
     108             :     private:
     109             :         OProxyAggregation( );                                       // never implemented
     110             :         OProxyAggregation( const OProxyAggregation& );              // never implemented
     111             :         OProxyAggregation& operator=( const OProxyAggregation& );   // never implemented
     112             :     };
     113             : 
     114             :     //=========================================================================
     115             :     //= OComponentProxyAggregationHelper
     116             :     //=========================================================================
     117             :     /** a helper class for aggregating a proxy to an XComponent
     118             : 
     119             :         <p>The object couples the life time of itself and the component: if one of the both
     120             :         dies (in a sense of being disposed), the other one dies, too.</p>
     121             : 
     122             :         <p>The class itself does not implement XComponent so you need to forward any XComponent::dispose
     123             :         calls which your derived class gets to the dispose method of this class.</p>
     124             :     */
     125             : 
     126             :     class COMPHELPER_DLLPUBLIC OComponentProxyAggregationHelper :public ::cppu::ImplHelper1 <   com::sun::star::lang::XEventListener
     127             :                                                                         >
     128             :                                             ,private OProxyAggregation
     129             :     {
     130             :     private:
     131             :         typedef ::cppu::ImplHelper1 <   ::com::sun::star::lang::XEventListener
     132             :                                     >   BASE;   // prevents some MSVC problems
     133             : 
     134             :     protected:
     135             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
     136             :                                             m_xInner;
     137             :         ::cppu::OBroadcastHelper&           m_rBHelper;
     138             : 
     139             :     protected:
     140             :         // OProxyAggregation
     141             :         using OProxyAggregation::getComponentContext;
     142             : 
     143             :         // XInterface
     144             :         ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
     145             : 
     146             :         // XTypeProvider
     147             :         DECLARE_XTYPEPROVIDER( )
     148             : 
     149             :     protected:
     150             :         OComponentProxyAggregationHelper(
     151             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
     152             :             ::cppu::OBroadcastHelper& _rBHelper
     153             :         );
     154             :         virtual ~OComponentProxyAggregationHelper( );
     155             : 
     156             :         /// to be called from within your ctor
     157             :         void componentAggregateProxyFor(
     158             :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComponent,
     159             :             oslInterlockedCount& _rRefCount,
     160             :             ::cppu::OWeakObject& _rDelegator
     161             :         );
     162             : 
     163             :         // XEventListener
     164             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     165             : 
     166             :         // XComponent
     167             :         virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
     168             : 
     169             :     private:
     170             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregationHelper( );                                                  // never implemented
     171             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregationHelper( const OComponentProxyAggregationHelper& );          // never implemented
     172             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregationHelper& operator=( const OComponentProxyAggregationHelper& );   // never implemented
     173             :     };
     174             : 
     175             :     //=========================================================================
     176             :     //= OComponentProxyAggregation
     177             :     //=========================================================================
     178             :     typedef ::cppu::WeakComponentImplHelperBase OComponentProxyAggregation_CBase;
     179             : 
     180             :     class COMPHELPER_DLLPUBLIC OComponentProxyAggregation   :public OBaseMutex
     181             :                                         ,public OComponentProxyAggregation_CBase
     182             :                                         ,public OComponentProxyAggregationHelper
     183             :     {
     184             :     protected:
     185             :         OComponentProxyAggregation(
     186             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
     187             :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComponent
     188             :         );
     189             : 
     190             :         virtual ~OComponentProxyAggregation();
     191             : 
     192             :         // XInterface
     193             :         DECLARE_XINTERFACE()
     194             :         // XTypeProvider
     195             :         DECLARE_XTYPEPROVIDER()
     196             : 
     197             :         // OComponentHelper
     198             :         virtual void SAL_CALL disposing()  throw (::com::sun::star::uno::RuntimeException);
     199             : 
     200             :         // XEventListener
     201             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
     202             : 
     203             :         // XComponent/OComponentProxyAggregationHelper
     204             :         virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
     205             : 
     206             :     protected:
     207             :         // be called from within the dtor of derived classes
     208             :         void implEnsureDisposeInDtor( );
     209             : 
     210             :     private:
     211             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregation( );                                                // never implemented
     212             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregation( const OComponentProxyAggregation& );          // never implemented
     213             :         COMPHELPER_DLLPRIVATE OComponentProxyAggregation& operator=( const OComponentProxyAggregation& );   // never implemented
     214             :     };
     215             : 
     216             : //.............................................................................
     217             : }   // namespace comphelper
     218             : //.............................................................................
     219             : 
     220             : 
     221             : #endif // COMPHELPER_PROXY_AGGREGATION
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10