xref: /trunk/main/dbaccess/source/ui/inc/indexcollection.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBAUI_INDEXCOLLECTION_HXX_
25cdf0e10cSrcweir #define _DBAUI_INDEXCOLLECTION_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
28cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
31cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBAUI_INDEXES_HXX_
37cdf0e10cSrcweir #include "indexes.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //......................................................................
41cdf0e10cSrcweir namespace dbaui
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //......................................................................
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     //==================================================================
46cdf0e10cSrcweir     //= OIndexCollection
47cdf0e10cSrcweir     //==================================================================
48cdf0e10cSrcweir     class OIndexCollection
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir     protected:
51cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
52cdf0e10cSrcweir                     m_xIndexes;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir         // cached information
55cdf0e10cSrcweir         Indexes     m_aIndexes;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     public:
58cdf0e10cSrcweir         // construction
59cdf0e10cSrcweir         OIndexCollection();
60cdf0e10cSrcweir         OIndexCollection(const OIndexCollection& _rSource);
61cdf0e10cSrcweir         //  OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         const OIndexCollection& operator=(const OIndexCollection& _rSource);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         // iterating through the collection
66cdf0e10cSrcweir         typedef OIndex* iterator;
67cdf0e10cSrcweir         typedef OIndex const* const_iterator;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir         /// get access to the first element of the index collection
begin() const70cdf0e10cSrcweir         Indexes::const_iterator begin() const { return m_aIndexes.begin(); }
71cdf0e10cSrcweir         /// get access to the first element of the index collection
begin()72cdf0e10cSrcweir         Indexes::iterator begin() { return m_aIndexes.begin(); }
73cdf0e10cSrcweir         /// get access to the (last + 1st) element of the index collection
end() const74cdf0e10cSrcweir         Indexes::const_iterator end() const { return m_aIndexes.end(); }
75cdf0e10cSrcweir         /// get access to the (last + 1st) element of the index collection
end()76cdf0e10cSrcweir         Indexes::iterator end() { return m_aIndexes.end(); }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         // searching
79cdf0e10cSrcweir         Indexes::const_iterator find(const String& _rName) const;
80cdf0e10cSrcweir         Indexes::iterator find(const String& _rName);
81cdf0e10cSrcweir         Indexes::const_iterator findOriginal(const String& _rName) const;
82cdf0e10cSrcweir         Indexes::iterator findOriginal(const String& _rName);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         // inserting without committing
85cdf0e10cSrcweir         // the OriginalName of the newly inserted index will be empty, thus indicating that it's new
86cdf0e10cSrcweir         Indexes::iterator insert(const String& _rName);
87cdf0e10cSrcweir         // commit a new index, which is already part if the collection, but does not have an equivalent in the
88cdf0e10cSrcweir         // data source, yet
89cdf0e10cSrcweir         void commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         // reset the data for the given index
92cdf0e10cSrcweir         void resetIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         // attach to a new key container
95cdf0e10cSrcweir         void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
96cdf0e10cSrcweir         // detach from the container
97cdf0e10cSrcweir         void detach();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         // is the object valid?
isValid() const100cdf0e10cSrcweir         sal_Bool    isValid() const { return m_xIndexes.is(); }
101cdf0e10cSrcweir         // number of contained indexes
size() const102cdf0e10cSrcweir         sal_Int32   size() const { return m_aIndexes.size(); }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         /// drop an index, and remove it from the collection
105cdf0e10cSrcweir         sal_Bool    drop(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
106cdf0e10cSrcweir         /// simply drop the index described by the name, but don't remove the descriptor from the collection
107cdf0e10cSrcweir         sal_Bool    dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     protected:
110cdf0e10cSrcweir         void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
111cdf0e10cSrcweir         void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor) SAL_THROW((::com::sun::star::uno::Exception));
112cdf0e10cSrcweir         void implFillIndexInfo(OIndex& _rIndex) SAL_THROW((::com::sun::star::uno::Exception));
113cdf0e10cSrcweir     };
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //......................................................................
117cdf0e10cSrcweir }   // namespace dbaui
118cdf0e10cSrcweir //......................................................................
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #endif // _DBAUI_INDEXCOLLECTION_HXX_
121