19 #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX
20 #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX
28 #include "com/sun/star/uno/RuntimeException.hpp"
29 #include "com/sun/star/uno/XInterface.hpp"
51 XInterface * pInterface,
const Type & rType )
55 Any aRet( pInterface->queryInterface( rType ) );
58 XInterface * pRet =
static_cast< XInterface *
>( aRet.pReserved );
59 aRet.pReserved = NULL;
66 template<
class interface_type >
68 XInterface * pInterface )
74 XInterface * pInterface,
const Type & rType )
76 XInterface * pQueried =
iquery( pInterface, rType );
79 throw RuntimeException(
84 template<
class interface_type >
86 XInterface * pInterface )
89 pInterface, interface_type::static_type());
92 template<
class interface_type >
93 inline interface_type * Reference< interface_type >::iset_throw(
94 interface_type * pInterface )
98 castToXInterface(pInterface)->acquire();
101 throw RuntimeException(
106 template<
class interface_type >
110 _pInterface->release();
113 template<
class interface_type >
119 template<
class interface_type >
124 _pInterface->acquire();
127 #if defined LIBO_INTERNAL_ONLY
128 template<
class interface_type >
131 _pInterface = rRef._pInterface;
132 rRef._pInterface =
nullptr;
135 template<
class interface_type >
template<
class derived_type >
137 const Reference< derived_type > & rRef,
139 std::is_base_of_v<interface_type, derived_type>
140 && !std::is_same_v<interface_type, XInterface>,
void *>)
142 interface_type * p = rRef.get();
145 _pInterface->acquire();
149 template<
class interface_type >
152 _pInterface = castToXInterface(pInterface);
154 _pInterface->acquire();
157 template<
class interface_type >
160 _pInterface = castToXInterface(pInterface);
163 template<
class interface_type >
166 _pInterface = castToXInterface(pInterface);
169 template<
class interface_type >
172 _pInterface = iquery( rRef.
get() );
175 template<
class interface_type >
178 _pInterface = iquery( pInterface );
181 template<
class interface_type >
185 ? iquery(
static_cast< XInterface *
>( rAny.pReserved ) ) : NULL);
188 template<
class interface_type >
191 _pInterface = iquery_throw( rRef.
get() );
194 template<
class interface_type >
197 _pInterface = iquery_throw( pInterface );
200 template<
class interface_type >
204 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL );
207 template<
class interface_type >
210 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
213 template<
class interface_type >
216 _pInterface = castToXInterface( iset_throw( pInterface ) );
220 template<
class interface_type >
225 XInterface *
const pOld = _pInterface;
231 template<
class interface_type >
233 interface_type * pInterface )
236 castToXInterface(pInterface)->acquire();
237 XInterface *
const pOld = _pInterface;
238 _pInterface = castToXInterface(pInterface);
241 return (NULL != pInterface);
244 template<
class interface_type >
248 XInterface *
const pOld = _pInterface;
249 _pInterface = castToXInterface(pInterface);
252 return (NULL != pInterface);
255 template<
class interface_type >
263 template<
class interface_type >
267 return set( castFromXInterface( rRef.
_pInterface ) );
270 template<
class interface_type >
274 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
277 template<
class interface_type >
285 template<
class interface_type >
293 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL )),
298 template<
class interface_type >
302 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
305 template<
class interface_type >
313 template<
class interface_type >
317 set( castFromXInterface(
320 ?
static_cast< XInterface *
>( rAny.pReserved ) : NULL )),
324 template<
class interface_type >
331 template<
class interface_type >
339 template<
class interface_type >
341 interface_type * pInterface )
347 template<
class interface_type >
355 #if defined LIBO_INTERNAL_ONLY
356 template<
class interface_type >
361 _pInterface->release();
362 _pInterface = rRef._pInterface;
363 rRef._pInterface =
nullptr;
368 template<
class interface_type >
376 template<
class interface_type >
378 XInterface * pInterface )
396 catch (RuntimeException &)
413 return (x1._pInterface < x2._pInterface);
415 catch (RuntimeException &)
424 return (!
operator == ( pInterface ));
437 #if defined LIBO_INTERNAL_ONLY
444 template<
typename charT,
typename traits> std::basic_ostream<charT, traits> &
446 std::basic_ostream<charT, traits> & stream,
BaseReference const & ref)
447 {
return stream << ref.
get(); }
455 #if defined LIBO_INTERNAL_ONLY
465 struct hash<::css::uno::Reference<T>>
467 std::size_t operator()(::css::uno::Reference<T>
const & s)
const
468 {
return size_t(s.get()); }
__sal_NoAcquire
Definition: types.h:349
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:352
#define COVERITY_NOEXCEPT_FALSE
To markup destructors that coverity warns might throw exceptions which won't throw in practice,...
Definition: types.h:333
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:324
@ typelib_TypeClass_INTERFACE
type class of interface
Definition: typeclass.h:78
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:10
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:52
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:159
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:695
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:150
@ UNO_QUERY
This enum value can be used for implicit interface query.
Definition: Reference.h:153
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:170
@ UNO_SET_THROW
Definition: Reference.h:171
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:161
Template reference class for interface type derived from BaseReference.
Definition: Reference.h:180
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:369
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:340
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:399
void clear()
Clears reference, i.e.
Definition: Reference.hxx:221
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:264
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:114
~Reference() COVERITY_NOEXCEPT_FALSE
Destructor: Releases interface if set.
Definition: Reference.hxx:107
C++ class representing an IDL any.
Definition: Any.h:53
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:63
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:403
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:50
bool operator!=(XInterface *pInterface) const
Inequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:422
XInterface * _pInterface
the interface pointer
Definition: Reference.h:67
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:73
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:90
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:385
C++ class representing an IDL meta type.
Definition: Type.h:55
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154