23 #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX 24 #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX 32 #include "com/sun/star/uno/RuntimeException.hpp" 33 #include "com/sun/star/uno/XInterface.hpp" 55 XInterface * pInterface,
const Type & rType )
59 Any aRet( pInterface->queryInterface( rType ) );
62 XInterface * pRet =
static_cast< XInterface *
>( aRet.pReserved );
63 aRet.pReserved = NULL;
70 template<
class interface_type >
72 XInterface * pInterface )
78 XInterface * pInterface,
const Type & rType )
80 XInterface * pQueried =
iquery( pInterface, rType );
83 throw RuntimeException(
88 template<
class interface_type >
90 XInterface * pInterface )
93 pInterface, interface_type::static_type());
96 template<
class interface_type >
97 inline interface_type * Reference< interface_type >::iset_throw(
98 interface_type * pInterface )
102 castToXInterface(pInterface)->acquire();
105 throw RuntimeException(
110 template<
class interface_type >
114 _pInterface->release();
117 template<
class interface_type >
123 template<
class interface_type >
128 _pInterface->acquire();
131 #if defined LIBO_INTERNAL_ONLY 133 #if !defined(__COVERITY__) 134 template<
class interface_type >
137 _pInterface = rRef._pInterface;
138 rRef._pInterface =
nullptr;
142 template<
class interface_type >
template<
class derived_type >
144 const Reference< derived_type > & rRef,
146 std::is_base_of_v<interface_type, derived_type>
147 && !std::is_same_v<interface_type, XInterface>,
void *>)
149 interface_type * p = rRef.get();
150 _pInterface = castToXInterface(p);
152 _pInterface->acquire();
156 template<
class interface_type >
159 _pInterface = castToXInterface(pInterface);
161 _pInterface->acquire();
164 template<
class interface_type >
167 _pInterface = castToXInterface(pInterface);
170 template<
class interface_type >
173 _pInterface = castToXInterface(pInterface);
176 template<
class interface_type >
179 _pInterface = iquery( rRef.
get() );
182 template<
class interface_type >
185 _pInterface = iquery( pInterface );
188 template<
class interface_type >
192 ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : NULL);
195 template<
class interface_type >
198 _pInterface = iquery_throw( rRef.
get() );
201 template<
class interface_type >
204 _pInterface = iquery_throw( pInterface );
207 template<
class interface_type >
211 ? static_cast< XInterface * >( rAny.pReserved ) : NULL );
214 template<
class interface_type >
217 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
220 template<
class interface_type >
223 _pInterface = castToXInterface( iset_throw( pInterface ) );
227 template<
class interface_type >
232 XInterface *
const pOld = _pInterface;
238 template<
class interface_type >
240 interface_type * pInterface )
243 castToXInterface(pInterface)->acquire();
244 XInterface *
const pOld = _pInterface;
245 _pInterface = castToXInterface(pInterface);
248 return (NULL != pInterface);
251 template<
class interface_type >
255 XInterface *
const pOld = _pInterface;
256 _pInterface = castToXInterface(pInterface);
259 return (NULL != pInterface);
262 template<
class interface_type >
270 template<
class interface_type >
274 return set( castFromXInterface( rRef.
_pInterface ) );
277 template<
class interface_type >
281 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
284 template<
class interface_type >
292 template<
class interface_type >
300 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
305 template<
class interface_type >
309 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
312 template<
class interface_type >
320 template<
class interface_type >
324 set( castFromXInterface(
327 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
331 template<
class interface_type >
338 template<
class interface_type >
346 template<
class interface_type >
348 interface_type * pInterface )
354 template<
class interface_type >
362 #if defined LIBO_INTERNAL_ONLY 363 template<
class interface_type >
368 _pInterface->release();
369 _pInterface = rRef._pInterface;
370 rRef._pInterface =
nullptr;
375 template<
class interface_type >
383 template<
class interface_type >
385 XInterface * pInterface )
391 #if defined LIBO_INTERNAL_ONLY 392 template<
class interface_type >
template<
class other_type >
398 template<
class interface_type >
template<
class other_type >
399 inline Reference< other_type > Reference< interface_type >::queryThrow()
const 404 template<
class interface_type >
405 inline Reference< interface_type > Any::query()
const 407 return Reference< interface_type >(*
this,
UNO_QUERY);
410 template<
class interface_type >
411 inline Reference< interface_type > Any::queryThrow()
const 429 catch (RuntimeException &)
448 catch (RuntimeException &)
457 return (!
operator == ( pInterface ));
470 #if defined LIBO_INTERNAL_ONLY 477 template<
typename charT,
typename traits> std::basic_ostream<charT, traits> &
479 std::basic_ostream<charT, traits> & stream,
BaseReference const & ref)
480 {
return stream << ref.
get(); }
488 #if defined LIBO_INTERNAL_ONLY 498 struct hash<::css::uno::Reference<T>>
500 std::size_t operator()(::css::uno::Reference<T>
const & s)
const 501 {
return size_t(s.get()); }
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:352
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:55
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:271
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:376
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iset_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
#define COVERITY_NOEXCEPT_FALSE
To markup destructors that coverity warns might throw exceptions which won't throw in practice...
Definition: types.h:367
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:77
~Reference() COVERITY_NOEXCEPT_FALSE
Destructor: Releases interface if set.
Definition: Reference.hxx:111
bool operator!=(XInterface *pInterface) const
Inequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:455
This enum value can be used for implicit interface query.
Definition: Reference.h:157
This enum value can be used for implicit interface query.
Definition: Reference.h:166
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:436
bool operator==(XInterface *pInterface) const
Equality operator: compares two interfaces Checks if both references are null or refer to the same ob...
Definition: Reference.hxx:418
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, Any const &any)
Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example)...
Definition: Any.hxx:708
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:347
C++ class representing an IDL any.
Definition: Any.h:57
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:13
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:153
Definition: Reference.h:175
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:43
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:405
__sal_NoAcquire
Definition: types.h:370
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
void clear()
Clears reference, i.e.
Definition: Reference.hxx:228
type class of interface
Definition: typeclass.h:82
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:171
definition of a no acquire enum for ctors
Definition: types.h:374
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:162
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:66
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:54
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:173
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:118
C++ class representing an IDL meta type.
Definition: Type.h:58
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:94
XInterface * _pInterface
the interface pointer
Definition: Reference.h:71