Update ooo320-m1
[ooovba.git] / connectivity / source / inc / TDatabaseMetaDataBase.hxx
blob3e6d151be54efa61d9aa3e9a99d364597b549547
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TDatabaseMetaDataBase.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
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.
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).
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.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_ODATABASEMETADATABASE_HXX_
32 #define _CONNECTIVITY_ODATABASEMETADATABASE_HXX_
34 #include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
35 #include <cppuhelper/implbase2.hxx>
36 #include <comphelper/broadcasthelper.hxx>
37 #include <com/sun/star/lang/XEventListener.hpp>
38 #include "FDatabaseMetaDataResultSet.hxx"
39 #include <functional>
40 #include "connectivity/dbtoolsdllapi.hxx"
42 namespace connectivity
44 typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > TConditions;
45 class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataBase :
46 public comphelper::OBaseMutex,
47 public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDatabaseMetaData2,
48 ::com::sun::star::lang::XEventListener>
50 private:
51 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aConnectionInfo;
52 ::connectivity::ODatabaseMetaDataResultSet::ORows m_aTypeInfoRows;
54 // cached database information
55 ::std::pair<bool,sal_Bool> m_isCatalogAtStart;
56 ::std::pair<bool,::rtl::OUString> m_sCatalogSeparator;
57 ::std::pair<bool,::rtl::OUString> m_sIdentifierQuoteString;
58 ::std::pair<bool,sal_Bool> m_supportsCatalogsInTableDefinitions;
59 ::std::pair<bool,sal_Bool> m_supportsSchemasInTableDefinitions;
60 ::std::pair<bool,sal_Bool> m_supportsCatalogsInDataManipulation;
61 ::std::pair<bool,sal_Bool> m_supportsSchemasInDataManipulation;
62 ::std::pair<bool,sal_Bool> m_supportsMixedCaseQuotedIdentifiers;
63 ::std::pair<bool,sal_Bool> m_supportsAlterTableWithAddColumn;
64 ::std::pair<bool,sal_Bool> m_supportsAlterTableWithDropColumn;
65 ::std::pair<bool,sal_Int32> m_MaxStatements;
66 ::std::pair<bool,sal_Int32> m_MaxTablesInSelect;
67 ::std::pair<bool,sal_Bool> m_storesMixedCaseQuotedIdentifiers;
69 template <typename T> T callImplMethod(::std::pair<bool,T>& _rCache,const ::std::mem_fun_t<T,ODatabaseMetaDataBase>& _pImplMethod)
71 ::osl::MutexGuard aGuard( m_aMutex );
72 if ( !_rCache.first )
74 _rCache.second = _pImplMethod(this);
75 _rCache.first = true;
77 return _rCache.second;
79 protected:
80 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
81 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xListenerHelper; // forward the calls from the connection to me
83 virtual ~ODatabaseMetaDataBase();
85 protected:
86 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw() = 0;
87 // cached database information
88 virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( ) = 0;
89 virtual sal_Bool impl_isCatalogAtStart_throw( ) = 0;
90 virtual ::rtl::OUString impl_getCatalogSeparator_throw( ) = 0;
91 virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( ) = 0;
92 virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) = 0;
93 virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( ) = 0;
94 virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) = 0;
95 virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) = 0;
96 virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( ) = 0;
97 virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( ) = 0;
98 virtual sal_Int32 impl_getMaxStatements_throw( ) = 0;
99 virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) = 0;
100 virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( ) = 0;
103 public:
105 ODatabaseMetaDataBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
107 // XDatabaseMetaData2
108 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getConnectionInfo( ) throw (::com::sun::star::uno::RuntimeException);
110 // XEventListener
111 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
126 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 // cached database information
130 virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
134 virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
135 virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
136 virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137 virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
138 virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
140 virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
141 virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
142 virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
145 #endif // _CONNECTIVITY_ODATABASEMETADATABASE_HXX_