xref: /trunk/main/UnoControls/source/inc/OConnectionPointHelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _OCONNECTIONPOINTHELPER_HXX
29 #define _OCONNECTIONPOINTHELPER_HXX
30 
31 //______________________________________________________________________________________________________________
32 //  includes of other projects
33 //______________________________________________________________________________________________________________
34 
35 #include <com/sun/star/lang/XConnectionPointContainer.hpp>
36 #include <com/sun/star/lang/XConnectionPoint.hpp>
37 #include <cppuhelper/weak.hxx>
38 #include <cppuhelper/propshlp.hxx>
39 
40 //______________________________________________________________________________________________________________
41 //  includes of my own project
42 //______________________________________________________________________________________________________________
43 #include "OConnectionPointContainerHelper.hxx"
44 
45 //______________________________________________________________________________________________________________
46 //  namespaces
47 //______________________________________________________________________________________________________________
48 
49 namespace unocontrols{
50 
51 #define UNO3_ANY                                        ::com::sun::star::uno::Any
52 #define UNO3_SEQUENCE                                   ::com::sun::star::uno::Sequence
53 #define UNO3_TYPE                                       ::com::sun::star::uno::Type
54 #define UNO3_REFERENCE                                  ::com::sun::star::uno::Reference
55 #define UNO3_XCONNECTIONPOINTCONTAINER                  ::com::sun::star::lang::XConnectionPointContainer
56 #define UNO3_XCONNECTIONPOINT                           ::com::sun::star::lang::XConnectionPoint
57 #define UNO3_MUTEX                                      ::osl::Mutex
58 #define UNO3_RUNTIMEEXCEPTION                           ::com::sun::star::uno::RuntimeException
59 #define UNO3_XINTERFACE                                 ::com::sun::star::uno::XInterface
60 #define UNO3_OMULTITYPEINTERFACECONTAINERHELPER         ::cppu::OMultiTypeInterfaceContainerHelper
61 #define UNO3_LISTENEREXISTEXCEPTION                     ::com::sun::star::lang::ListenerExistException
62 #define UNO3_INVALIDLISTENEREXCEPTION                   ::com::sun::star::lang::InvalidListenerException
63 #define UNO3_WEAKREFERENCE                              ::com::sun::star::uno::WeakReference
64 #define UNO3_OWEAKOBJECT                                ::cppu::OWeakObject
65 #define UNO3_OCONNECTIONPOINTCONTAINERHELPER            OConnectionPointContainerHelper
66 
67 //______________________________________________________________________________________________________________
68 //  defines
69 //______________________________________________________________________________________________________________
70 
71 //______________________________________________________________________________________________________________
72 //  class declaration OConnectionPointHelper
73 //______________________________________________________________________________________________________________
74 
75 class OConnectionPointHelper    :   public  UNO3_XCONNECTIONPOINT
76                                 ,   public  UNO3_OWEAKOBJECT
77 {
78 
79 //______________________________________________________________________________________________________________
80 //  public methods
81 //______________________________________________________________________________________________________________
82 
83 public:
84 
85     //__________________________________________________________________________________________________________
86     //  construct/destruct
87     //__________________________________________________________________________________________________________
88 
89     /**_________________________________________________________________________________________________________
90         @short
91         @descr
92 
93         @seealso
94 
95         @param
96 
97         @return
98 
99         @onerror
100     */
101 
102     OConnectionPointHelper( UNO3_MUTEX&                             aMutex                      ,
103                             UNO3_OCONNECTIONPOINTCONTAINERHELPER*   pContainerImplementation    ,
104                             UNO3_TYPE                               aType                       );
105 
106     /**_________________________________________________________________________________________________________
107         @short
108         @descr
109 
110         @seealso
111 
112         @param
113 
114         @return
115 
116         @onerror
117     */
118 
119     virtual ~OConnectionPointHelper();
120 
121     //________________________________________________________________________________________________________
122     //  XInterface
123     //________________________________________________________________________________________________________
124 
125     /**_______________________________________________________________________________________________________
126         @short      give answer, if interface is supported
127         @descr      The interfaces are searched by type.
128 
129         @seealso    XInterface
130 
131         @param      "rType" is the type of searched interface.
132 
133         @return     Any     information about found interface
134 
135         @onerror    A RuntimeException is thrown.
136     */
137 
138     virtual UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION );
139 
140     /**_______________________________________________________________________________________________________
141         @short      increment refcount
142         @descr      -
143 
144         @seealso    XInterface
145         @seealso    release()
146 
147         @param      -
148 
149         @return     -
150 
151         @onerror    A RuntimeException is thrown.
152     */
153 
154     virtual void SAL_CALL acquire() throw();
155 
156     /**_______________________________________________________________________________________________________
157         @short      decrement refcount
158         @descr      -
159 
160         @seealso    XInterface
161         @seealso    acquire()
162 
163         @param      -
164 
165         @return     -
166 
167         @onerror    A RuntimeException is thrown.
168     */
169 
170     virtual void SAL_CALL release() throw();
171 
172     //__________________________________________________________________________________________________________
173     //  XConnectionPoint
174     //__________________________________________________________________________________________________________
175 
176     /**_________________________________________________________________________________________________________
177         @short
178         @descr
179 
180         @seealso
181 
182         @param
183 
184         @return
185 
186         @onerror
187     */
188 
189     virtual UNO3_TYPE SAL_CALL getConnectionType() throw( UNO3_RUNTIMEEXCEPTION );
190 
191     /**_________________________________________________________________________________________________________
192         @short
193         @descr
194 
195         @seealso
196 
197         @param
198 
199         @return
200 
201         @onerror
202     */
203 
204     virtual UNO3_REFERENCE< UNO3_XCONNECTIONPOINTCONTAINER > SAL_CALL getConnectionPointContainer() throw( UNO3_RUNTIMEEXCEPTION );
205 
206     /**_________________________________________________________________________________________________________
207         @short
208         @descr
209 
210         @seealso
211 
212         @param
213 
214         @return
215 
216         @onerror
217     */
218 
219     virtual void SAL_CALL advise( const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw(   UNO3_LISTENEREXISTEXCEPTION     ,
220                                                                                                 UNO3_INVALIDLISTENEREXCEPTION   ,
221                                                                                                 UNO3_RUNTIMEEXCEPTION           );
222 
223     /**_________________________________________________________________________________________________________
224         @short
225         @descr
226 
227         @seealso
228 
229         @param
230 
231         @return
232 
233         @onerror
234     */
235 
236     virtual void SAL_CALL unadvise( const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener ) throw( UNO3_RUNTIMEEXCEPTION );
237 
238     /**_________________________________________________________________________________________________________
239         @short
240         @descr
241 
242         @seealso
243 
244         @param
245 
246         @return
247 
248         @onerror
249     */
250 
251     virtual UNO3_SEQUENCE< UNO3_REFERENCE< UNO3_XINTERFACE > > SAL_CALL getConnections() throw( UNO3_RUNTIMEEXCEPTION );
252 
253 //______________________________________________________________________________________________________________
254 //  private methods
255 //______________________________________________________________________________________________________________
256 
257 private:
258 
259     /**_________________________________________________________________________________________________________
260         @short
261         @descr
262 
263         @seealso
264 
265         @param
266 
267         @return
268 
269         @onerror
270     */
271 
272     sal_Bool impl_LockContainer();
273 
274     /**_________________________________________________________________________________________________________
275         @short
276         @descr
277 
278         @seealso
279 
280         @param
281 
282         @return
283 
284         @onerror
285     */
286 
287     void impl_UnlockContainer();
288 
289 //______________________________________________________________________________________________________________
290 //  private variables
291 //______________________________________________________________________________________________________________
292 
293 private:
294 
295     UNO3_MUTEX&                                             m_aSharedMutex              ;
296     UNO3_WEAKREFERENCE< UNO3_XCONNECTIONPOINTCONTAINER >    m_oContainerWeakReference   ;   // Reference to container-class!. Don't use Reference<...>
297                                                                                             // It is a ring-reference => and must be a wekreference!
298     UNO3_OCONNECTIONPOINTCONTAINERHELPER*                   m_pContainerImplementation  ;
299     UNO3_TYPE                                               m_aInterfaceType            ;
300     UNO3_REFERENCE< UNO3_XINTERFACE >                       m_xLock                     ;
301 
302 };  // class OConnectionPointHelper
303 
304 }   // namespace unocontrols
305 
306 #endif  // #ifndef _OCONNECTIONPOINTHELPER_HXX
307