xref: /trunk/main/connectivity/source/drivers/macab/MacabConnection.hxx (revision 9c15e1abd703a7953928d7a80655ae1a76a41f6d)
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 
23 
24 #ifndef _CONNECTIVITY_MACAB_CONNECTION_HXX_
25 #define _CONNECTIVITY_MACAB_CONNECTION_HXX_
26 
27 #include <map>
28 #include "OSubComponent.hxx"
29 #include "connectivity/CommonTools.hxx"
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/sdbc/SQLWarning.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
35 #include <comphelper/broadcasthelper.hxx>
36 #include <cppuhelper/compbase3.hxx>
37 #include "TConnection.hxx"
38 
39 namespace connectivity
40 {
41     namespace macab
42     {
43 
44         typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::sdbc::XConnection,
45                                                 ::com::sun::star::sdbc::XWarningsSupplier,
46                                                 ::com::sun::star::lang::XServiceInfo
47                                             > OMetaConnection_BASE;
48 
49         class MacabStatement_Base;
50         class MacabDriver;
51         class MacabDatabaseMetaData;
52         class MacabAddressBook;
53 
54         //typedef OMetaConnection_BASE              MacabConnection_BASE; // implements basics and text encoding
55         typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
56 
57         typedef connectivity::OMetaConnection MacabConnection_BASE;
58 
59         class MacabConnection : public MacabConnection_BASE,
60                             public OSubComponent<MacabConnection, MacabConnection_BASE>
61         {
62             friend class OSubComponent<MacabConnection, MacabConnection_BASE>;
63 
64         protected:
65             //====================================================================
66             // Data attributes
67             //====================================================================
68             MacabAddressBook*                   m_pAddressBook; // the address book
69             MacabDriver*                                m_pDriver;      // pointer to the owning driver object
70             ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>
71                                                     m_xCatalog;     // needed for the SQL interpreter
72 
73         public:
74             virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
75 
76             MacabConnection(MacabDriver* _pDriver);
77             virtual ~MacabConnection();
78 
79             void closeAllStatements ();
80 
81             // OComponentHelper
82             virtual void SAL_CALL disposing(void);
83 
84             // XInterface
85             virtual void SAL_CALL release() throw();
86 
87             // XServiceInfo
88             DECLARE_SERVICE_INFO();
89 
90             // XConnection
91             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  );
92             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql );
93             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql );
94             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql );
95             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit );
96             virtual sal_Bool SAL_CALL getAutoCommit(  );
97             virtual void SAL_CALL commit(  );
98             virtual void SAL_CALL rollback(  );
99             virtual sal_Bool SAL_CALL isClosed(  );
100             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  );
101             virtual void SAL_CALL setReadOnly( sal_Bool readOnly );
102             virtual sal_Bool SAL_CALL isReadOnly(  );
103             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog );
104             virtual ::rtl::OUString SAL_CALL getCatalog(  );
105             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level );
106             virtual sal_Int32 SAL_CALL getTransactionIsolation(  );
107             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  );
108             virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap );
109 
110             // XCloseable
111             virtual void SAL_CALL close(  );
112 
113             // XWarningsSupplier
114             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  );
115             virtual void SAL_CALL clearWarnings(  );
116 
117             // needed for the SQL interpreter
118             ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
119 
120             // accessors
121             inline MacabDriver*         getDriver()         const { return m_pDriver;}
122                    MacabAddressBook* getAddressBook()   const;
123         };
124     }
125 }
126 
127 #endif // _CONNECTIVITY_MACAB_CONNECTION_HXX_
128