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