Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _DBAUI_INDEXCOLLECTION_HXX_
21 : #define _DBAUI_INDEXCOLLECTION_HXX_
22 :
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/sdbc/SQLException.hpp>
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 : #include "indexes.hxx"
27 :
28 : //......................................................................
29 : namespace dbaui
30 : {
31 : //......................................................................
32 :
33 : //==================================================================
34 : //= OIndexCollection
35 : //==================================================================
36 0 : class OIndexCollection
37 : {
38 : protected:
39 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
40 : m_xIndexes;
41 :
42 : // cached information
43 : Indexes m_aIndexes;
44 :
45 : public:
46 : // construction
47 : OIndexCollection();
48 : OIndexCollection(const OIndexCollection& _rSource);
49 : // OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
50 :
51 : const OIndexCollection& operator=(const OIndexCollection& _rSource);
52 :
53 : // iterating through the collection
54 : typedef OIndex* iterator;
55 : typedef OIndex const* const_iterator;
56 :
57 : /// get access to the first element of the index collection
58 : Indexes::const_iterator begin() const { return m_aIndexes.begin(); }
59 : /// get access to the first element of the index collection
60 0 : Indexes::iterator begin() { return m_aIndexes.begin(); }
61 : /// get access to the (last + 1st) element of the index collection
62 : Indexes::const_iterator end() const { return m_aIndexes.end(); }
63 : /// get access to the (last + 1st) element of the index collection
64 0 : Indexes::iterator end() { return m_aIndexes.end(); }
65 :
66 : // searching
67 : Indexes::const_iterator find(const String& _rName) const;
68 : Indexes::iterator find(const String& _rName);
69 : Indexes::const_iterator findOriginal(const String& _rName) const;
70 : Indexes::iterator findOriginal(const String& _rName);
71 :
72 : // inserting without committing
73 : // the OriginalName of the newly inserted index will be empty, thus indicating that it's new
74 : Indexes::iterator insert(const String& _rName);
75 : // commit a new index, which is already part if the collection, but does not have an equivalent in the
76 : // data source, yet
77 : void commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
78 :
79 : // reset the data for the given index
80 : void resetIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
81 :
82 : // attach to a new key container
83 : void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
84 : // detach from the container
85 : void detach();
86 :
87 : // is the object valid?
88 : sal_Bool isValid() const { return m_xIndexes.is(); }
89 : // number of contained indexes
90 : sal_Int32 size() const { return m_aIndexes.size(); }
91 :
92 : /// drop an index, and remove it from the collection
93 : sal_Bool drop(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
94 : /// simply drop the index described by the name, but don't remove the descriptor from the collection
95 : sal_Bool dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
96 :
97 : protected:
98 : void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
99 : void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor) SAL_THROW((::com::sun::star::uno::Exception));
100 : void implFillIndexInfo(OIndex& _rIndex) SAL_THROW((::com::sun::star::uno::Exception));
101 : };
102 :
103 :
104 : //......................................................................
105 : } // namespace dbaui
106 : //......................................................................
107 :
108 : #endif // _DBAUI_INDEXCOLLECTION_HXX_
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|