1*24f6443dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*24f6443dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*24f6443dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*24f6443dSAndrew Rist * distributed with this work for additional information
6*24f6443dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*24f6443dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*24f6443dSAndrew Rist * "License"); you may not use this file except in compliance
9*24f6443dSAndrew Rist * with the License. You may obtain a copy of the License at
10*24f6443dSAndrew Rist *
11*24f6443dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*24f6443dSAndrew Rist *
13*24f6443dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*24f6443dSAndrew Rist * software distributed under the License is distributed on an
15*24f6443dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24f6443dSAndrew Rist * KIND, either express or implied. See the License for the
17*24f6443dSAndrew Rist * specific language governing permissions and limitations
18*24f6443dSAndrew Rist * under the License.
19*24f6443dSAndrew Rist *
20*24f6443dSAndrew Rist *************************************************************/
21*24f6443dSAndrew Rist
22*24f6443dSAndrew Rist
23cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
24cdf0e10cSrcweir #define _COM_SUN_STAR_UNO_REFERENCE_H_
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include <rtl/alloc.h>
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir namespace com
30cdf0e10cSrcweir {
31cdf0e10cSrcweir namespace sun
32cdf0e10cSrcweir {
33cdf0e10cSrcweir namespace star
34cdf0e10cSrcweir {
35cdf0e10cSrcweir namespace uno
36cdf0e10cSrcweir {
37cdf0e10cSrcweir
38cdf0e10cSrcweir class RuntimeException;
39cdf0e10cSrcweir class XInterface;
40cdf0e10cSrcweir class Type;
41cdf0e10cSrcweir class Any;
42cdf0e10cSrcweir
43cdf0e10cSrcweir /** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
44cdf0e10cSrcweir Deprecated, please use SAL_NO_ACQUIRE.
45cdf0e10cSrcweir @deprecated
46cdf0e10cSrcweir */
47cdf0e10cSrcweir enum UnoReference_NoAcquire
48cdf0e10cSrcweir {
49cdf0e10cSrcweir /** This enum value can be used for creating a reference granting a given interface,
50cdf0e10cSrcweir i.e. transferring ownership to it.
51cdf0e10cSrcweir */
52cdf0e10cSrcweir UNO_REF_NO_ACQUIRE
53cdf0e10cSrcweir };
54cdf0e10cSrcweir
55cdf0e10cSrcweir /** This base class serves as a base class for all template reference classes and
56cdf0e10cSrcweir has been introduced due to compiler problems with templated operators ==, =!.
57cdf0e10cSrcweir */
58cdf0e10cSrcweir class BaseReference
59cdf0e10cSrcweir {
60cdf0e10cSrcweir protected:
61cdf0e10cSrcweir /** the interface pointer
62cdf0e10cSrcweir */
63cdf0e10cSrcweir XInterface * _pInterface;
64cdf0e10cSrcweir
65cdf0e10cSrcweir /** Queries given interface for type rType.
66cdf0e10cSrcweir
67cdf0e10cSrcweir @param pInterface interface pointer
68cdf0e10cSrcweir @param rType interface type
69cdf0e10cSrcweir @return interface of demanded type (may be null)
70cdf0e10cSrcweir */
71cdf0e10cSrcweir inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType )
72cdf0e10cSrcweir SAL_THROW( (RuntimeException) );
73cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
74cdf0e10cSrcweir /** Queries given interface for type rType.
75cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be queried.
76cdf0e10cSrcweir
77cdf0e10cSrcweir @param pInterface interface pointer
78cdf0e10cSrcweir @param rType interface type
79cdf0e10cSrcweir @return interface of demanded type
80cdf0e10cSrcweir */
81cdf0e10cSrcweir inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType )
82cdf0e10cSrcweir SAL_THROW( (RuntimeException) );
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir
85cdf0e10cSrcweir public:
86cdf0e10cSrcweir /** Gets interface pointer. This call does not acquire the interface.
87cdf0e10cSrcweir
88cdf0e10cSrcweir @return UNacquired interface pointer
89cdf0e10cSrcweir */
get() const90cdf0e10cSrcweir inline XInterface * SAL_CALL get() const SAL_THROW( () )
91cdf0e10cSrcweir { return _pInterface; }
92cdf0e10cSrcweir
93cdf0e10cSrcweir /** Checks if reference is null.
94cdf0e10cSrcweir
95cdf0e10cSrcweir @return true if reference acquires an interface, i.e. true if it is not null
96cdf0e10cSrcweir */
is() const97cdf0e10cSrcweir inline sal_Bool SAL_CALL is() const SAL_THROW( () )
98cdf0e10cSrcweir { return (0 != _pInterface); }
99cdf0e10cSrcweir
100cdf0e10cSrcweir /** Equality operator: compares two interfaces
101cdf0e10cSrcweir Checks if both references are null or refer to the same object.
102cdf0e10cSrcweir
103cdf0e10cSrcweir @param rRef another interface
104cdf0e10cSrcweir @return true if both references are null or refer to the same object, false otherwise
105cdf0e10cSrcweir */
106cdf0e10cSrcweir inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW( () );
107cdf0e10cSrcweir /** Unequality operator: compares two interfaces
108cdf0e10cSrcweir Checks if both references are null or refer to the same object.
109cdf0e10cSrcweir
110cdf0e10cSrcweir @param rRef another interface
111cdf0e10cSrcweir @return false if both references are null or refer to the same object, true otherwise
112cdf0e10cSrcweir */
113cdf0e10cSrcweir inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW( () );
114cdf0e10cSrcweir
115cdf0e10cSrcweir /** Equality operator: compares two interfaces
116cdf0e10cSrcweir Checks if both references are null or refer to the same object.
117cdf0e10cSrcweir
118cdf0e10cSrcweir @param rRef another reference
119cdf0e10cSrcweir @return true if both references are null or refer to the same object, false otherwise
120cdf0e10cSrcweir */
121cdf0e10cSrcweir inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW( () );
122cdf0e10cSrcweir /** Unequality operator: compares two interfaces
123cdf0e10cSrcweir Checks if both references are null or refer to the same object.
124cdf0e10cSrcweir
125cdf0e10cSrcweir @param rRef another reference
126cdf0e10cSrcweir @return false if both references are null or refer to the same object, true otherwise
127cdf0e10cSrcweir */
128cdf0e10cSrcweir inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW( () );
129cdf0e10cSrcweir
130cdf0e10cSrcweir /** Needed by some STL containers.
131cdf0e10cSrcweir
132cdf0e10cSrcweir @param rRef another reference
133cdf0e10cSrcweir @return true, if this reference is less than rRef
134cdf0e10cSrcweir */
135cdf0e10cSrcweir inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW( () );
136cdf0e10cSrcweir };
137cdf0e10cSrcweir
138cdf0e10cSrcweir /** Enum defining UNO_QUERY and UNO_REF_QUERY for implicit interface query.
139cdf0e10cSrcweir */
140cdf0e10cSrcweir enum UnoReference_Query
141cdf0e10cSrcweir {
142cdf0e10cSrcweir /** This enum value can be used for implicit interface query.
143cdf0e10cSrcweir */
144cdf0e10cSrcweir UNO_QUERY,
145cdf0e10cSrcweir /** This enum value can be used for implicit interface query.
146cdf0e10cSrcweir */
147cdf0e10cSrcweir UNO_REF_QUERY
148cdf0e10cSrcweir };
149cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
150cdf0e10cSrcweir /** Enum defining UNO_QUERY_THROW and UNO_REF_QUERY_THROW for implicit interface query.
151cdf0e10cSrcweir If the demanded interface is unavailable, then a RuntimeException is thrown.
152cdf0e10cSrcweir */
153cdf0e10cSrcweir enum UnoReference_QueryThrow
154cdf0e10cSrcweir {
155cdf0e10cSrcweir /** This enum value can be used for implicit interface query.
156cdf0e10cSrcweir */
157cdf0e10cSrcweir UNO_QUERY_THROW,
158cdf0e10cSrcweir /** This enum value can be used for implicit interface query.
159cdf0e10cSrcweir */
160cdf0e10cSrcweir UNO_REF_QUERY_THROW
161cdf0e10cSrcweir };
162cdf0e10cSrcweir /** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a <NULL/>
163cdf0e10cSrcweir interface
164cdf0e10cSrcweir
165cdf0e10cSrcweir @since UDK 3.2.8
166cdf0e10cSrcweir */
167cdf0e10cSrcweir enum UnoReference_SetThrow
168cdf0e10cSrcweir {
169cdf0e10cSrcweir UNO_SET_THROW
170cdf0e10cSrcweir };
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir
173cdf0e10cSrcweir /** Template reference class for interface type derived from BaseReference.
174cdf0e10cSrcweir A special constructor given the UNO_QUERY or UNO_REF_QUERY identifier queries interfaces
175cdf0e10cSrcweir for reference type.
176cdf0e10cSrcweir */
177cdf0e10cSrcweir template< class interface_type >
178cdf0e10cSrcweir class Reference : public BaseReference
179cdf0e10cSrcweir {
180cdf0e10cSrcweir /** Queries given interface for type interface_type.
181cdf0e10cSrcweir
182cdf0e10cSrcweir @param pInterface interface pointer
183cdf0e10cSrcweir @return interface of demanded type (may be null)
184cdf0e10cSrcweir */
185cdf0e10cSrcweir inline static XInterface * SAL_CALL iquery( XInterface * pInterface )
186cdf0e10cSrcweir SAL_THROW( (RuntimeException) );
187cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
188cdf0e10cSrcweir /** Queries given interface for type interface_type.
189cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be queried.
190cdf0e10cSrcweir
191cdf0e10cSrcweir @param pInterface interface pointer
192cdf0e10cSrcweir @return interface of demanded type
193cdf0e10cSrcweir */
194cdf0e10cSrcweir inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface )
195cdf0e10cSrcweir SAL_THROW( (RuntimeException) );
196cdf0e10cSrcweir /** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise.
197cdf0e10cSrcweir
198cdf0e10cSrcweir @param pInterface interface pointer
199cdf0e10cSrcweir @return pInterface
200cdf0e10cSrcweir */
201cdf0e10cSrcweir inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface )
202cdf0e10cSrcweir SAL_THROW( (RuntimeException) );
203cdf0e10cSrcweir #endif
204cdf0e10cSrcweir
205cdf0e10cSrcweir /** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a
206cdf0e10cSrcweir pointer to this interface_type.
207cdf0e10cSrcweir
208cdf0e10cSrcweir To work around ambiguities in the case of multiple-inheritance interface
209cdf0e10cSrcweir types (which inherit XInterface more than once), use reinterpret_cast
210cdf0e10cSrcweir (resp. a sequence of two static_casts, to avoid warnings about
211cdf0e10cSrcweir reinterpret_cast used between related classes) to switch from a pointer
212cdf0e10cSrcweir to XInterface to a pointer to this derived interface_type. In
213cdf0e10cSrcweir principle, this is not guaranteed to work. In practice, it seems to
214cdf0e10cSrcweir work on all supported platforms.
215cdf0e10cSrcweir */
castFromXInterface(XInterface * p)216cdf0e10cSrcweir static inline interface_type * castFromXInterface(XInterface * p) {
217cdf0e10cSrcweir return static_cast< interface_type * >(static_cast< void * >(p));
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir /** Cast from a pointer to this interface_type to an "interface pointer"
221cdf0e10cSrcweir (e.g., BaseReference::_pInterface).
222cdf0e10cSrcweir
223cdf0e10cSrcweir To work around ambiguities in the case of multiple-inheritance interface
224cdf0e10cSrcweir types (which inherit XInterface more than once), use reinterpret_cast
225cdf0e10cSrcweir (resp. a sequence of two static_casts, to avoid warnings about
226cdf0e10cSrcweir reinterpret_cast used between related classes) to switch from a pointer
227cdf0e10cSrcweir to this derived interface_type to a pointer to XInterface. In
228cdf0e10cSrcweir principle, this is not guaranteed to work. In practice, it seems to
229cdf0e10cSrcweir work on all supported platforms.
230cdf0e10cSrcweir */
castToXInterface(interface_type * p)231cdf0e10cSrcweir static inline XInterface * castToXInterface(interface_type * p) {
232cdf0e10cSrcweir return static_cast< XInterface * >(static_cast< void * >(p));
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir public:
236cdf0e10cSrcweir // these are here to force memory de/allocation to sal lib.
237cdf0e10cSrcweir /** @internal */
operator new(size_t nSize)238cdf0e10cSrcweir inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW( () )
239cdf0e10cSrcweir { return ::rtl_allocateMemory( nSize ); }
240cdf0e10cSrcweir /** @internal */
operator delete(void * pMem)241cdf0e10cSrcweir inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW( () )
242cdf0e10cSrcweir { ::rtl_freeMemory( pMem ); }
243cdf0e10cSrcweir /** @internal */
operator new(size_t,void * pMem)244cdf0e10cSrcweir inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW( () )
245cdf0e10cSrcweir { return pMem; }
246cdf0e10cSrcweir /** @internal */
operator delete(void *,void *)247cdf0e10cSrcweir inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW( () )
248cdf0e10cSrcweir {}
249cdf0e10cSrcweir
250cdf0e10cSrcweir /** Destructor: Releases interface if set.
251cdf0e10cSrcweir */
252cdf0e10cSrcweir inline ~Reference() SAL_THROW( () );
253cdf0e10cSrcweir
254cdf0e10cSrcweir /** Default Constructor: Sets null reference.
255cdf0e10cSrcweir */
256cdf0e10cSrcweir inline Reference() SAL_THROW( () );
257cdf0e10cSrcweir
258cdf0e10cSrcweir /** Copy constructor: Copies interface reference.
259cdf0e10cSrcweir
260cdf0e10cSrcweir @param rRef another reference
261cdf0e10cSrcweir */
262cdf0e10cSrcweir inline Reference( const Reference< interface_type > & rRef ) SAL_THROW( () );
263cdf0e10cSrcweir /** Constructor: Sets given interface pointer.
264cdf0e10cSrcweir
265cdf0e10cSrcweir @param pInterface an interface pointer
266cdf0e10cSrcweir */
267cdf0e10cSrcweir inline Reference( interface_type * pInterface ) SAL_THROW( () );
268cdf0e10cSrcweir
269cdf0e10cSrcweir /** Constructor: Sets given interface pointer without acquiring it.
270cdf0e10cSrcweir
271cdf0e10cSrcweir @param pInterface another reference
272cdf0e10cSrcweir @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
273cdf0e10cSrcweir */
274cdf0e10cSrcweir inline Reference( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () );
275cdf0e10cSrcweir /** Constructor: Sets given interface pointer without acquiring it.
276cdf0e10cSrcweir Deprecated, please use SAL_NO_ACQUIRE version.
277cdf0e10cSrcweir
278cdf0e10cSrcweir @deprecated
279cdf0e10cSrcweir @param pInterface another reference
280cdf0e10cSrcweir @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
281cdf0e10cSrcweir */
282cdf0e10cSrcweir inline Reference( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () );
283cdf0e10cSrcweir
284cdf0e10cSrcweir /** Constructor: Queries given interface for reference interface type (interface_type).
285cdf0e10cSrcweir
286cdf0e10cSrcweir @param rRef another reference
287cdf0e10cSrcweir @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to other constructors
288cdf0e10cSrcweir */
289cdf0e10cSrcweir inline Reference( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) );
290cdf0e10cSrcweir /** Constructor: Queries given interface for reference interface type (interface_type).
291cdf0e10cSrcweir
292cdf0e10cSrcweir @param pInterface an interface pointer
293cdf0e10cSrcweir @param dummy UNO_QUERY to force obvious distinction to other constructors
294cdf0e10cSrcweir */
295cdf0e10cSrcweir inline Reference( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) );
296cdf0e10cSrcweir /** Constructor: Queries given any for reference interface type (interface_type).
297cdf0e10cSrcweir
298cdf0e10cSrcweir @param rAny an any
299cdf0e10cSrcweir @param dummy UNO_QUERY to force obvious distinction to other constructors
300cdf0e10cSrcweir */
301cdf0e10cSrcweir inline Reference( const Any & rAny, UnoReference_Query ) SAL_THROW( (RuntimeException) );
302cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
303cdf0e10cSrcweir /** Constructor: Queries given interface for reference interface type (interface_type).
304cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be queried.
305cdf0e10cSrcweir
306cdf0e10cSrcweir @param rRef another reference
307cdf0e10cSrcweir @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
308cdf0e10cSrcweir to other constructors
309cdf0e10cSrcweir */
310cdf0e10cSrcweir inline Reference( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
311cdf0e10cSrcweir /** Constructor: Queries given interface for reference interface type (interface_type).
312cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be queried.
313cdf0e10cSrcweir
314cdf0e10cSrcweir @param pInterface an interface pointer
315cdf0e10cSrcweir @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
316cdf0e10cSrcweir to other constructors
317cdf0e10cSrcweir */
318cdf0e10cSrcweir inline Reference( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
319cdf0e10cSrcweir /** Constructor: Queries given any for reference interface type (interface_type).
320cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be queried.
321cdf0e10cSrcweir
322cdf0e10cSrcweir @param rAny an any
323cdf0e10cSrcweir @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
324cdf0e10cSrcweir to other constructors
325cdf0e10cSrcweir */
326cdf0e10cSrcweir inline Reference( const Any & rAny, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
327cdf0e10cSrcweir /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
328cdf0e10cSrcweir if the source interface is <NULL/>.
329cdf0e10cSrcweir
330cdf0e10cSrcweir @param rRef another interface reference of the same type
331cdf0e10cSrcweir @param dummy UNO_SET_THROW to distinguish from default copy constructor
332cdf0e10cSrcweir
333cdf0e10cSrcweir @since UDK 3.2.8
334cdf0e10cSrcweir */
335cdf0e10cSrcweir inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
336cdf0e10cSrcweir /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
337cdf0e10cSrcweir if the source interface is <NULL/>.
338cdf0e10cSrcweir
339cdf0e10cSrcweir @param pInterface an interface pointer
340cdf0e10cSrcweir @param dummy UNO_SET_THROW to distinguish from default assignment constructor
341cdf0e10cSrcweir
342cdf0e10cSrcweir @since UDK 3.2.8
343cdf0e10cSrcweir */
344cdf0e10cSrcweir inline Reference( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
345cdf0e10cSrcweir #endif
346cdf0e10cSrcweir
347cdf0e10cSrcweir /** Cast operator to Reference< XInterface >: Reference objects are binary compatible and
348cdf0e10cSrcweir any interface must be derived from com.sun.star.uno.XInterface.
349cdf0e10cSrcweir This a useful direct cast possibility.
350cdf0e10cSrcweir */
351cdf0e10cSrcweir inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW( () )
352cdf0e10cSrcweir { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
353cdf0e10cSrcweir
354cdf0e10cSrcweir /** Dereference operator: Used to call interface methods.
355cdf0e10cSrcweir
356cdf0e10cSrcweir @return UNacquired interface pointer
357cdf0e10cSrcweir */
operator ->() const358cdf0e10cSrcweir inline interface_type * SAL_CALL operator -> () const SAL_THROW( () )
359cdf0e10cSrcweir { return castFromXInterface(_pInterface); }
360cdf0e10cSrcweir
361cdf0e10cSrcweir /** Gets interface pointer. This call does not acquire the interface.
362cdf0e10cSrcweir
363cdf0e10cSrcweir @return UNacquired interface pointer
364cdf0e10cSrcweir */
get() const365cdf0e10cSrcweir inline interface_type * SAL_CALL get() const SAL_THROW( () )
366cdf0e10cSrcweir { return castFromXInterface(_pInterface); }
367cdf0e10cSrcweir
368cdf0e10cSrcweir /** Clears reference, i.e. releases interface. Reference is null after clear() call.
369cdf0e10cSrcweir */
370cdf0e10cSrcweir inline void SAL_CALL clear() SAL_THROW( () );
371cdf0e10cSrcweir
372cdf0e10cSrcweir /** Sets the given interface. An interface already set will be released.
373cdf0e10cSrcweir
374cdf0e10cSrcweir @param rRef another reference
375cdf0e10cSrcweir @return true, if non-null interface was set
376cdf0e10cSrcweir */
377cdf0e10cSrcweir inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW( () );
378cdf0e10cSrcweir /** Sets the given interface. An interface already set will be released.
379cdf0e10cSrcweir
380cdf0e10cSrcweir @param pInterface another interface
381cdf0e10cSrcweir @return true, if non-null interface was set
382cdf0e10cSrcweir */
383cdf0e10cSrcweir inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW( () );
384cdf0e10cSrcweir
385cdf0e10cSrcweir /** Sets interface pointer without acquiring it. An interface already set will be released.
386cdf0e10cSrcweir
387cdf0e10cSrcweir @param pInterface an interface pointer
388cdf0e10cSrcweir @param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods
389cdf0e10cSrcweir @return true, if non-null interface was set
390cdf0e10cSrcweir */
391cdf0e10cSrcweir inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () );
392cdf0e10cSrcweir /** Sets interface pointer without acquiring it. An interface already set will be released.
393cdf0e10cSrcweir Deprecated, please use SAL_NO_ACQUIRE version.
394cdf0e10cSrcweir
395cdf0e10cSrcweir @deprecated
396cdf0e10cSrcweir @param pInterface an interface pointer
397cdf0e10cSrcweir @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods
398cdf0e10cSrcweir @return true, if non-null interface was set
399cdf0e10cSrcweir */
400cdf0e10cSrcweir inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () );
401cdf0e10cSrcweir
402cdf0e10cSrcweir /** Queries given interface for reference interface type (interface_type) and sets it.
403cdf0e10cSrcweir An interface already set will be released.
404cdf0e10cSrcweir
405cdf0e10cSrcweir @param pInterface an interface pointer
406cdf0e10cSrcweir @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to set methods
407cdf0e10cSrcweir @return true, if non-null interface was set
408cdf0e10cSrcweir */
409cdf0e10cSrcweir inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) );
410cdf0e10cSrcweir /** Queries given interface for reference interface type (interface_type) and sets it.
411cdf0e10cSrcweir An interface already set will be released.
412cdf0e10cSrcweir
413cdf0e10cSrcweir @param rRef another reference
414cdf0e10cSrcweir @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to set methods
415cdf0e10cSrcweir @return true, if non-null interface was set
416cdf0e10cSrcweir */
417cdf0e10cSrcweir inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) );
418cdf0e10cSrcweir
419cdf0e10cSrcweir /** Queries given any for reference interface type (interface_type)
420cdf0e10cSrcweir and sets it. An interface already set will be released.
421cdf0e10cSrcweir
422cdf0e10cSrcweir @param rAny
423cdf0e10cSrcweir an Any containing an interface
424cdf0e10cSrcweir @param dummy
425cdf0e10cSrcweir UNO_QUERY or UNO_REF_QUERY to force obvious distinction
426cdf0e10cSrcweir to set methods
427cdf0e10cSrcweir @return
428cdf0e10cSrcweir true, if non-null interface was set
429cdf0e10cSrcweir */
430cdf0e10cSrcweir inline bool set( Any const & rAny, UnoReference_Query );
431cdf0e10cSrcweir
432cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
433cdf0e10cSrcweir /** Queries given interface for reference interface type (interface_type) and sets it.
434cdf0e10cSrcweir An interface already set will be released.
435cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be set.
436cdf0e10cSrcweir
437cdf0e10cSrcweir @param pInterface an interface pointer
438cdf0e10cSrcweir @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
439cdf0e10cSrcweir to set methods
440cdf0e10cSrcweir */
441cdf0e10cSrcweir inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
442cdf0e10cSrcweir /** Queries given interface for reference interface type (interface_type) and sets it.
443cdf0e10cSrcweir An interface already set will be released.
444cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be set.
445cdf0e10cSrcweir
446cdf0e10cSrcweir @param rRef another reference
447cdf0e10cSrcweir @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
448cdf0e10cSrcweir to set methods
449cdf0e10cSrcweir */
450cdf0e10cSrcweir inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
451cdf0e10cSrcweir
452cdf0e10cSrcweir /** Queries given any for reference interface type (interface_type) and
453cdf0e10cSrcweir sets it. An interface already set will be released.
454cdf0e10cSrcweir Throws a RuntimeException if the demanded interface cannot be set.
455cdf0e10cSrcweir
456cdf0e10cSrcweir @param rAny
457cdf0e10cSrcweir an Any containing an interface
458cdf0e10cSrcweir @param dummy
459cdf0e10cSrcweir UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious
460cdf0e10cSrcweir distinction to set methods
461cdf0e10cSrcweir */
462cdf0e10cSrcweir inline void set( Any const & rAny, UnoReference_QueryThrow );
463cdf0e10cSrcweir /** sets the given interface
464cdf0e10cSrcweir An interface already set will be released.
465cdf0e10cSrcweir Throws a RuntimeException if the source interface is <NULL/>.
466cdf0e10cSrcweir
467cdf0e10cSrcweir @param pInterface an interface pointer
468cdf0e10cSrcweir @param dummy UNO_SET_THROW to force obvious distinction to other set methods
469cdf0e10cSrcweir
470cdf0e10cSrcweir @since UDK 3.2.8
471cdf0e10cSrcweir */
472cdf0e10cSrcweir inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
473cdf0e10cSrcweir /** sets the given interface
474cdf0e10cSrcweir An interface already set will be released.
475cdf0e10cSrcweir Throws a RuntimeException if the source interface is <NULL/>.
476cdf0e10cSrcweir
477cdf0e10cSrcweir @param rRef an interface reference
478cdf0e10cSrcweir @param dummy UNO_SET_THROW to force obvious distinction to other set methods
479cdf0e10cSrcweir
480cdf0e10cSrcweir @since UDK 3.2.8
481cdf0e10cSrcweir */
482cdf0e10cSrcweir inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
483cdf0e10cSrcweir
484cdf0e10cSrcweir #endif
485cdf0e10cSrcweir
486cdf0e10cSrcweir /** Assignment operator: Acquires given interface pointer and sets reference.
487cdf0e10cSrcweir An interface already set will be released.
488cdf0e10cSrcweir
489cdf0e10cSrcweir @param pInterface an interface pointer
490cdf0e10cSrcweir @return this reference
491cdf0e10cSrcweir */
492cdf0e10cSrcweir inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW( () );
493cdf0e10cSrcweir /** Assignment operator: Acquires given interface reference and sets reference.
494cdf0e10cSrcweir An interface already set will be released.
495cdf0e10cSrcweir
496cdf0e10cSrcweir @param rRef an interface reference
497cdf0e10cSrcweir @return this reference
498cdf0e10cSrcweir */
499cdf0e10cSrcweir inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) SAL_THROW( () );
500cdf0e10cSrcweir
501cdf0e10cSrcweir /** Queries given interface reference for type interface_type.
502cdf0e10cSrcweir
503cdf0e10cSrcweir @param rRef interface reference
504cdf0e10cSrcweir @return interface reference of demanded type (may be null)
505cdf0e10cSrcweir */
506cdf0e10cSrcweir inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) );
507cdf0e10cSrcweir /** Queries given interface for type interface_type.
508cdf0e10cSrcweir
509cdf0e10cSrcweir @param pInterface interface pointer
510cdf0e10cSrcweir @return interface reference of demanded type (may be null)
511cdf0e10cSrcweir */
512cdf0e10cSrcweir inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
513cdf0e10cSrcweir };
514cdf0e10cSrcweir
515cdf0e10cSrcweir /** @internal
516cdf0e10cSrcweir Enables boost::mem_fn and boost::bind to recognize Reference.
517cdf0e10cSrcweir */
518cdf0e10cSrcweir template <typename T>
get_pointer(Reference<T> const & r)519cdf0e10cSrcweir inline T * get_pointer( Reference<T> const& r )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir return r.get();
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir }
525cdf0e10cSrcweir }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
529cdf0e10cSrcweir #endif
530