1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2008 by Sun Microsystems, Inc. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * $RCSfile: mysqlc_driver.hxx,v $ 9 * 10 * $Revision: 1.1.2.4 $ 11 * 12 * This file is part of OpenOffice.org. 13 * 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. 17 * 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). 23 * 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. 28 ************************************************************************/ 29 30 #ifndef MYSQLC_SDRIVER_HXX 31 #define MYSQLC_SDRIVER_HXX 32 33 #include "mysqlc_connection.hxx" 34 35 #include <com/sun/star/sdbc/XDriver.hpp> 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 38 #include <cppuhelper/compbase2.hxx> 39 #include <preextstl.h> 40 #include <cppconn/driver.h> 41 #include <postextstl.h> 42 #include <osl/module.h> 43 44 namespace connectivity 45 { 46 namespace mysqlc 47 { 48 using ::rtl::OUString; 49 using ::com::sun::star::sdbc::SQLException; 50 using ::com::sun::star::uno::RuntimeException; 51 using ::com::sun::star::uno::Exception; 52 using ::com::sun::star::uno::Reference; 53 using ::com::sun::star::uno::Sequence; 54 Reference< ::com::sun::star::uno::XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw(Exception); 55 56 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, 57 ::com::sun::star::lang::XServiceInfo > ODriver_BASE; 58 59 typedef void* (SAL_CALL * OMysqlCConnection_CreateInstanceFunction)(void* _pDriver); 60 61 class MysqlCDriver : public ODriver_BASE 62 { 63 protected: 64 Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 65 ::osl::Mutex m_aMutex; // mutex is need to control member access 66 OWeakRefArray m_xConnections; // vector containing a list 67 // of all the Connection objects 68 // for this Driver 69 70 sql::Driver * cppDriver; 71 72 public: 73 74 MysqlCDriver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); 75 76 // OComponentHelper 77 void SAL_CALL disposing(void); 78 // XInterface 79 static OUString getImplementationName_Static() throw(RuntimeException); 80 static Sequence< OUString > getSupportedServiceNames_Static() throw(RuntimeException); 81 82 // XServiceInfo 83 OUString SAL_CALL getImplementationName() throw(RuntimeException); 84 sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); 85 Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 86 87 // XDriver 88 Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 89 throw(SQLException, RuntimeException); 90 91 sal_Bool SAL_CALL acceptsURL(const OUString& url) throw(SQLException, RuntimeException); 92 Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 93 throw(SQLException, RuntimeException); 94 95 sal_Int32 SAL_CALL getMajorVersion() throw(RuntimeException); 96 sal_Int32 SAL_CALL getMinorVersion() throw(RuntimeException); 97 98 inline Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; } 99 100 rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; } 101 102 private: 103 void impl_initCppConn_lck_throw(); 104 }; 105 } /* mysqlc */ 106 } /* connectivity */ 107 108 #endif // MYSQLC_SDRIVER_HXX 109 /* 110 * Local variables: 111 * tab-width: 4 112 * c-basic-offset: 4 113 * End: 114 * vim600: noet sw=4 ts=4 fdm=marker 115 * vim<600: noet sw=4 ts=4 116 */ 117