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 INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXCOLLECTION_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_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 : namespace dbaui
29 : {
30 :
31 : // OIndexCollection
32 0 : class OIndexCollection
33 : {
34 : protected:
35 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
36 : m_xIndexes;
37 :
38 : // cached information
39 : Indexes m_aIndexes;
40 :
41 : public:
42 : // construction
43 : OIndexCollection();
44 : OIndexCollection(const OIndexCollection& _rSource);
45 : // OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
46 :
47 : const OIndexCollection& operator=(const OIndexCollection& _rSource);
48 :
49 : // iterating through the collection
50 : typedef OIndex* iterator;
51 : typedef OIndex const* const_iterator;
52 :
53 : /// get access to the first element of the index collection
54 : Indexes::const_iterator begin() const { return m_aIndexes.begin(); }
55 : /// get access to the first element of the index collection
56 0 : Indexes::iterator begin() { return m_aIndexes.begin(); }
57 : /// get access to the (last + 1st) element of the index collection
58 : Indexes::const_iterator end() const { return m_aIndexes.end(); }
59 : /// get access to the (last + 1st) element of the index collection
60 0 : Indexes::iterator end() { return m_aIndexes.end(); }
61 :
62 : // searching
63 : Indexes::const_iterator find(const OUString& _rName) const;
64 : Indexes::iterator find(const OUString& _rName);
65 : Indexes::const_iterator findOriginal(const OUString& _rName) const;
66 : Indexes::iterator findOriginal(const OUString& _rName);
67 :
68 : // inserting without committing
69 : // the OriginalName of the newly inserted index will be empty, thus indicating that it's new
70 : Indexes::iterator insert(const OUString& _rName);
71 : // commit a new index, which is already part if the collection, but does not have an equivalent in the
72 : // data source, yet
73 : void commitNewIndex(const Indexes::iterator& _rPos);
74 :
75 : // reset the data for the given index
76 : void resetIndex(const Indexes::iterator& _rPos);
77 :
78 : // attach to a new key container
79 : void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
80 : // detach from the container
81 : void detach();
82 :
83 : // is the object valid?
84 : bool isValid() const { return m_xIndexes.is(); }
85 : // number of contained indexes
86 : sal_Int32 size() const { return m_aIndexes.size(); }
87 :
88 : /// drop an index, and remove it from the collection
89 : bool drop(const Indexes::iterator& _rPos);
90 : /// simply drop the index described by the name, but don't remove the descriptor from the collection
91 : bool dropNoRemove(const Indexes::iterator& _rPos);
92 :
93 : protected:
94 : void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
95 : void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor);
96 : void implFillIndexInfo(OIndex& _rIndex);
97 : };
98 :
99 : } // namespace dbaui
100 :
101 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXCOLLECTION_HXX
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|