1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _DBAUI_INDEXCOLLECTION_HXX_ 29 #define _DBAUI_INDEXCOLLECTION_HXX_ 30 31 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 32 #include <com/sun/star/container/XNameAccess.hpp> 33 #endif 34 #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ 35 #include <com/sun/star/sdbc/SQLException.hpp> 36 #endif 37 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 38 #include <com/sun/star/beans/XPropertySet.hpp> 39 #endif 40 #ifndef _DBAUI_INDEXES_HXX_ 41 #include "indexes.hxx" 42 #endif 43 44 //...................................................................... 45 namespace dbaui 46 { 47 //...................................................................... 48 49 //================================================================== 50 //= OIndexCollection 51 //================================================================== 52 class OIndexCollection 53 { 54 protected: 55 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > 56 m_xIndexes; 57 58 // cached information 59 Indexes m_aIndexes; 60 61 public: 62 // construction 63 OIndexCollection(); 64 OIndexCollection(const OIndexCollection& _rSource); 65 // OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 66 67 const OIndexCollection& operator=(const OIndexCollection& _rSource); 68 69 // iterating through the collection 70 typedef OIndex* iterator; 71 typedef OIndex const* const_iterator; 72 73 /// get access to the first element of the index collection 74 Indexes::const_iterator begin() const { return m_aIndexes.begin(); } 75 /// get access to the first element of the index collection 76 Indexes::iterator begin() { return m_aIndexes.begin(); } 77 /// get access to the (last + 1st) element of the index collection 78 Indexes::const_iterator end() const { return m_aIndexes.end(); } 79 /// get access to the (last + 1st) element of the index collection 80 Indexes::iterator end() { return m_aIndexes.end(); } 81 82 // searching 83 Indexes::const_iterator find(const String& _rName) const; 84 Indexes::iterator find(const String& _rName); 85 Indexes::const_iterator findOriginal(const String& _rName) const; 86 Indexes::iterator findOriginal(const String& _rName); 87 88 // inserting without committing 89 // the OriginalName of the newly inserted index will be empty, thus indicating that it's new 90 Indexes::iterator insert(const String& _rName); 91 // commit a new index, which is already part if the collection, but does not have an equivalent in the 92 // data source, yet 93 void commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 94 95 // reset the data for the given index 96 void resetIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 97 98 // attach to a new key container 99 void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 100 // detach from the container 101 void detach(); 102 103 // is the object valid? 104 sal_Bool isValid() const { return m_xIndexes.is(); } 105 // number of contained indexes 106 sal_Int32 size() const { return m_aIndexes.size(); } 107 108 /// drop an index, and remove it from the collection 109 sal_Bool drop(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 110 /// simply drop the index described by the name, but don't remove the descriptor from the collection 111 sal_Bool dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException)); 112 113 protected: 114 void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes); 115 void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor) SAL_THROW((::com::sun::star::uno::Exception)); 116 void implFillIndexInfo(OIndex& _rIndex) SAL_THROW((::com::sun::star::uno::Exception)); 117 }; 118 119 120 //...................................................................... 121 } // namespace dbaui 122 //...................................................................... 123 124 #endif // _DBAUI_INDEXCOLLECTION_HXX_ 125 126