19 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
20 #define _COM_SUN_STAR_UNO_REFERENCE_HXX_
23 #include <com/sun/star/uno/RuntimeException.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
38 XInterface * pInterface,
const Type & rType )
43 Any aRet( pInterface->queryInterface( rType ) );
46 XInterface * pRet =
static_cast< XInterface *
>( aRet.pReserved );
54 template<
class interface_type >
56 XInterface * pInterface )
SAL_THROW( (RuntimeException) )
60 #ifndef EXCEPTIONS_OFF
69 XInterface * pInterface,
const Type & rType )
72 XInterface * pQueried = iquery( pInterface, rType );
75 throw RuntimeException(
80 template<
class interface_type >
82 XInterface * pInterface )
SAL_THROW( (RuntimeException) )
85 pInterface, interface_type::static_type());
88 template<
class interface_type >
89 inline interface_type * Reference< interface_type >::iset_throw(
90 interface_type * pInterface )
SAL_THROW( (RuntimeException) )
94 castToXInterface(pInterface)->acquire();
97 throw RuntimeException(
104 template<
class interface_type >
108 _pInterface->release();
111 template<
class interface_type >
117 template<
class interface_type >
120 _pInterface = rRef._pInterface;
122 _pInterface->acquire();
125 template<
class interface_type >
template<
class derived_type >
128 typename detail::UpCast< interface_type, derived_type >::t )
131 interface_type * p = rRef.
get();
134 _pInterface->acquire();
137 template<
class interface_type >
140 _pInterface = castToXInterface(pInterface);
142 _pInterface->acquire();
145 template<
class interface_type >
148 _pInterface = castToXInterface(pInterface);
151 template<
class interface_type >
154 _pInterface = castToXInterface(pInterface);
157 template<
class interface_type >
160 _pInterface = iquery( rRef.
get() );
163 template<
class interface_type >
166 _pInterface = iquery( pInterface );
169 template<
class interface_type >
173 ? iquery( static_cast< XInterface * >( rAny.
pReserved ) ) : 0);
175 #ifndef EXCEPTIONS_OFF
177 template<
class interface_type >
180 _pInterface = iquery_throw( rRef.
get() );
183 template<
class interface_type >
186 _pInterface = iquery_throw( pInterface );
189 template<
class interface_type >
193 ? static_cast< XInterface * >( rAny.
pReserved ) : 0 );
196 template<
class interface_type >
199 _pInterface = castToXInterface( iset_throw( rRef.
get() ) );
202 template<
class interface_type >
205 _pInterface = castToXInterface( iset_throw( pInterface ) );
210 template<
class interface_type >
215 XInterface *
const pOld = _pInterface;
221 template<
class interface_type >
223 interface_type * pInterface )
SAL_THROW(())
226 castToXInterface(pInterface)->acquire();
227 XInterface *
const pOld = _pInterface;
228 _pInterface = castToXInterface(pInterface);
231 return (0 != pInterface);
234 template<
class interface_type >
238 XInterface *
const pOld = _pInterface;
239 _pInterface = castToXInterface(pInterface);
242 return (0 != pInterface);
245 template<
class interface_type >
253 template<
class interface_type >
257 return set( castFromXInterface( rRef._pInterface ) );
260 template<
class interface_type >
264 return set( castFromXInterface(iquery( pInterface )),
SAL_NO_ACQUIRE );
267 template<
class interface_type >
275 template<
class interface_type >
283 ? static_cast< XInterface * >( rAny.
pReserved ) : 0 )),
287 #ifndef EXCEPTIONS_OFF
289 template<
class interface_type >
293 set( castFromXInterface(iquery_throw( pInterface )),
SAL_NO_ACQUIRE );
296 template<
class interface_type >
304 template<
class interface_type >
308 set( castFromXInterface(
311 ? static_cast< XInterface * >( rAny.
pReserved ) : 0 )),
315 template<
class interface_type >
322 template<
class interface_type >
332 template<
class interface_type >
334 interface_type * pInterface )
SAL_THROW(())
340 template<
class interface_type >
344 set( castFromXInterface( rRef._pInterface ) );
349 template<
class interface_type >
357 template<
class interface_type >
359 XInterface * pInterface )
SAL_THROW( (RuntimeException) )
370 if (_pInterface == pInterface)
372 #ifndef EXCEPTIONS_OFF
380 #ifndef EXCEPTIONS_OFF
382 catch (RuntimeException &)
393 if (_pInterface == rRef._pInterface)
395 #if ! defined EXCEPTIONS_OFF
403 #if ! defined EXCEPTIONS_OFF
405 catch (RuntimeException &)
415 return (!
operator == ( pInterface ));
425 return (!
operator == ( rRef._pInterface ));
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:54
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:112
interface_type * get() const
Gets interface pointer.
Definition: Reference.h:419
This enum value can be used for implicit interface query.
Definition: Reference.h:140
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:43
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
~Reference()
Destructor: Releases interface if set.
Definition: Reference.hxx:105
definition of a no acquire enum for ctors
Definition: types.h:374
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:37
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:68
sal_Bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:547
XInterface * _pInterface
the interface pointer
Definition: Reference.h:59
sal_Bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:254
rtl_uString * cppu_unsatisfied_iset_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
static Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:350
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:136
type class of interface
Definition: typeclass.h:73
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:157
void * pReserved
reserved space for storing value
Definition: any2.h:52
unsigned char sal_Bool
Definition: types.h:37
#define sal_False
Definition: types.h:38
struct _typelib_TypeDescriptionReference * pType
type of value
Definition: any2.h:44
__sal_NoAcquire
Definition: types.h:370
void clear()
Clears reference, i.e.
Definition: Reference.hxx:211
sal_Bool operator!=(XInterface *pInterface) const
Unequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:413
sal_Bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:390
sal_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:368
typelib_TypeClass eTypeClass
type class of type
Definition: typedescription.h:52
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:87
rtl_uString * cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
CPPU_DLLPUBLIC void SAL_THROW_EXTERN_C()
This method is called to wait for a reply of a previously sent request.
XInterface * get() const
Gets interface pointer.
Definition: Reference.h:86
C++ class representing an IDL any.
Definition: Any.h:46
Holds a weak reference to a type description.
Definition: typedescription.h:40
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:333
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:356
C++ class representing an IDL meta type.
Definition: Type.h:55
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:146
#define sal_True
Definition: types.h:39
Definition: Reference.h:159