xref: /trunk/main/mysqlc/source/mysqlc_driver.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef MYSQLC_SDRIVER_HXX
23 #define MYSQLC_SDRIVER_HXX
24 
25 #include "mysqlc_connection.hxx"
26 
27 #include <com/sun/star/sdbc/XDriver.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 
30 #include <cppuhelper/compbase2.hxx>
31 #include <preextstl.h>
32 #include <cppconn/driver.h>
33 #include <postextstl.h>
34 #include <osl/module.h>
35 
36 namespace connectivity
37 {
38     namespace mysqlc
39     {
40         using ::rtl::OUString;
41         using ::com::sun::star::sdbc::SQLException;
42         using ::com::sun::star::uno::RuntimeException;
43         using ::com::sun::star::uno::Exception;
44         using ::com::sun::star::uno::Reference;
45         using ::com::sun::star::uno::Sequence;
46         Reference< ::com::sun::star::uno::XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
47 
48         typedef ::cppu::WeakComponentImplHelper2<   ::com::sun::star::sdbc::XDriver,
49                                                     ::com::sun::star::lang::XServiceInfo > ODriver_BASE;
50 
51         typedef void* (SAL_CALL * OMysqlCConnection_CreateInstanceFunction)(void* _pDriver);
52 
53         class MysqlCDriver : public ODriver_BASE
54         {
55         protected:
56             Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
57             ::osl::Mutex    m_aMutex;       // mutex is need to control member access
58             OWeakRefArray   m_xConnections; // vector containing a list
59                                             // of all the Connection objects
60                                             // for this Driver
61 
62             sql::Driver * cppDriver;
63 
64         public:
65 
66             MysqlCDriver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
67 
68             // OComponentHelper
69             void SAL_CALL disposing(void);
70             // XInterface
71             static OUString getImplementationName_Static();
72             static Sequence< OUString > getSupportedServiceNames_Static();
73 
74             // XServiceInfo
75             OUString SAL_CALL getImplementationName();
76             sal_Bool SAL_CALL supportsService(const OUString& ServiceName);
77             Sequence< OUString > SAL_CALL getSupportedServiceNames();
78 
79             // XDriver
80             Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info);
81 
82             sal_Bool SAL_CALL acceptsURL(const OUString& url);
83             Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info);
84 
85             sal_Int32 SAL_CALL getMajorVersion();
86             sal_Int32 SAL_CALL getMinorVersion();
87 
getFactory() const88             inline Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; }
89 
getDefaultEncoding()90             rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; }
91 
92         private:
93             void    impl_initCppConn_lck_throw();
94         };
95     } /* mysqlc */
96 } /* connectivity */
97 
98 #endif // MYSQLC_SDRIVER_HXX
99 /*
100  * Local variables:
101  * tab-width: 4
102  * c-basic-offset: 4
103  * End:
104  * vim600: noet sw=4 ts=4 fdm=marker
105  * vim<600: noet sw=4 ts=4
106  */
107