3 #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX
4 #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_HXX
12 #include "com/sun/star/uno/RuntimeException.hpp"
13 #include "com/sun/star/uno/XInterface.hpp"
35 XInterface * pInterface,
const Type & rType )
39 Any aRet( pInterface->queryInterface( rType ) );
42 XInterface * pRet =
static_cast< XInterface *
>( aRet.pReserved );
43 aRet.pReserved = NULL;
50 template<
class interface_type >
52 XInterface * pInterface )
58 XInterface * pInterface,
const Type & rType )
60 XInterface * pQueried =
iquery( pInterface, rType );
63 throw RuntimeException(
68 template<
class interface_type >
70 XInterface * pInterface )
73 pInterface, interface_type::static_type());
76 template<
class interface_type >
77 inline interface_type * Reference< interface_type >::iset_throw(
78 interface_type * pInterface )
82 castToXInterface(pInterface)->acquire();
85 throw RuntimeException(
90 template<
class interface_type >
94 _pInterface->release();
97 template<
class interface_type >
103 template<
class interface_type >
108 _pInterface->acquire();
111 #if defined LIBO_INTERNAL_ONLY
112 template<
class interface_type >
115 _pInterface = rRef._pInterface;
116 rRef._pInterface =
nullptr;
119 template<
class interface_type >
template<
class derived_type >
121 const Reference< derived_type > & rRef,
123 std::is_base_of_v<interface_type, derived_type>
124 && !std::is_same_v<interface_type, XInterface>,
void *>)
126 interface_type * p = rRef.get();
127 _pInterface = castToXInterface(p);
129 _pInterface->acquire();
133 template<
class interface_type >
136 _pInterface = castToXInterface(pInterface);
138 _pInterface->acquire();
141 template<
class interface_type >
144 _pInterface = castToXInterface(pInterface);
147 template<
class interface_type >
150 _pInterface = castToXInterface(pInterface);
153 template<
class interface_type >
156 _pInterface = iquery( rRef.
get() );
159 template<
class interface_type >
162 _pInterface = iquery( pInterface );
165 template<
class interface_type >
169 ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : NULL);
172 template<
class interface_type >
175 _pInterface = iquery_throw( rRef.
get() );
178 template<
class interface_type >
181 _pInterface = iquery_throw( pInterface );
184 template<
class interface_type >
188 ? static_cast< XInterface * >( rAny.pReserved ) : NULL );
191 template<
class interface_type >
194 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
197 template<
class interface_type >
200 _pInterface = castToXInterface( iset_throw( pInterface ) );
204 template<
class interface_type >
209 XInterface *
const pOld = _pInterface;
215 template<
class interface_type >
217 interface_type * pInterface )
220 castToXInterface(pInterface)->acquire();
221 XInterface *
const pOld = _pInterface;
222 _pInterface = castToXInterface(pInterface);
225 return (NULL != pInterface);
228 template<
class interface_type >
232 XInterface *
const pOld = _pInterface;
233 _pInterface = castToXInterface(pInterface);
236 return (NULL != pInterface);
239 template<
class interface_type >
247 template<
class interface_type >
251 return set( castFromXInterface( rRef.
_pInterface ) );
254 template<
class interface_type >
258 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
261 template<
class interface_type >
269 template<
class interface_type >
277 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
282 template<
class interface_type >
286 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
289 template<
class interface_type >
297 template<
class interface_type >
301 set( castFromXInterface(
304 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
308 template<
class interface_type >
315 template<
class interface_type >
323 template<
class interface_type >
325 interface_type * pInterface )
331 template<
class interface_type >
339 #if defined LIBO_INTERNAL_ONLY
340 template<
class interface_type >
345 _pInterface->release();
346 _pInterface = rRef._pInterface;
347 rRef._pInterface =
nullptr;
352 template<
class interface_type >
360 template<
class interface_type >
362 XInterface * pInterface )
380 catch (RuntimeException &)
399 catch (RuntimeException &)
408 return (!
operator == ( pInterface ));
421 #if defined LIBO_INTERNAL_ONLY
428 template<
typename charT,
typename traits> std::basic_ostream<charT, traits> &
430 std::basic_ostream<charT, traits> & stream,
BaseReference const & ref)
431 {
return stream << ref.
get(); }
439 #if defined LIBO_INTERNAL_ONLY
449 struct hash<::css::uno::Reference<T>>
451 std::size_t operator()(::css::uno::Reference<T>
const & s)
const
452 {
return size_t(s.get()); }
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iset_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
__sal_NoAcquire
Definition: types.h:332
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:324
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:353
C++ class representing an IDL any.
Definition: Any.h:36
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:142
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:142
#define COVERITY_NOEXCEPT_FALSE
To markup destructors that coverity warns might throw exceptions which won't throw in practice...
Definition: types.h:329
This enum value can be used for implicit interface query.
Definition: Reference.h:137
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:133
CPPU_DLLPUBLIC void SAL_THROW_EXTERN_C()
This method is called to wait for a reply of a previously sent request.
type class of interface
Definition: typeclass.h:62
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:74
~Reference() COVERITY_NOEXCEPT_FALSE
Destructor: Releases interface if set.
Definition: Reference.hxx:91
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:98
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:684
C++ class representing an IDL meta type.
Definition: Type.h:38
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:383
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:369
bool operator!=(XInterface *pInterface) const
Inequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:406
definition of a no acquire enum for ctors
Definition: types.h:336
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:248
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:23
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:153
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:35
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:46
void clear()
Clears reference, i.e.
Definition: Reference.hxx:205
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:34
Definition: Reference.h:155
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:387
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:57
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:11
XInterface * _pInterface
the interface pointer
Definition: Reference.h:51