| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* This file is part of LibreOffice published API. |
| 22 |
*/ |
| 23 |
#ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
| 24 |
#define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
| 25 |
|
| 26 |
#include "sal/config.h" |
| 27 |
|
| 28 |
#include <cassert> |
| 29 |
#include <cstddef> |
| 30 |
|
| 31 |
#if defined LIBO_INTERNAL_ONLY |
| 32 |
#include <type_traits> |
| 33 |
#endif |
| 34 |
|
| 35 |
#include "rtl/alloc.h" |
| 36 |
|
| 37 |
namespace com |
| 38 |
{ |
| 39 |
namespace sun |
| 40 |
{ |
| 41 |
namespace star |
| 42 |
{ |
| 43 |
namespace uno |
| 44 |
{ |
| 45 |
|
| 46 |
class RuntimeException; |
| 47 |
class XInterface; |
| 48 |
class Type; |
| 49 |
class Any; |
| 50 |
|
| 51 |
/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface. |
| 52 |
Deprecated, please use SAL_NO_ACQUIRE. |
| 53 |
@deprecated |
| 54 |
*/ |
| 55 |
enum UnoReference_NoAcquire |
| 56 |
{ |
| 57 |
/** This enum value can be used for creating a reference granting a given interface, |
| 58 |
i.e. transferring ownership to it. |
| 59 |
*/ |
| 60 |
UNO_REF_NO_ACQUIRE |
| 61 |
}; |
| 62 |
|
| 63 |
/** This base class serves as a base class for all template reference classes and |
| 64 |
has been introduced due to compiler problems with templated operators ==, =!. |
| 65 |
*/ |
| 66 |
class BaseReference |
| 67 |
{ |
| 68 |
protected: |
| 69 |
/** the interface pointer |
| 70 |
*/ |
| 71 |
XInterface * _pInterface; |
| 72 |
|
| 73 |
/** Queries given interface for type rType. |
| 74 |
|
| 75 |
@param pInterface interface pointer |
| 76 |
@param rType interface type |
| 77 |
@return interface of demanded type (may be null) |
| 78 |
*/ |
| 79 |
inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType ); |
| 80 |
/** Queries given interface for type rType. |
| 81 |
Throws a RuntimeException if the demanded interface cannot be queried. |
| 82 |
|
| 83 |
@param pInterface interface pointer |
| 84 |
@param rType interface type |
| 85 |
@return interface of demanded type |
| 86 |
*/ |
| 87 |
inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType ); |
| 88 |
|
| 89 |
public: |
| 90 |
/** Gets interface pointer. This call does not acquire the interface. |
| 91 |
|
| 92 |
@return UNacquired interface pointer |
| 93 |
*/ |
| 94 |
XInterface * SAL_CALL get() const |
| 95 |
{ return _pInterface; } |
| 96 |
|
| 97 |
/** Checks if reference is null. |
| 98 |
|
| 99 |
@return true if reference acquires an interface, i.e. true if it is not null |
| 100 |
*/ |
| 101 |
bool SAL_CALL is() const |
| 102 |
{ return (NULL != _pInterface); } |
| 103 |
|
| 104 |
#if defined LIBO_INTERNAL_ONLY |
| 105 |
/** Checks if reference is null. |
| 106 |
|
| 107 |
@return true if reference acquires an interface, i.e. true if it is not null |
| 108 |
*/ |
| 109 |
explicit operator bool() const |
| 110 |
{ return is(); } |
| 111 |
#endif |
| 112 |
|
| 113 |
/** Equality operator: compares two interfaces |
| 114 |
Checks if both references are null or refer to the same object. |
| 115 |
|
| 116 |
@param pInterface another interface |
| 117 |
@return true if both references are null or refer to the same object, false otherwise |
| 118 |
*/ |
| 119 |
inline bool SAL_CALL operator == ( XInterface * pInterface ) const; |
| 120 |
/** Inequality operator: compares two interfaces |
| 121 |
Checks if both references are null or refer to the same object. |
| 122 |
|
| 123 |
@param pInterface another interface |
| 124 |
@return false if both references are null or refer to the same object, true otherwise |
| 125 |
*/ |
| 126 |
inline bool SAL_CALL operator != ( XInterface * pInterface ) const; |
| 127 |
|
| 128 |
/** Equality operator: compares two interfaces |
| 129 |
Checks if both references are null or refer to the same object. |
| 130 |
|
| 131 |
@param rRef another reference |
| 132 |
@return true if both references are null or refer to the same object, false otherwise |
| 133 |
*/ |
| 134 |
inline bool SAL_CALL operator == ( const BaseReference & rRef ) const; |
| 135 |
/** Inequality operator: compares two interfaces |
| 136 |
Checks if both references are null or refer to the same object. |
| 137 |
|
| 138 |
@param rRef another reference |
| 139 |
@return false if both references are null or refer to the same object, true otherwise |
| 140 |
*/ |
| 141 |
inline bool SAL_CALL operator != ( const BaseReference & rRef ) const; |
| 142 |
|
| 143 |
/** Needed by some STL containers. |
| 144 |
|
| 145 |
@param rRef another reference |
| 146 |
@return true, if this reference is less than rRef |
| 147 |
*/ |
| 148 |
inline bool SAL_CALL operator < ( const BaseReference & rRef ) const; |
| 149 |
}; |
| 150 |
|
| 151 |
/** Enum defining UNO_QUERY for implicit interface query. |
| 152 |
*/ |
| 153 |
enum UnoReference_Query |
| 154 |
{ |
| 155 |
/** This enum value can be used for implicit interface query. |
| 156 |
*/ |
| 157 |
UNO_QUERY |
| 158 |
}; |
| 159 |
/** Enum defining UNO_QUERY_THROW for implicit interface query. |
| 160 |
If the demanded interface is unavailable, then a RuntimeException is thrown. |
| 161 |
*/ |
| 162 |
enum UnoReference_QueryThrow |
| 163 |
{ |
| 164 |
/** This enum value can be used for implicit interface query. |
| 165 |
*/ |
| 166 |
UNO_QUERY_THROW |
| 167 |
}; |
| 168 |
/** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null |
| 169 |
interface |
| 170 |
|
| 171 |
@since UDK 3.2.8 |
| 172 |
*/ |
| 173 |
enum UnoReference_SetThrow |
| 174 |
{ |
| 175 |
UNO_SET_THROW |
| 176 |
}; |
| 177 |
|
| 178 |
/** Template reference class for interface type derived from BaseReference. |
| 179 |
A special constructor given the UNO_QUERY identifier queries interfaces |
| 180 |
for reference type. |
| 181 |
*/ |
| 182 |
template< class interface_type > |
| 183 |
class SAL_DLLPUBLIC_RTTI Reference : public BaseReference |
| 184 |
{ |
| 185 |
/** Queries given interface for type interface_type. |
| 186 |
|
| 187 |
@param pInterface interface pointer |
| 188 |
@return interface of demanded type (may be null) |
| 189 |
*/ |
| 190 |
inline static XInterface * SAL_CALL iquery( XInterface * pInterface ); |
| 191 |
/** Queries given interface for type interface_type. |
| 192 |
Throws a RuntimeException if the demanded interface cannot be queried. |
| 193 |
|
| 194 |
@param pInterface interface pointer |
| 195 |
@return interface of demanded type |
| 196 |
*/ |
| 197 |
inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface ); |
| 198 |
/** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise. |
| 199 |
|
| 200 |
@param pInterface interface pointer |
| 201 |
@return pInterface |
| 202 |
*/ |
| 203 |
inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface ); |
| 204 |
|
| 205 |
/** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a |
| 206 |
pointer to this interface_type. |
| 207 |
|
| 208 |
To work around ambiguities in the case of multiple-inheritance interface |
| 209 |
types (which inherit XInterface more than once), use reinterpret_cast |
| 210 |
(resp. a sequence of two static_casts, to avoid warnings about |
| 211 |
reinterpret_cast used between related classes) to switch from a pointer |
| 212 |
to XInterface to a pointer to this derived interface_type. In |
| 213 |
principle, this is not guaranteed to work. In practice, it seems to |
| 214 |
work on all supported platforms. |
| 215 |
*/ |
| 216 |
static interface_type * castFromXInterface(XInterface * p) { |
| 217 |
return static_cast< interface_type * >(static_cast< void * >(p)); |
| 218 |
} |
| 219 |
|
| 220 |
/** Cast from a pointer to this interface_type to an "interface pointer" |
| 221 |
(e.g., BaseReference::_pInterface). |
| 222 |
|
| 223 |
To work around ambiguities in the case of multiple-inheritance interface |
| 224 |
types (which inherit XInterface more than once), use reinterpret_cast |
| 225 |
(resp. a sequence of two static_casts, to avoid warnings about |
| 226 |
reinterpret_cast used between related classes) to switch from a pointer |
| 227 |
to this derived interface_type to a pointer to XInterface. In |
| 228 |
principle, this is not guaranteed to work. In practice, it seems to |
| 229 |
work on all supported platforms. |
| 230 |
*/ |
| 231 |
static XInterface * castToXInterface(interface_type * p) { |
| 232 |
return static_cast< XInterface * >(static_cast< void * >(p)); |
| 233 |
} |
| 234 |
|
| 235 |
public: |
| 236 |
/// @cond INTERNAL |
| 237 |
// these are here to force memory de/allocation to sal lib. |
| 238 |
static void * SAL_CALL operator new ( ::size_t nSize ) |
| 239 |
{ return ::rtl_allocateMemory( nSize ); } |
| 240 |
static void SAL_CALL operator delete ( void * pMem ) |
| 241 |
{ ::rtl_freeMemory( pMem ); } |
| 242 |
static void * SAL_CALL operator new ( ::size_t, void * pMem ) |
| 243 |
{ return pMem; } |
| 244 |
static void SAL_CALL operator delete ( void *, void * ) |
| 245 |
{} |
| 246 |
/// @endcond |
| 247 |
|
| 248 |
/** Destructor: Releases interface if set. |
| 249 |
*/ |
| 250 |
inline ~Reference() COVERITY_NOEXCEPT_FALSE; |
| 251 |
|
| 252 |
/** Default Constructor: Sets null reference. |
| 253 |
*/ |
| 254 |
inline Reference(); |
| 255 |
|
| 256 |
/** Copy constructor: Copies interface reference. |
| 257 |
|
| 258 |
@param rRef another reference |
| 259 |
*/ |
| 260 |
inline Reference( const Reference< interface_type > & rRef ); |
| 261 |
|
| 262 |
#if defined LIBO_INTERNAL_ONLY |
| 263 |
/** Move constructor |
| 264 |
|
| 265 |
@param rRef another reference |
| 266 |
*/ |
| 267 |
#if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions |
| 268 |
inline Reference( Reference< interface_type > && rRef ) noexcept; |
| 269 |
#endif |
| 270 |
|
| 271 |
/** Up-casting conversion constructor: Copies interface reference. |
| 272 |
|
| 273 |
Does not work for up-casts to ambiguous bases. For the special case of |
| 274 |
up-casting to Reference< XInterface >, see the corresponding conversion |
| 275 |
operator. |
| 276 |
|
| 277 |
@param rRef another reference |
| 278 |
*/ |
| 279 |
template< class derived_type > |
| 280 |
inline Reference( |
| 281 |
const Reference< derived_type > & rRef, |
| 282 |
std::enable_if_t< |
| 283 |
std::is_base_of_v<interface_type, derived_type> |
| 284 |
&& !std::is_same_v<interface_type, XInterface>, void *> = nullptr); |
| 285 |
#endif |
| 286 |
|
| 287 |
/** Constructor: Sets given interface pointer. |
| 288 |
|
| 289 |
@param pInterface an interface pointer |
| 290 |
*/ |
| 291 |
inline Reference( interface_type * pInterface ); |
| 292 |
|
| 293 |
/** Constructor: Sets given interface pointer without acquiring it. |
| 294 |
|
| 295 |
@param pInterface another reference |
| 296 |
@param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors |
| 297 |
*/ |
| 298 |
inline Reference( interface_type * pInterface, __sal_NoAcquire dummy); |
| 299 |
/** Constructor: Sets given interface pointer without acquiring it. |
| 300 |
Deprecated, please use SAL_NO_ACQUIRE version. |
| 301 |
|
| 302 |
@deprecated |
| 303 |
@param pInterface another reference |
| 304 |
@param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors |
| 305 |
*/ |
| 306 |
inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version") Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ); |
| 307 |
|
| 308 |
/** Constructor: Queries given interface for reference interface type (interface_type). |
| 309 |
|
| 310 |
@param rRef another reference |
| 311 |
@param dummy UNO_QUERY to force obvious distinction to other constructors |
| 312 |
*/ |
| 313 |
inline Reference( const BaseReference & rRef, UnoReference_Query dummy ); |
| 314 |
/** Constructor: Queries given interface for reference interface type (interface_type). |
| 315 |
|
| 316 |
@param pInterface an interface pointer |
| 317 |
@param dummy UNO_QUERY to force obvious distinction to other constructors |
| 318 |
*/ |
| 319 |
inline Reference( XInterface * pInterface, UnoReference_Query dummy); |
| 320 |
/** Constructor: Queries given any for reference interface type (interface_type). |
| 321 |
|
| 322 |
@param rAny an any |
| 323 |
@param dummy UNO_QUERY to force obvious distinction to other constructors |
| 324 |
*/ |
| 325 |
inline Reference( const Any & rAny, UnoReference_Query dummy); |
| 326 |
/** Constructor: Queries given interface for reference interface type (interface_type). |
| 327 |
Throws a RuntimeException if the demanded interface cannot be queried. |
| 328 |
|
| 329 |
@param rRef another reference |
| 330 |
@param dummy UNO_QUERY_THROW to force obvious distinction |
| 331 |
to other constructors |
| 332 |
*/ |
| 333 |
inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
| 334 |
#ifdef LIBO_INTERNAL_ONLY |
| 335 |
/** |
| 336 |
Prevent code from calling the QUERY_THROW constructor, when they meant to use the SET_THROW constructor. |
| 337 |
*/ |
| 338 |
Reference( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
| 339 |
#endif |
| 340 |
/** Constructor: Queries given interface for reference interface type (interface_type). |
| 341 |
Throws a RuntimeException if the demanded interface cannot be queried. |
| 342 |
|
| 343 |
@param pInterface an interface pointer |
| 344 |
@param dummy UNO_QUERY_THROW to force obvious distinction |
| 345 |
to other constructors |
| 346 |
*/ |
| 347 |
inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
| 348 |
/** Constructor: Queries given any for reference interface type (interface_type). |
| 349 |
Throws a RuntimeException if the demanded interface cannot be queried. |
| 350 |
|
| 351 |
@param rAny an any |
| 352 |
@param dummy UNO_QUERY_THROW to force obvious distinction |
| 353 |
to other constructors |
| 354 |
*/ |
| 355 |
inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ); |
| 356 |
/** Constructor: assigns from the given interface of the same type. Throws a RuntimeException |
| 357 |
if the source interface is NULL. |
| 358 |
|
| 359 |
@param rRef another interface reference of the same type |
| 360 |
@param dummy UNO_SET_THROW to distinguish from default copy constructor |
| 361 |
|
| 362 |
@since UDK 3.2.8 |
| 363 |
*/ |
| 364 |
inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ); |
| 365 |
/** Constructor: assigns from the given interface of the same type. Throws a RuntimeException |
| 366 |
if the source interface is NULL. |
| 367 |
|
| 368 |
@param pInterface an interface pointer |
| 369 |
@param dummy UNO_SET_THROW to distinguish from default assignment constructor |
| 370 |
|
| 371 |
@since UDK 3.2.8 |
| 372 |
*/ |
| 373 |
inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ); |
| 374 |
|
| 375 |
/** Cast operator to Reference< XInterface >: Reference objects are binary compatible and |
| 376 |
any interface must be derived from com.sun.star.uno.XInterface. |
| 377 |
This a useful direct cast possibility. |
| 378 |
*/ |
| 379 |
SAL_CALL operator const Reference< XInterface > & () const |
| 380 |
{ return * reinterpret_cast< const Reference< XInterface > * >( this ); } |
| 381 |
|
| 382 |
/** Dereference operator: Used to call interface methods. |
| 383 |
|
| 384 |
@return UNacquired interface pointer |
| 385 |
*/ |
| 386 |
interface_type * SAL_CALL operator -> () const { |
| 387 |
assert(_pInterface != NULL); |
| 388 |
return castFromXInterface(_pInterface); |
| 389 |
} |
| 390 |
|
| 391 |
/** Indirection operator. |
| 392 |
|
| 393 |
@since LibreOffice 6.3 |
| 394 |
@return UNacquired interface reference |
| 395 |
*/ |
| 396 |
interface_type & SAL_CALL operator * () const { |
| 397 |
assert(_pInterface != NULL); |
| 398 |
return *castFromXInterface(_pInterface); |
| 399 |
} |
| 400 |
|
| 401 |
/** Gets interface pointer. This call does not acquire the interface. |
| 402 |
|
| 403 |
@return UNacquired interface pointer |
| 404 |
*/ |
| 405 |
interface_type * SAL_CALL get() const |
| 406 |
{ return castFromXInterface(_pInterface); } |
| 407 |
|
| 408 |
/** Clears reference, i.e. releases interface. Reference is null after clear() call. |
| 409 |
*/ |
| 410 |
inline void SAL_CALL clear(); |
| 411 |
|
| 412 |
/** Sets the given interface. An interface already set will be released. |
| 413 |
|
| 414 |
@param rRef another reference |
| 415 |
@return true, if non-null interface was set |
| 416 |
*/ |
| 417 |
inline bool SAL_CALL set( const Reference< interface_type > & rRef ); |
| 418 |
/** Sets the given interface. An interface already set will be released. |
| 419 |
|
| 420 |
@param pInterface another interface |
| 421 |
@return true, if non-null interface was set |
| 422 |
*/ |
| 423 |
inline bool SAL_CALL set( interface_type * pInterface ); |
| 424 |
|
| 425 |
/** Sets interface pointer without acquiring it. An interface already set will be released. |
| 426 |
|
| 427 |
@param pInterface an interface pointer |
| 428 |
@param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods |
| 429 |
@return true, if non-null interface was set |
| 430 |
*/ |
| 431 |
inline bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy); |
| 432 |
/** Sets interface pointer without acquiring it. An interface already set will be released. |
| 433 |
Deprecated, please use SAL_NO_ACQUIRE version. |
| 434 |
|
| 435 |
@deprecated |
| 436 |
@param pInterface an interface pointer |
| 437 |
@param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods |
| 438 |
@return true, if non-null interface was set |
| 439 |
*/ |
| 440 |
inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version") bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy); |
| 441 |
|
| 442 |
/** Queries given interface for reference interface type (interface_type) and sets it. |
| 443 |
An interface already set will be released. |
| 444 |
|
| 445 |
@param pInterface an interface pointer |
| 446 |
@param dummy UNO_QUERY to force obvious distinction to set methods |
| 447 |
@return true, if non-null interface was set |
| 448 |
*/ |
| 449 |
inline bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ); |
| 450 |
/** Queries given interface for reference interface type (interface_type) and sets it. |
| 451 |
An interface already set will be released. |
| 452 |
|
| 453 |
@param rRef another reference |
| 454 |
@param dummy UNO_QUERY to force obvious distinction to set methods |
| 455 |
@return true, if non-null interface was set |
| 456 |
*/ |
| 457 |
inline bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy); |
| 458 |
|
| 459 |
/** Queries given any for reference interface type (interface_type) |
| 460 |
and sets it. An interface already set will be released. |
| 461 |
|
| 462 |
@param rAny |
| 463 |
an Any containing an interface |
| 464 |
@param dummy |
| 465 |
UNO_QUERY to force obvious distinction |
| 466 |
to set methods |
| 467 |
@return |
| 468 |
true, if non-null interface was set |
| 469 |
*/ |
| 470 |
inline bool set( Any const & rAny, UnoReference_Query dummy ); |
| 471 |
|
| 472 |
/** Queries given interface for reference interface type (interface_type) and sets it. |
| 473 |
An interface already set will be released. |
| 474 |
Throws a RuntimeException if the demanded interface cannot be set. |
| 475 |
|
| 476 |
@param pInterface an interface pointer |
| 477 |
@param dummy UNO_QUERY_THROW to force obvious distinction |
| 478 |
to set methods |
| 479 |
*/ |
| 480 |
inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
| 481 |
/** Queries given interface for reference interface type (interface_type) and sets it. |
| 482 |
An interface already set will be released. |
| 483 |
Throws a RuntimeException if the demanded interface cannot be set. |
| 484 |
|
| 485 |
@param rRef another reference |
| 486 |
@param dummy UNO_QUERY_THROW to force obvious distinction |
| 487 |
to set methods |
| 488 |
*/ |
| 489 |
inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
| 490 |
#ifdef LIBO_INTERNAL_ONLY |
| 491 |
/** |
| 492 |
Prevent code from calling the QUERY_THROW version, when they meant to use the SET_THROW version. |
| 493 |
*/ |
| 494 |
void set( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
| 495 |
#endif |
| 496 |
|
| 497 |
/** Queries given any for reference interface type (interface_type) and |
| 498 |
sets it. An interface already set will be released. |
| 499 |
Throws a RuntimeException if the demanded interface cannot be set. |
| 500 |
|
| 501 |
@param rAny |
| 502 |
an Any containing an interface |
| 503 |
@param dummy |
| 504 |
UNO_QUERY_THROW to force obvious distinction to set methods |
| 505 |
*/ |
| 506 |
inline void set( Any const & rAny, UnoReference_QueryThrow dummy); |
| 507 |
/** sets the given interface |
| 508 |
An interface already set will be released. |
| 509 |
Throws a RuntimeException if the source interface is @b NULL. |
| 510 |
|
| 511 |
@param pInterface an interface pointer |
| 512 |
@param dummy UNO_SET_THROW to force obvious distinction to other set methods |
| 513 |
|
| 514 |
@since UDK 3.2.8 |
| 515 |
*/ |
| 516 |
inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy); |
| 517 |
/** sets the given interface |
| 518 |
An interface already set will be released. |
| 519 |
Throws a RuntimeException if the source interface is @b NULL. |
| 520 |
|
| 521 |
@param rRef an interface reference |
| 522 |
@param dummy UNO_SET_THROW to force obvious distinction to other set methods |
| 523 |
|
| 524 |
@since UDK 3.2.8 |
| 525 |
*/ |
| 526 |
inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy); |
| 527 |
|
| 528 |
|
| 529 |
/** Assignment operator: Acquires given interface pointer and sets reference. |
| 530 |
An interface already set will be released. |
| 531 |
|
| 532 |
@param pInterface an interface pointer |
| 533 |
@return this reference |
| 534 |
*/ |
| 535 |
inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ); |
| 536 |
/** Assignment operator: Acquires given interface reference and sets reference. |
| 537 |
An interface already set will be released. |
| 538 |
|
| 539 |
@param rRef an interface reference |
| 540 |
@return this reference |
| 541 |
*/ |
| 542 |
inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ); |
| 543 |
#if defined LIBO_INTERNAL_ONLY |
| 544 |
/** Assignment move operator: Acquires given interface reference and sets reference. |
| 545 |
An interface already set will be released. |
| 546 |
|
| 547 |
@param rRef an interface reference |
| 548 |
@return this reference |
| 549 |
*/ |
| 550 |
inline Reference< interface_type > & operator = ( Reference< interface_type > && rRef ) noexcept; |
| 551 |
#endif |
| 552 |
/** Queries given interface reference for type interface_type. |
| 553 |
|
| 554 |
@param rRef interface reference |
| 555 |
@return interface reference of demanded type (may be null) |
| 556 |
*/ |
| 557 |
SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ); |
| 558 |
/** Queries given interface for type interface_type. |
| 559 |
|
| 560 |
@param pInterface interface pointer |
| 561 |
@return interface reference of demanded type (may be null) |
| 562 |
*/ |
| 563 |
SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ); |
| 564 |
#if defined LIBO_INTERNAL_ONLY |
| 565 |
/** Queries this for the required interface, and returns the requested reference, possibly empty. |
| 566 |
A syntactic sugar for 'Reference< other_type > xOther(xThis, UNO_QUERY)' that avoids some |
| 567 |
verbocity. |
| 568 |
|
| 569 |
@return new reference |
| 570 |
*/ |
| 571 |
template< class other_type > inline Reference< other_type > query() const; |
| 572 |
/** Queries this for the required interface, and returns the requested reference, or throws |
| 573 |
on failure. A syntactic sugar for 'Reference< other_type > xOther(xThis, UNO_QUERY_THROW)' |
| 574 |
that avoids some verbocity. |
| 575 |
|
| 576 |
@return new reference |
| 577 |
*/ |
| 578 |
template< class other_type > inline Reference< other_type > queryThrow() const; |
| 579 |
#endif |
| 580 |
}; |
| 581 |
|
| 582 |
} |
| 583 |
} |
| 584 |
} |
| 585 |
} |
| 586 |
|
| 587 |
#endif |
| 588 |
|
| 589 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |