LCOV - code coverage report
Current view: top level - dbaccess/source/core/inc - FilteredContainer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 12 25.0 %
Date: 2012-08-25 Functions: 3 8 37.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.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                 :            : #ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX
      20                 :            : #define DBACCESS_CORE_FILTERED_CONTAINER_HXX
      21                 :            : 
      22                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      23                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      24                 :            : 
      25                 :            : #include <connectivity/sdbcx/VCollection.hxx>
      26                 :            : 
      27                 :            : namespace dbtools
      28                 :            : {
      29                 :            :     class IWarningsContainer;
      30                 :            : }
      31                 :            : 
      32                 :            : namespace dbaccess
      33                 :            : {
      34                 :            :     class IRefreshListener;
      35                 :            : 
      36 [ +  - ][ -  + ]:         56 :     class OFilteredContainer : public ::connectivity::sdbcx::OCollection
      37                 :            :     {
      38                 :            :     private:
      39                 :            :         mutable sal_Bool m_bConstructed;        // late ctor called
      40                 :            : 
      41                 :            :     protected:
      42                 :            :         ::dbtools::IWarningsContainer*  m_pWarningsContainer;
      43                 :            :         IRefreshListener*               m_pRefreshListener;
      44                 :            :         oslInterlockedCount&            m_nInAppend;
      45                 :            : 
      46                 :            :         // holds the original container which where set in construct but they can be null
      47                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xMasterContainer;
      48                 :            :         ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection >     m_xConnection;
      49                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >   m_xMetaData;
      50                 :            : 
      51                 :            :         /** returns a string denoting the only type of tables allowed in this container, or an empty string
      52                 :            :             if there is no such restriction
      53                 :            :         */
      54                 :            :         virtual ::rtl::OUString getTableTypeRestriction() const = 0;
      55                 :            : 
      56                 :          0 :         inline virtual void addMasterContainerListener(){}
      57                 :          0 :         inline virtual void removeMasterContainerListener(){}
      58                 :            : 
      59                 :            :         // ::connectivity::sdbcx::OCollection
      60                 :            :         virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
      61                 :            : 
      62                 :            :         virtual ::rtl::OUString getNameForObject(const ::connectivity::sdbcx::ObjectType& _xObject);
      63                 :            : 
      64                 :            :         /** tell the container to free all elements and all additional resources.<BR>
      65                 :            :             After using this method the object may be reconstructed by calling one of the <code>constrcuct</code> methods.
      66                 :            :         */
      67                 :            :         virtual void SAL_CALL disposing();
      68                 :            : 
      69                 :            :         class EnsureReset
      70                 :            :         {
      71                 :            :         public:
      72                 :          0 :             EnsureReset( oslInterlockedCount& _rValueLocation)
      73                 :          0 :                 :m_rValue( _rValueLocation )
      74                 :            :             {
      75                 :          0 :                 osl_incrementInterlockedCount(&m_rValue);
      76                 :          0 :             }
      77                 :            : 
      78                 :          0 :             ~EnsureReset()
      79                 :            :             {
      80                 :          0 :                 osl_decrementInterlockedCount(&m_rValue);
      81                 :          0 :             }
      82                 :            : 
      83                 :            :         private:
      84                 :            :             oslInterlockedCount&   m_rValue;
      85                 :            :         };
      86                 :            : 
      87                 :            :         /** retrieve a table type filter to pass to <member scope="com::sun::star::sdbc">XDatabaseMetaData::getTables</member>,
      88                 :            :             according to the current data source settings
      89                 :            :         */
      90                 :            :         void    getAllTableTypeFilter( ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rFilter ) const;
      91                 :            : 
      92                 :            :     public:
      93                 :            :         /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
      94                 :            :             interface.<BR>
      95                 :            :             @param          _rParent            the object which acts as parent for the container.
      96                 :            :                                                 all refcounting is rerouted to this object
      97                 :            :             @param          _rMutex             the access safety object of the parent
      98                 :            :             @param          _rTableFilter       restricts the visible tables by name
      99                 :            :             @param          _rTableTypeFilter   restricts the visible tables by type
     100                 :            :             @see            construct
     101                 :            :         */
     102                 :            :         OFilteredContainer( ::cppu::OWeakObject& _rParent,
     103                 :            :                             ::osl::Mutex& _rMutex,
     104                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon,
     105                 :            :                             sal_Bool _bCase,
     106                 :            :                             IRefreshListener*   _pRefreshListener,
     107                 :            :                             ::dbtools::IWarningsContainer* _pWarningsContainer,
     108                 :            :                             oslInterlockedCount& _nInAppend
     109                 :            :                         );
     110                 :            : 
     111                 :         56 :         inline void dispose() { disposing(); }
     112                 :            : 
     113                 :            :         /** late ctor. The container will fill itself with the data got by the connection meta data, considering the
     114                 :            :             filters given (the connection is the parent object you passed in the ctor).
     115                 :            :         */
     116                 :            :         void construct(
     117                 :            :             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter,
     118                 :            :             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter
     119                 :            :             );
     120                 :            : 
     121                 :            :         /** late ctor. The container will fill itself with wrapper objects for the tables returned by the given
     122                 :            :             name container.
     123                 :            :         */
     124                 :            :         void construct(
     125                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxMasterContainer,
     126                 :            :             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter,
     127                 :            :             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter
     128                 :            :             );
     129                 :            : 
     130                 :        564 :         inline sal_Bool isInitialized() const { return m_bConstructed; }
     131                 :            :     };
     132                 :            : // ..............................................................................
     133                 :            : } // namespace
     134                 :            : // ..............................................................................
     135                 :            : 
     136                 :            : #endif // DBACCESS_CORE_FILTERED_CONTAINER_HXX
     137                 :            : 
     138                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10