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 _DBAUI_INDEXCOLLECTION_HXX_ 25 #define _DBAUI_INDEXCOLLECTION_HXX_ 26 27 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 28 #include <com/sun/star/container/XNameAccess.hpp> 29 #endif 30 #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ 31 #include <com/sun/star/sdbc/SQLException.hpp> 32 #endif 33 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 34 #include <com/sun/star/beans/XPropertySet.hpp> 35 #endif 36 #ifndef _DBAUI_INDEXES_HXX_ 37 #include "indexes.hxx" 38 #endif 39 40 //...................................................................... 41 namespace dbaui 42 { 43 //...................................................................... 44 45 //================================================================== 46 //= OIndexCollection 47 //================================================================== 48 class OIndexCollection 49 { 50 protected: 51 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > 52 m_xIndexes; 53 54 // cached information 55 Indexes m_aIndexes; 56 57 public: 58 // construction 59 OIndexCollection(); 60 OIndexCollection(const OIndexCollection& _rSource); 61 // OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 62 63 const OIndexCollection& operator=(const OIndexCollection& _rSource); 64 65 // iterating through the collection 66 typedef OIndex* iterator; 67 typedef OIndex const* const_iterator; 68 69 /// get access to the first element of the index collection begin() const70 Indexes::const_iterator begin() const { return m_aIndexes.begin(); } 71 /// get access to the first element of the index collection begin()72 Indexes::iterator begin() { return m_aIndexes.begin(); } 73 /// get access to the (last + 1st) element of the index collection end() const74 Indexes::const_iterator end() const { return m_aIndexes.end(); } 75 /// get access to the (last + 1st) element of the index collection end()76 Indexes::iterator end() { return m_aIndexes.end(); } 77 78 // searching 79 Indexes::const_iterator find(const String& _rName) const; 80 Indexes::iterator find(const String& _rName); 81 Indexes::const_iterator findOriginal(const String& _rName) const; 82 Indexes::iterator findOriginal(const String& _rName); 83 84 // inserting without committing 85 // the OriginalName of the newly inserted index will be empty, thus indicating that it's new 86 Indexes::iterator insert(const String& _rName); 87 // commit a new index, which is already part if the collection, but does not have an equivalent in the 88 // data source, yet 89 void commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 90 91 // reset the data for the given index 92 void resetIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 93 94 // attach to a new key container 95 void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 96 // detach from the container 97 void detach(); 98 99 // is the object valid? isValid() const100 sal_Bool isValid() const { return m_xIndexes.is(); } 101 // number of contained indexes size() const102 sal_Int32 size() const { return m_aIndexes.size(); } 103 104 /// drop an index, and remove it from the collection 105 sal_Bool drop(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 106 /// simply drop the index described by the name, but don't remove the descriptor from the collection 107 sal_Bool dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 108 109 protected: 110 void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 111 void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor) SAL_THROW((::com::sun::star::uno::Exception)); 112 void implFillIndexInfo(OIndex& _rIndex) SAL_THROW((::com::sun::star::uno::Exception)); 113 }; 114 115 116 //...................................................................... 117 } // namespace dbaui 118 //...................................................................... 119 120 #endif // _DBAUI_INDEXCOLLECTION_HXX_ 121 122