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