Update ooo320-m1
[ooovba.git] / connectivity / source / inc / mysql / YDriver.hxx
blob45d2fb8ab824513d5d7997391428ecfe1ce899c5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: YDriver.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CONNECTIVITY_MYSQL_DRIVER_HXX
31 #define CONNECTIVITY_MYSQL_DRIVER_HXX
33 #include <com/sun/star/sdbc/XDriver.hpp>
34 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <cppuhelper/compbase3.hxx>
37 #include <comphelper/uno3.hxx>
38 #include <comphelper/stl_types.hxx>
39 #include <comphelper/broadcasthelper.hxx>
40 #include "connectivity/CommonTools.hxx"
42 //........................................................................
43 namespace connectivity
45 //........................................................................
47 class OMetaConnection;
49 namespace mysql
51 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
53 typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver
54 , ::com::sun::star::sdbcx::XDataDefinitionSupplier
55 , ::com::sun::star::lang::XServiceInfo
56 > ODriverDelegator_BASE;
58 typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,OMetaConnection*> TWeakConnectionPair;
59 typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
60 typedef ::std::vector< TWeakPair > TWeakPairVector;
61 DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >,TJDBCDrivers);
62 typedef enum
64 D_ODBC,
65 D_JDBC,
66 D_NATIVE
67 } T_DRIVERTYPE;
70 /** delegates all calls to the orignal driver and extend the existing one with the SDBCX layer.
73 class ODriverDelegator : public ::comphelper::OBaseMutex
74 ,public ODriverDelegator_BASE
76 TJDBCDrivers m_aJdbcDrivers; // all jdbc drivers
77 TWeakPairVector m_aConnections; // vector containing a list
78 // of all the Connection objects
79 // for this Driver
80 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xODBCDriver;
81 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xNativeDriver;
82 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
83 ::rtl::OUString m_sOldDriverClass;
84 T_DRIVERTYPE m_eDriverType;
86 /** load the driver we want to delegate.
87 The <member>m_xODBCDriver</member> or <member>m_xDBCDriver</member> may be <NULL/> if the driver could not be loaded.
88 @param url
89 The URL.
90 @param info
91 The property info contains which driver we have to delegate.
92 @return
93 The driver which was currently selected.
95 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > loadDriver( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info );
97 public:
98 /** creates a new delegator for a mysql driver
100 ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
102 // XServiceInfo
103 DECLARE_SERVICE_INFO();
104 static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
105 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
107 // XDriver
108 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109 virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111 virtual sal_Int32 SAL_CALL getMajorVersion( ) throw (::com::sun::star::uno::RuntimeException);
112 virtual sal_Int32 SAL_CALL getMinorVersion( ) throw (::com::sun::star::uno::RuntimeException);
114 // XDataDefinitionSupplier
115 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117 protected:
118 /// dtor
119 virtual ~ODriverDelegator();
120 // OComponentHelper
121 virtual void SAL_CALL disposing(void);
125 //........................................................................
126 } // namespace connectivity
127 //........................................................................
128 #endif // CONNECTIVITY_MYSQL_DRIVER_HXX