xref: /trunk/main/connectivity/inc/connectivity/sdbcx/VCatalog.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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_SDBCX_CATALOG_HXX_
25 #define _CONNECTIVITY_SDBCX_CATALOG_HXX_
26 
27 #include <osl/diagnose.h>
28 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
29 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
30 #include <com/sun/star/sdbcx/XUsersSupplier.hpp>
31 #include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
32 #include <com/sun/star/sdbc/XConnection.hpp>
33 #include <com/sun/star/sdbc/XRow.hpp>
34 #include <cppuhelper/compbase5.hxx>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include "connectivity/CommonTools.hxx"
37 #include "OSubComponent.hxx"
38 #include "connectivity/sdbcx/IRefreshable.hxx"
39 #include "connectivity/StdTypeDefs.hxx"
40 #include "connectivity/dbtoolsdllapi.hxx"
41 
42 namespace connectivity
43 {
44     namespace sdbcx
45     {
46 
47         class OCollection;
48         // OCatalog is a general catalog class
49         // other drivers can be derived their catalog from this class when they want to support sdbcx
50         // it holds already tables, views, groups and users
51 
52         typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbcx::XTablesSupplier,
53                                                   ::com::sun::star::sdbcx::XViewsSupplier,
54                                                   ::com::sun::star::sdbcx::XUsersSupplier,
55                                                   ::com::sun::star::sdbcx::XGroupsSupplier,
56                                                   ::com::sun::star::lang::XServiceInfo> OCatalog_BASE;
57 
58 
59         class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE OCatalog :
60                             public OCatalog_BASE,
61                             public IRefreshableGroups,
62                             public IRefreshableUsers,
63                             public connectivity::OSubComponent<OCatalog, OCatalog_BASE>
64         {
65             friend class connectivity::OSubComponent<OCatalog, OCatalog_BASE>;
66         protected:
67 
68             ::osl::Mutex        m_aMutex;
69 
70             // this members are deleted when the dtor is called
71             // they are hold weak
72             OCollection*        m_pTables;
73             OCollection*        m_pViews;
74             OCollection*        m_pGroups;
75             OCollection*        m_pUsers;
76 
77             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
78 
79             /** builds the name which should be used to access the object later on in the collection.
80                 Will only be called in fillNames.
81                 @param  _xRow
82                     The current row from the resultset given to fillNames.
83             */
84             virtual ::rtl::OUString buildName(  const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >& _xRow);
85 
86             /** fills a vector with the necessary names which can be used in combination with the collections.
87                 For each row buildName will be called.
88                 @param  _xResult
89                     The resultset which should be used to fill the names. Will be disposed after return and set to NULL.
90                 @param  _rNames
91                     The vector who will be filled.
92             */
93             void fillNames(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResult,TStringVector& _rNames);
94 
95         public:
96             OCatalog(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> &_xConnection);
97             virtual ~OCatalog();
98 
99             DECLARE_SERVICE_INFO();
100 
101             // refreshTables is called when the method getTables had been called
102             // the member m_pTables has to be created
103             virtual void refreshTables()    = 0;
104             // refreshViews is called when the method getViews had been called
105             virtual void refreshViews()     = 0;
106 
107             // the other refresh methods come from base classes IRefreshableGroups and IRefreshableUsers
108 
109             // ::cppu::OComponentHelper
110             virtual void SAL_CALL disposing(void);
111             // XInterface
112             void SAL_CALL acquire() throw();
113             void SAL_CALL release() throw();
114             // XTablesSupplier
115             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(  ) throw(::com::sun::star::uno::RuntimeException);
116             // XViewsSupplier
117             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews(  ) throw(::com::sun::star::uno::RuntimeException);
118             // XUsersSupplier
119             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers(  ) throw(::com::sun::star::uno::RuntimeException);
120             // XGroupsSupplier
121             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups(  ) throw(::com::sun::star::uno::RuntimeException);
122 
123         };
124     }
125 }
126 
127 #endif // _CONNECTIVITY_SDBCX_CATALOG_HXX_
128