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
132 template<
class interface_type >
135 _pInterface = rRef._pInterface;
136 rRef._pInterface =
nullptr;
139 template<
class interface_type >
template<
class derived_type >
141 const Reference< derived_type > & rRef,
143 std::is_base_of_v<interface_type, derived_type>
144 && !std::is_same_v<interface_type, XInterface>,
void *>)
146 interface_type * p = rRef.get();
147 _pInterface = castToXInterface(p);
149 _pInterface->acquire();
153 template<
class interface_type >
156 _pInterface = castToXInterface(pInterface);
158 _pInterface->acquire();
161 template<
class interface_type >
164 _pInterface = castToXInterface(pInterface);
167 template<
class interface_type >
170 _pInterface = castToXInterface(pInterface);
173 template<
class interface_type >
176 _pInterface = iquery( rRef.
get() );
179 template<
class interface_type >
182 _pInterface = iquery( pInterface );
185 template<
class interface_type >
189 ? iquery(
static_cast< XInterface *
>( rAny.pReserved ) ) : NULL);
192 template<
class interface_type >
195 _pInterface = iquery_throw( rRef.
get() );
198 template<
class interface_type >
201 _pInterface = iquery_throw( pInterface );
204 template<
class interface_type >
208 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL );
211 template<
class interface_type >
214 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
217 template<
class interface_type >
220 _pInterface = castToXInterface( iset_throw( pInterface ) );
224 template<
class interface_type >
229 XInterface *
const pOld = _pInterface;
235 template<
class interface_type >
237 interface_type * pInterface )
240 castToXInterface(pInterface)->acquire();
241 XInterface *
const pOld = _pInterface;
242 _pInterface = castToXInterface(pInterface);
245 return (NULL != pInterface);
248 template<
class interface_type >
252 XInterface *
const pOld = _pInterface;
253 _pInterface = castToXInterface(pInterface);
256 return (NULL != pInterface);
259 template<
class interface_type >
267 template<
class interface_type >
271 return set( castFromXInterface( rRef.
_pInterface ) );
274 template<
class interface_type >
278 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
281 template<
class interface_type >
289 template<
class interface_type >
297 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL )),
302 template<
class interface_type >
306 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
309 template<
class interface_type >
317 template<
class interface_type >
321 set( castFromXInterface(
324 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL )),
328 template<
class interface_type >
335 template<
class interface_type >
343 template<
class interface_type >
345 interface_type * pInterface )
351 template<
class interface_type >
359 #if defined LIBO_INTERNAL_ONLY
360 template<
class interface_type >
365 _pInterface->release();
366 _pInterface = rRef._pInterface;
367 rRef._pInterface =
nullptr;
372 template<
class interface_type >
380 template<
class interface_type >
382 XInterface * pInterface )
400 catch (RuntimeException &)
417 return (x1._pInterface < x2._pInterface);
419 catch (RuntimeException &)
428 return (!
operator == ( pInterface ));
441 #if defined LIBO_INTERNAL_ONLY
448 template<
typename charT,
typename traits> std::basic_ostream<charT, traits> &
450 std::basic_ostream<charT, traits> & stream,
BaseReference const & ref)
451 {
return stream << ref.
get(); }
459 #if defined LIBO_INTERNAL_ONLY
469 struct hash<::css::uno::Reference<T>>
471 std::size_t operator()(::css::uno::Reference<T>
const & s)
const
472 {
return size_t(s.get()); }
__sal_NoAcquire
Definition: types.h:353
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:356
#define COVERITY_NOEXCEPT_FALSE
To markup destructors that coverity warns might throw exceptions which won't throw in practice,...
Definition: types.h:349
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:334
@ typelib_TypeClass_INTERFACE
type class of interface
Definition: typeclass.h:82
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:13
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iset_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:56
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:163
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:696
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:154
@ UNO_QUERY
This enum value can be used for implicit interface query.
Definition: Reference.h:157
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:174
@ UNO_SET_THROW
Definition: Reference.h:175
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
Template reference class for interface type derived from BaseReference.
Definition: Reference.h:184
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:373
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:344
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:403
void clear()
Clears reference, i.e.
Definition: Reference.hxx:225
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:268
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:118
~Reference() COVERITY_NOEXCEPT_FALSE
Destructor: Releases interface if set.
Definition: Reference.hxx:111
C++ class representing an IDL any.
Definition: Any.h:57
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:67
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:407
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:54
bool operator!=(XInterface *pInterface) const
Inequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:426
XInterface * _pInterface
the interface pointer
Definition: Reference.h:71
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:77
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:94
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:389
C++ class representing an IDL meta type.
Definition: Type.h:59
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162