1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SDBCX_VCATALOG_HXX
21 #define INCLUDED_CONNECTIVITY_SDBCX_VCATALOG_HXX
23 #include <osl/diagnose.h>
24 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
25 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
26 #include <com/sun/star/sdbcx/XUsersSupplier.hpp>
27 #include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
28 #include <com/sun/star/sdbc/XConnection.hpp>
29 #include <com/sun/star/sdbc/XRow.hpp>
30 #include <cppuhelper/compbase5.hxx>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <connectivity/CommonTools.hxx>
33 #include <connectivity/OSubComponent.hxx>
34 #include <connectivity/sdbcx/IRefreshable.hxx>
35 #include <connectivity/StdTypeDefs.hxx>
36 #include <connectivity/dbtoolsdllapi.hxx>
38 namespace connectivity
44 // OCatalog is a general catalog class
45 // other drivers can be derived their catalog from this class when they want to support sdbcx
46 // it holds already tables, views, groups and users
48 typedef ::cppu::WeakComponentImplHelper5
< ::com::sun::star::sdbcx::XTablesSupplier
,
49 ::com::sun::star::sdbcx::XViewsSupplier
,
50 ::com::sun::star::sdbcx::XUsersSupplier
,
51 ::com::sun::star::sdbcx::XGroupsSupplier
,
52 ::com::sun::star::lang::XServiceInfo
> OCatalog_BASE
;
55 class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE OCatalog
:
57 public IRefreshableGroups
,
58 public IRefreshableUsers
,
59 public connectivity::OSubComponent
<OCatalog
, OCatalog_BASE
>
61 friend class connectivity::OSubComponent
<OCatalog
, OCatalog_BASE
>;
64 ::osl::Mutex m_aMutex
;
66 // this members are deleted when the dtor is called
68 OCollection
* m_pTables
;
69 OCollection
* m_pViews
;
70 OCollection
* m_pGroups
;
71 OCollection
* m_pUsers
;
73 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> m_xMetaData
; // just to make things easier
75 /** builds the name which should be used to access the object later on in the collection.
76 Will only be called in fillNames.
78 The current row from the resultset given to fillNames.
80 virtual OUString
buildName( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>& _xRow
);
82 /** fills a vector with the necessary names which can be used in combination with the collections.
83 For each row buildName will be called.
85 The resultset which should be used to fill the names. Will be disposed after return and set to NULL.
87 The vector who will be filled.
89 void fillNames(::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xResult
,TStringVector
& _rNames
);
92 OCatalog(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> &_xConnection
);
95 DECLARE_SERVICE_INFO();
97 // refreshTables is called when the method getTables had been called
98 // the member m_pTables has to be created
99 virtual void refreshTables() = 0;
100 // refreshViews is called when the method getViews had been called
101 virtual void refreshViews() = 0;
103 // the other refresh methods come from base classes IRefreshableGroups and IRefreshableUsers
105 // ::cppu::OComponentHelper
106 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
108 void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
109 void SAL_CALL
release() throw() SAL_OVERRIDE
;
111 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getTables( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getViews( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getUsers( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
117 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getGroups( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
123 #endif // INCLUDED_CONNECTIVITY_SDBCX_VCATALOG_HXX
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */