bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_xcontainer.hxx
blobf53b0303ae1bbfdf49e8e38f7db16f2230c3b156
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XCONTAINER_HXX
38 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XCONTAINER_HXX
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include <com/sun/star/container/XIndexAccess.hpp>
41 #include <com/sun/star/container/XEnumerationAccess.hpp>
42 #include <com/sun/star/container/XContainer.hpp>
44 #include <com/sun/star/sdbcx/XAppend.hpp>
45 #include <com/sun/star/sdbcx/XDrop.hpp>
46 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
48 #include <com/sun/star/util/XRefreshable.hpp>
50 #include <cppuhelper/compbase.hxx>
52 #include <unordered_map>
54 #include "pq_connection.hxx"
55 #include "pq_statics.hxx"
57 namespace pq_sdbc_driver
60 class EventBroadcastHelper
62 public:
63 virtual void fire(css::lang::XEventListener * listener) const = 0;
64 virtual css::uno::Type getType() const = 0;
65 virtual ~EventBroadcastHelper(){};
68 class RefreshedBroadcaster : public EventBroadcastHelper
70 css::lang::EventObject m_event;
71 public:
72 explicit RefreshedBroadcaster(const css::uno::Reference< css::uno::XInterface > & source ) :
73 m_event( source )
76 virtual void fire( css::lang::XEventListener * listener ) const override
78 static_cast<css::util::XRefreshListener*>(listener)->refreshed( m_event );
81 virtual css::uno::Type getType() const override
83 return cppu::UnoType<
84 css::util::XRefreshListener>::get();
88 typedef std::unordered_map
90 OUString,
91 sal_Int32
92 > String2IntMap;
94 typedef ::cppu::WeakComponentImplHelper
96 css::container::XNameAccess,
97 css::container::XIndexAccess,
98 css::container::XEnumerationAccess,
99 css::sdbcx::XAppend,
100 css::sdbcx::XDrop,
101 css::util::XRefreshable,
102 css::sdbcx::XDataDescriptorFactory,
103 css::container::XContainer
104 > ContainerBase;
106 class /* abstract */ Container : public ContainerBase
108 protected:
109 ::rtl::Reference< comphelper::RefCountedMutex > m_xMutex;
110 ConnectionSettings *m_pSettings;
111 css::uno::Reference< css::sdbc::XConnection > m_origin;
112 String2IntMap m_name2index; // maps the element name to an index
113 std::vector< css::uno::Any > m_values; // contains the real values
114 OUString m_type;
116 public:
117 Container(
118 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
119 const css::uno::Reference< css::sdbc::XConnection > & origin,
120 ConnectionSettings *pSettings,
121 const OUString & type // for exception messages
124 public: // XIndexAccess
125 virtual sal_Int32 SAL_CALL getCount( ) override;
126 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
128 public: // XEnumerationAccess
129 virtual css::uno::Reference< css::container::XEnumeration >
130 SAL_CALL createEnumeration( ) override;
132 public: // XNameAccess
133 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
134 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
135 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
136 // Methods
137 virtual css::uno::Type SAL_CALL getElementType( ) override;
138 virtual sal_Bool SAL_CALL hasElements( ) override;
141 public: // XAppend
142 // Must be overridden in Non-Descriptors. May be overridden in descriptors, when
143 // PropertySet.NAME != container name
144 virtual void SAL_CALL appendByDescriptor(
145 const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override;
147 // helper method !
148 /// @throws css::container::ElementExistException
149 void append(
150 const OUString & str,
151 const css::uno::Reference< css::beans::XPropertySet >& descriptor );
154 public: // XDrop
155 virtual void SAL_CALL dropByName( const OUString& elementName ) override;
156 virtual void SAL_CALL dropByIndex( sal_Int32 index ) override;
158 public: // XDataDescriptorFactory
159 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override = 0;
161 public: // XRefreshable
162 virtual void SAL_CALL refresh( ) override {}
163 virtual void SAL_CALL addRefreshListener(
164 const css::uno::Reference< css::util::XRefreshListener >& l ) override;
165 virtual void SAL_CALL removeRefreshListener(
166 const css::uno::Reference< css::util::XRefreshListener >& l ) override;
168 public:
169 // Methods
170 virtual void SAL_CALL addContainerListener(
171 const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
172 virtual void SAL_CALL removeContainerListener(
173 const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
175 public:
176 virtual void SAL_CALL disposing() override;
178 public:
179 void rename( const OUString & oldName, const OUString &newName );
181 protected:
182 void fire( const EventBroadcastHelper & helper );
186 #endif
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */