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