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