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,
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 <boost/unordered_map.hpp>
42 #include <com/sun/star/container/XNameAccess.hpp>
43 #include <com/sun/star/container/XIndexAccess.hpp>
44 #include <com/sun/star/container/XEnumerationAccess.hpp>
45 #include <com/sun/star/container/XContainer.hpp>
47 #include <com/sun/star/sdbcx/XAppend.hpp>
48 #include <com/sun/star/sdbcx/XDrop.hpp>
49 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
51 #include <com/sun/star/util/XRefreshable.hpp>
53 #include <cppuhelper/compbase8.hxx>
55 #include "pq_connection.hxx"
56 #include "pq_statics.hxx"
58 namespace pq_sdbc_driver
61 class EventBroadcastHelper
64 virtual void fire(com::sun::star::lang::XEventListener
* listener
) const = 0;
65 virtual com::sun::star::uno::Type
getType() const = 0;
66 virtual ~EventBroadcastHelper(){};
69 class RefreshedBroadcaster
: public EventBroadcastHelper
71 com::sun::star::lang::EventObject m_event
;
73 RefreshedBroadcaster(const com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> & source
) :
77 virtual void fire( com::sun::star::lang::XEventListener
* listener
) const SAL_OVERRIDE
79 ((com::sun::star::util::XRefreshListener
*)listener
)->refreshed( m_event
);
82 virtual com::sun::star::uno::Type
getType() const SAL_OVERRIDE
85 (com::sun::star::uno::Reference
< com::sun::star::util::XRefreshListener
> *)0 );
89 typedef ::boost::unordered_map
94 ::std::equal_to
< OUString
>
97 typedef ::cppu::WeakComponentImplHelper8
99 com::sun::star::container::XNameAccess
,
100 com::sun::star::container::XIndexAccess
,
101 com::sun::star::container::XEnumerationAccess
,
102 com::sun::star::sdbcx::XAppend
,
103 com::sun::star::sdbcx::XDrop
,
104 com::sun::star::util::XRefreshable
,
105 com::sun::star::sdbcx::XDataDescriptorFactory
,
106 com::sun::star::container::XContainer
109 class /* abstract */ Container
: public ContainerBase
112 ::rtl::Reference
< RefCountedMutex
> m_refMutex
;
113 ConnectionSettings
*m_pSettings
;
114 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> m_origin
;
115 String2IntMap m_name2index
; // maps the element name to an index
116 ::com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> m_values
; // contains the real values
121 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
122 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
123 ConnectionSettings
*pSettings
,
124 const OUString
& type
// for exception messages
127 public: // XIndexAccess
128 virtual sal_Int32 SAL_CALL
getCount( )
129 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
131 throw (::com::sun::star::lang::IndexOutOfBoundsException
,
132 ::com::sun::star::lang::WrappedTargetException
,
133 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 public: // XEnumerationAccess
136 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
>
137 SAL_CALL
createEnumeration( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 public: // XNameAccess
140 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
)
141 throw (::com::sun::star::container::NoSuchElementException
,
142 ::com::sun::star::lang::WrappedTargetException
,
143 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
144 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames( )
145 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
147 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
150 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
151 virtual sal_Bool SAL_CALL
hasElements( )
152 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 // Must be overridden in Non-Descriptors. May be overridden in descriptors, when
157 // PropertySet.NAME != container name
158 virtual void SAL_CALL
appendByDescriptor(
159 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& descriptor
)
160 throw (::com::sun::star::sdbc::SQLException
,
161 ::com::sun::star::container::ElementExistException
,
162 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
166 const OUString
& str
,
167 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& descriptor
)
168 throw ( ::com::sun::star::container::ElementExistException
);
172 virtual void SAL_CALL
dropByName( const OUString
& elementName
)
173 throw (::com::sun::star::sdbc::SQLException
,
174 ::com::sun::star::container::NoSuchElementException
,
175 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
176 virtual void SAL_CALL
dropByIndex( sal_Int32 index
)
177 throw (::com::sun::star::sdbc::SQLException
,
178 ::com::sun::star::lang::IndexOutOfBoundsException
,
179 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
181 public: // XDataDescriptorFactory
182 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
createDataDescriptor( )
183 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
185 public: // XRefreshable
186 virtual void SAL_CALL
refresh( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{}
187 virtual void SAL_CALL
addRefreshListener(
188 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
)
189 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
190 virtual void SAL_CALL
removeRefreshListener(
191 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
)
192 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
196 virtual void SAL_CALL
addContainerListener(
197 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
)
198 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 virtual void SAL_CALL
removeContainerListener(
200 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
)
201 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
204 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
207 void rename( const OUString
& oldName
, const OUString
&newName
);
210 void fire( const EventBroadcastHelper
& helper
);
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */