xref: /trunk/main/connectivity/source/inc/mysql/YDriver.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5caf5cd79SAndrew Rist  * distributed with this work for additional information
6caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18caf5cd79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20caf5cd79SAndrew Rist  *************************************************************/
21caf5cd79SAndrew Rist 
22caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef CONNECTIVITY_MYSQL_DRIVER_HXX
24cdf0e10cSrcweir #define CONNECTIVITY_MYSQL_DRIVER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriver.hpp>
27cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
29cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx>
30cdf0e10cSrcweir #include <comphelper/uno3.hxx>
31cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
32cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
33cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //........................................................................
36cdf0e10cSrcweir namespace connectivity
37cdf0e10cSrcweir {
38cdf0e10cSrcweir //........................................................................
39cdf0e10cSrcweir 
40cdf0e10cSrcweir     class OMetaConnection;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     namespace mysql
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         ::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 );
45cdf0e10cSrcweir 
46cdf0e10cSrcweir         typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::sdbc::XDriver
47cdf0e10cSrcweir                                                 ,   ::com::sun::star::sdbcx::XDataDefinitionSupplier
48cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XServiceInfo
49cdf0e10cSrcweir                                                 >   ODriverDelegator_BASE;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir         typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,OMetaConnection*> TWeakConnectionPair;
52cdf0e10cSrcweir         typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
53cdf0e10cSrcweir         typedef ::std::vector< TWeakPair > TWeakPairVector;
54cdf0e10cSrcweir         DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >,TJDBCDrivers);
55cdf0e10cSrcweir         typedef enum
56cdf0e10cSrcweir         {
57cdf0e10cSrcweir             D_ODBC,
58cdf0e10cSrcweir             D_JDBC,
59cdf0e10cSrcweir             D_NATIVE
60cdf0e10cSrcweir         } T_DRIVERTYPE;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63*0cb2ec91SJohn Bampton         /** delegates all calls to the original driver and extend the existing one with the SDBCX layer.
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         */
66cdf0e10cSrcweir         class ODriverDelegator : public ::comphelper::OBaseMutex
67cdf0e10cSrcweir                                 ,public ODriverDelegator_BASE
68cdf0e10cSrcweir         {
69cdf0e10cSrcweir             TJDBCDrivers                                                        m_aJdbcDrivers; // all jdbc drivers
70cdf0e10cSrcweir             TWeakPairVector                                                     m_aConnections; //  vector containing a list
71cdf0e10cSrcweir                                                                                                 //  of all the Connection objects
72cdf0e10cSrcweir                                                                                                 //  for this Driver
73cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >                 m_xODBCDriver;
74cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >                 m_xNativeDriver;
75cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xFactory;
76cdf0e10cSrcweir             ::rtl::OUString     m_sOldDriverClass;
77cdf0e10cSrcweir             T_DRIVERTYPE        m_eDriverType;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir             /** load the driver we want to delegate.
80cdf0e10cSrcweir                 The <member>m_xODBCDriver</member> or <member>m_xDBCDriver</member> may be <NULL/> if the driver could not be loaded.
81cdf0e10cSrcweir                 @param  url
82cdf0e10cSrcweir                     The URL.
83cdf0e10cSrcweir                 @param  info
84cdf0e10cSrcweir                     The property info contains which driver we have to delegate.
85cdf0e10cSrcweir                 @return
86cdf0e10cSrcweir                     The driver which was currently selected.
87cdf0e10cSrcweir             */
88cdf0e10cSrcweir             ::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 );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         public:
91cdf0e10cSrcweir             /** creates a new delegator for a mysql driver
92cdf0e10cSrcweir             */
93cdf0e10cSrcweir             ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir             // XServiceInfo
96cdf0e10cSrcweir             DECLARE_SERVICE_INFO();
97cdf0e10cSrcweir             static ::rtl::OUString getImplementationName_Static(  ) throw(::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(  ) throw (::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             // XDriver
101cdf0e10cSrcweir             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);
102cdf0e10cSrcweir             virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir             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);
104cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getMajorVersion(  ) throw (::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getMinorVersion(  ) throw (::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir             // XDataDefinitionSupplier
108cdf0e10cSrcweir             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);
109cdf0e10cSrcweir             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);
110cdf0e10cSrcweir         protected:
111cdf0e10cSrcweir             /// dtor
112cdf0e10cSrcweir             virtual ~ODriverDelegator();
113cdf0e10cSrcweir             // OComponentHelper
114cdf0e10cSrcweir             virtual void SAL_CALL disposing(void);
115cdf0e10cSrcweir         };
116cdf0e10cSrcweir     }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //........................................................................
119cdf0e10cSrcweir }   // namespace connectivity
120cdf0e10cSrcweir //........................................................................
121cdf0e10cSrcweir #endif // CONNECTIVITY_MYSQL_DRIVER_HXX
122