xref: /aoo42x/main/mysqlc/source/mysqlc_driver.hxx (revision 079eb577)
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) throw(Exception);
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()					throw(RuntimeException);
72 			static Sequence< OUString > getSupportedServiceNames_Static()	throw(RuntimeException);
73 
74 			// XServiceInfo
75 			OUString SAL_CALL getImplementationName()						throw(RuntimeException);
76 			sal_Bool SAL_CALL supportsService(const OUString& ServiceName)	throw(RuntimeException);
77 			Sequence< OUString > SAL_CALL getSupportedServiceNames()		throw(RuntimeException);
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 																			throw(SQLException, RuntimeException);
82 
83 			sal_Bool SAL_CALL acceptsURL(const OUString& url) throw(SQLException, RuntimeException);
84 			Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info)
85 																			throw(SQLException, RuntimeException);
86 
87 			sal_Int32 SAL_CALL getMajorVersion()							throw(RuntimeException);
88 			sal_Int32 SAL_CALL getMinorVersion()							throw(RuntimeException);
89 
getFactory() const90             inline Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; }
91 
getDefaultEncoding()92 			rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; }
93 
94         private:
95             void    impl_initCppConn_lck_throw();
96 		};
97 	} /* mysqlc */
98 } /* connectivity */
99 
100 #endif // MYSQLC_SDRIVER_HXX
101 /*
102  * Local variables:
103  * tab-width: 4
104  * c-basic-offset: 4
105  * End:
106  * vim600: noet sw=4 ts=4 fdm=marker
107  * vim<600: noet sw=4 ts=4
108  */
109