Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / postgresql / pq_xcontainer.hxx
blobbe1fdf1e735cbc4b1ec379ad2af20c8568938aa8
1 /*************************************************************************
3 * $RCSfile: pq_xcontainer.hxx,v $
5 * $Revision: 1.1.2.4 $
7 * last change: $Author: jbu $ $Date: 2007/01/07 13:50:38 $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Joerg Budischewski
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Joerg Budischewski
60 ************************************************************************/
62 #ifndef _PQ_CONTAINER_HXX_
63 #define _PQ_CONTAINER_HXX_
64 #include <hash_map>
65 #include <vector>
67 #include <com/sun/star/container/XNameAccess.hpp>
68 #include <com/sun/star/container/XIndexAccess.hpp>
69 #include <com/sun/star/container/XEnumerationAccess.hpp>
70 #include <com/sun/star/container/XContainer.hpp>
72 #include <com/sun/star/sdbcx/XAppend.hpp>
73 #include <com/sun/star/sdbcx/XDrop.hpp>
74 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
76 #include <com/sun/star/util/XRefreshable.hpp>
78 #include <cppuhelper/compbase8.hxx>
80 #include "pq_connection.hxx"
81 #include "pq_statics.hxx"
83 namespace pq_sdbc_driver
86 class EventBroadcastHelper
88 public:
89 virtual void fire(com::sun::star::lang::XEventListener * listener) const = 0;
90 virtual com::sun::star::uno::Type getType() const = 0;
91 virtual ~EventBroadcastHelper(){};
94 class RefreshedBroadcaster : public EventBroadcastHelper
96 com::sun::star::lang::EventObject m_event;
97 public:
98 RefreshedBroadcaster(const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & source ) :
99 m_event( source )
102 virtual void fire( com::sun::star::lang::XEventListener * listener ) const
104 ((com::sun::star::util::XRefreshListener*)listener)->refreshed( m_event );
107 virtual com::sun::star::uno::Type getType() const
109 return getCppuType(
110 (com::sun::star::uno::Reference< com::sun::star::util::XRefreshListener > *)0 );
114 typedef ::std::hash_map
116 rtl::OUString,
117 sal_Int32,
118 rtl::OUStringHash,
119 ::std::equal_to< rtl::OUString >,
120 Allocator< ::std::pair< const ::rtl::OUString , sal_Int32 > >
121 > String2IntMap;
123 typedef ::cppu::WeakComponentImplHelper8
125 com::sun::star::container::XNameAccess,
126 com::sun::star::container::XIndexAccess,
127 com::sun::star::container::XEnumerationAccess,
128 com::sun::star::sdbcx::XAppend,
129 com::sun::star::sdbcx::XDrop,
130 com::sun::star::util::XRefreshable,
131 com::sun::star::sdbcx::XDataDescriptorFactory,
132 com::sun::star::container::XContainer
133 > ContainerBase;
135 class /* abstract */ Container : public ContainerBase
137 protected:
138 ::rtl::Reference< RefCountedMutex > m_refMutex;
139 ConnectionSettings *m_pSettings;
140 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_origin;
141 String2IntMap m_name2index; // maps the element name to an index
142 ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values; // contains the real values
143 ::rtl::OUString m_type;
145 public:
146 Container(
147 const ::rtl::Reference< RefCountedMutex > & refMutex,
148 const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
149 ConnectionSettings *pSettings,
150 const ::rtl::OUString & type // for exception messages
153 public: // XIndexAccess
154 virtual sal_Int32 SAL_CALL getCount( )
155 throw (::com::sun::star::uno::RuntimeException);
156 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
157 throw (::com::sun::star::lang::IndexOutOfBoundsException,
158 ::com::sun::star::lang::WrappedTargetException,
159 ::com::sun::star::uno::RuntimeException);
161 public: // XEnumerationAccess
162 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
163 SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException);
165 public: // XNameAccess
166 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
167 throw (::com::sun::star::container::NoSuchElementException,
168 ::com::sun::star::lang::WrappedTargetException,
169 ::com::sun::star::uno::RuntimeException);
170 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
171 throw (::com::sun::star::uno::RuntimeException);
172 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
173 throw (::com::sun::star::uno::RuntimeException);
174 // Methods
175 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
176 throw (::com::sun::star::uno::RuntimeException);
177 virtual sal_Bool SAL_CALL hasElements( )
178 throw (::com::sun::star::uno::RuntimeException);
181 public: // XAppend
182 // Must be overriden in Non-Descriptors. May be overriden in descriptors, when
183 // PropertySet.NAME != container name
184 virtual void SAL_CALL appendByDescriptor(
185 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
186 throw (::com::sun::star::sdbc::SQLException,
187 ::com::sun::star::container::ElementExistException,
188 ::com::sun::star::uno::RuntimeException);
190 // helper method !
191 void append(
192 const rtl::OUString & str,
193 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
194 throw ( ::com::sun::star::container::ElementExistException );
197 public: // XDrop
198 virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
199 throw (::com::sun::star::sdbc::SQLException,
200 ::com::sun::star::container::NoSuchElementException,
201 ::com::sun::star::uno::RuntimeException);
202 virtual void SAL_CALL dropByIndex( sal_Int32 index )
203 throw (::com::sun::star::sdbc::SQLException,
204 ::com::sun::star::lang::IndexOutOfBoundsException,
205 ::com::sun::star::uno::RuntimeException);
207 public: // XDataDescriptorFactory
208 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
209 throw (::com::sun::star::uno::RuntimeException) = 0;
211 public: // XRefreshable
212 virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException) {}
213 virtual void SAL_CALL addRefreshListener(
214 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
215 throw (::com::sun::star::uno::RuntimeException);
216 virtual void SAL_CALL removeRefreshListener(
217 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
218 throw (::com::sun::star::uno::RuntimeException);
220 public:
221 // Methods
222 virtual void SAL_CALL addContainerListener(
223 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
224 throw (::com::sun::star::uno::RuntimeException);
225 virtual void SAL_CALL removeContainerListener(
226 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
227 throw (::com::sun::star::uno::RuntimeException);
229 public:
230 virtual void SAL_CALL disposing();
232 public:
233 void rename( const rtl::OUString & oldName, const rtl::OUString &newName );
235 protected:
236 void fire( const EventBroadcastHelper & helper );
240 #endif