LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_xcontainer.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 13 0.0 %
Date: 2014-04-11 Functions: 0 11 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             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #ifndef _PQ_CONTAINER_HXX_
      38             : #define _PQ_CONTAINER_HXX_
      39             : #include <boost/unordered_map.hpp>
      40             : #include <vector>
      41             : 
      42             : #include <com/sun/star/container/XNameAccess.hpp>
      43             : #include <com/sun/star/container/XIndexAccess.hpp>
      44             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      45             : #include <com/sun/star/container/XContainer.hpp>
      46             : 
      47             : #include <com/sun/star/sdbcx/XAppend.hpp>
      48             : #include <com/sun/star/sdbcx/XDrop.hpp>
      49             : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
      50             : 
      51             : #include <com/sun/star/util/XRefreshable.hpp>
      52             : 
      53             : #include <cppuhelper/compbase8.hxx>
      54             : 
      55             : #include "pq_connection.hxx"
      56             : #include "pq_statics.hxx"
      57             : 
      58             : namespace pq_sdbc_driver
      59             : {
      60             : 
      61           0 : class EventBroadcastHelper
      62             : {
      63             : public:
      64             :     virtual void fire(com::sun::star::lang::XEventListener * listener) const = 0;
      65             :     virtual com::sun::star::uno::Type getType() const = 0;
      66           0 :     virtual ~EventBroadcastHelper(){};
      67             : };
      68             : 
      69           0 : class RefreshedBroadcaster : public EventBroadcastHelper
      70             : {
      71             :     com::sun::star::lang::EventObject m_event;
      72             : public:
      73           0 :     RefreshedBroadcaster(const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & source ) :
      74           0 :         m_event( source )
      75           0 :     {}
      76             : 
      77           0 :     virtual void fire( com::sun::star::lang::XEventListener * listener ) const SAL_OVERRIDE
      78             :     {
      79           0 :         ((com::sun::star::util::XRefreshListener*)listener)->refreshed( m_event );
      80           0 :     }
      81             : 
      82           0 :     virtual com::sun::star::uno::Type getType() const SAL_OVERRIDE
      83             :     {
      84             :         return getCppuType(
      85           0 :             (com::sun::star::uno::Reference< com::sun::star::util::XRefreshListener > *)0 );
      86             :     }
      87             : };
      88             : 
      89             : typedef ::boost::unordered_map
      90             : <
      91             :    OUString,
      92             :    sal_Int32,
      93             :    OUStringHash,
      94             :    ::std::equal_to< OUString >,
      95             :    Allocator< ::std::pair< const OUString , sal_Int32 > >
      96             : > String2IntMap;
      97             : 
      98             : typedef ::cppu::WeakComponentImplHelper8
      99             : <
     100             :     com::sun::star::container::XNameAccess,
     101             :     com::sun::star::container::XIndexAccess,
     102             :     com::sun::star::container::XEnumerationAccess,
     103             :     com::sun::star::sdbcx::XAppend,
     104             :     com::sun::star::sdbcx::XDrop,
     105             :     com::sun::star::util::XRefreshable,
     106             :     com::sun::star::sdbcx::XDataDescriptorFactory,
     107             :     com::sun::star::container::XContainer
     108             : > ContainerBase;
     109             : 
     110           0 : class /* abstract */ Container : public ContainerBase
     111             : {
     112             : protected:
     113             :     ::rtl::Reference< RefCountedMutex > m_refMutex;
     114             :     ConnectionSettings *m_pSettings;
     115             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_origin;
     116             :     String2IntMap m_name2index;  // maps the element name to an index
     117             :     ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values; // contains the real values
     118             :     OUString m_type;
     119             : 
     120             : public:
     121             :     Container(
     122             :         const ::rtl::Reference< RefCountedMutex > & refMutex,
     123             :         const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection >  & origin,
     124             :         ConnectionSettings *pSettings,
     125             :         const OUString & type  // for exception messages
     126             :         );
     127             : 
     128             : public: // XIndexAccess
     129             :     virtual sal_Int32 SAL_CALL getCount(  )
     130             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
     132             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     133             :                ::com::sun::star::lang::WrappedTargetException,
     134             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     135             : 
     136             : public: // XEnumerationAccess
     137             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
     138             :     SAL_CALL createEnumeration(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             : 
     140             : public: // XNameAccess
     141             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
     142             :         throw (::com::sun::star::container::NoSuchElementException,
     143             :                ::com::sun::star::lang::WrappedTargetException,
     144             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames(  )
     146             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
     148             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :     // Methods
     150             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  )
     151             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             :     virtual sal_Bool SAL_CALL hasElements(  )
     153             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             : 
     155             : 
     156             : public: // XAppend
     157             :     // Must be overridden in Non-Descriptors. May be overridden in descriptors, when
     158             :     // PropertySet.NAME != container name
     159             :     virtual void SAL_CALL appendByDescriptor(
     160             :         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
     161             :         throw (::com::sun::star::sdbc::SQLException,
     162             :                ::com::sun::star::container::ElementExistException,
     163             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     164             : 
     165             :     // helper method !
     166             :     void append(
     167             :         const OUString & str,
     168             :         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
     169             :         throw ( ::com::sun::star::container::ElementExistException );
     170             : 
     171             : 
     172             : public: // XDrop
     173             :     virtual void SAL_CALL dropByName( const OUString& elementName )
     174             :         throw (::com::sun::star::sdbc::SQLException,
     175             :                ::com::sun::star::container::NoSuchElementException,
     176             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             :     virtual void SAL_CALL dropByIndex( sal_Int32 index )
     178             :         throw (::com::sun::star::sdbc::SQLException,
     179             :                ::com::sun::star::lang::IndexOutOfBoundsException,
     180             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             : 
     182             : public: // XDataDescriptorFactory
     183             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor(  )
     184             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
     185             : 
     186             : public: // XRefreshable
     187           0 :     virtual void SAL_CALL refresh(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE {}
     188             :     virtual void SAL_CALL addRefreshListener(
     189             :         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
     190             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             :     virtual void SAL_CALL removeRefreshListener(
     192             :         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
     193             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     194             : 
     195             : public:
     196             :     // Methods
     197             :     virtual void SAL_CALL addContainerListener(
     198             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
     199             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             :     virtual void SAL_CALL removeContainerListener(
     201             :         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
     202             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : 
     204             : public:
     205             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     206             : 
     207             : public:
     208             :     void rename( const OUString & oldName, const OUString &newName );
     209             : 
     210             : protected:
     211             :     void fire( const EventBroadcastHelper & helper );
     212             : };
     213             : 
     214             : }
     215             : #endif
     216             : 
     217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10