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;
136 template<
class interface_type >
template<
class derived_type >
139 typename detail::UpCast< interface_type, derived_type >::t )
141 interface_type * p = rRef.
get();
144 _pInterface->acquire();
147 template<
class interface_type >
150 _pInterface = castToXInterface(pInterface);
152 _pInterface->acquire();
155 template<
class interface_type >
158 _pInterface = castToXInterface(pInterface);
161 template<
class interface_type >
164 _pInterface = castToXInterface(pInterface);
167 template<
class interface_type >
170 _pInterface = iquery( rRef.
get() );
173 template<
class interface_type >
176 _pInterface = iquery( pInterface );
179 template<
class interface_type >
183 ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : NULL);
186 template<
class interface_type >
189 _pInterface = iquery_throw( rRef.
get() );
192 template<
class interface_type >
195 _pInterface = iquery_throw( pInterface );
198 template<
class interface_type >
202 ? static_cast< XInterface * >( rAny.pReserved ) : NULL );
205 template<
class interface_type >
208 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
211 template<
class interface_type >
214 _pInterface = castToXInterface( iset_throw( pInterface ) );
218 template<
class interface_type >
223 XInterface *
const pOld = _pInterface;
229 template<
class interface_type >
231 interface_type * pInterface )
234 castToXInterface(pInterface)->acquire();
235 XInterface *
const pOld = _pInterface;
236 _pInterface = castToXInterface(pInterface);
239 return (NULL != pInterface);
242 template<
class interface_type >
246 XInterface *
const pOld = _pInterface;
247 _pInterface = castToXInterface(pInterface);
250 return (NULL != pInterface);
253 template<
class interface_type >
261 template<
class interface_type >
265 return set( castFromXInterface( rRef.
_pInterface ) );
268 template<
class interface_type >
272 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
275 template<
class interface_type >
283 template<
class interface_type >
291 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
296 template<
class interface_type >
300 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
303 template<
class interface_type >
311 template<
class interface_type >
315 set( castFromXInterface(
318 ? static_cast< XInterface * >( rAny.pReserved ) : NULL )),
322 template<
class interface_type >
329 template<
class interface_type >
337 template<
class interface_type >
339 interface_type * pInterface )
345 template<
class interface_type >
353 #if defined LIBO_INTERNAL_ONLY 354 template<
class interface_type >
359 _pInterface->release();
360 _pInterface = rRef._pInterface;
361 rRef._pInterface =
nullptr;
366 template<
class interface_type >
374 template<
class interface_type >
376 XInterface * pInterface )
394 catch (RuntimeException &)
413 catch (RuntimeException &)
422 return (!
operator == ( pInterface ));
435 #if defined LIBO_INTERNAL_ONLY 442 template<
typename charT,
typename traits> std::basic_ostream<charT, traits> &
444 std::basic_ostream<charT, traits> & stream,
BaseReference const & ref)
445 {
return stream << ref.
get(); }
453 #if defined LIBO_INTERNAL_ONLY 463 struct hash<::css::uno::Reference<T>>
465 std::size_t operator()(::css::uno::Reference<T>
const & s)
const 466 {
return size_t(s.get()); }
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:346
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:47
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
bool operator!=(XInterface *pInterface) const
Inequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:420
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:355
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:444
This enum value can be used for implicit interface query.
Definition: Reference.h:149
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:73
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:401
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
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:383
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:10
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:145
Definition: Reference.h:167
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:338
C++ class representing an IDL any.
Definition: Any.h:52
__sal_NoAcquire
Definition: types.h:370
CPPU_DLLPUBLIC rtl_uString * cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:39
type class of interface
Definition: typeclass.h:79
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:154
void clear()
Clears reference, i.e.
Definition: Reference.hxx:219
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:126
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:86
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:367
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:58
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:165
XInterface * _pInterface
the interface pointer
Definition: Reference.h:63
~Reference() COVERITY_NOEXCEPT_FALSE
Destructor: Releases interface if set.
Definition: Reference.hxx:107
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:262
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:50
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:114
C++ class representing an IDL meta type.
Definition: Type.h:54