19 #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
20 #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
37 class RuntimeException;
70 inline static XInterface * SAL_CALL
iquery( XInterface * pInterface,
const Type & rType );
78 inline static XInterface * SAL_CALL
iquery_throw( XInterface * pInterface,
const Type & rType );
85 inline XInterface * SAL_CALL
get()
const
92 inline bool SAL_CALL
is()
const
101 inline bool SAL_CALL
operator == ( XInterface * pInterface )
const;
108 inline bool SAL_CALL
operator != ( XInterface * pInterface )
const;
174 template<
typename T1,
typename T2 >
struct UpCast {
176 template<
bool,
typename U1,
typename >
struct C
179 template<
typename U1,
typename U2 >
struct C< false, U1, U2 >
182 struct S {
char c[2]; };
185 static char f(T2 *,
long);
186 static S f(T1 *
const &,
int);
188 template<
typename U >
static char f(T2 *, U);
189 static S f(T1 *,
int);
195 operator T1 *
const & ()
const;
197 operator T1 * ()
const;
203 typedef typename C< sizeof (f(H(), 0)) == 1, void *, void >::t t;
206 template<
typename T2 >
struct UpCast< XInterface, T2 > {};
215 template<
class interface_type >
216 class Reference :
public BaseReference
223 inline static XInterface * SAL_CALL iquery( XInterface * pInterface );
230 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface );
236 inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface );
249 static inline interface_type * castFromXInterface(XInterface * p) {
250 return static_cast< interface_type *
>(
static_cast< void *
>(p));
264 static inline XInterface * castToXInterface(interface_type * p) {
265 return static_cast< XInterface *
>(
static_cast< void *
>(p));
271 inline static void * SAL_CALL
operator new ( ::size_t nSize )
273 inline static void SAL_CALL
operator delete (
void * pMem )
275 inline static void * SAL_CALL
operator new ( ::size_t,
void * pMem )
277 inline static void SAL_CALL
operator delete (
void *,
void * )
293 inline Reference(
const Reference< interface_type > & rRef );
303 template<
class derived_type >
305 const Reference< derived_type > & rRef,
306 typename detail::UpCast< interface_type, derived_type >::t = 0 );
312 inline Reference( interface_type * pInterface );
410 inline interface_type * SAL_CALL
get()
const
415 inline void SAL_CALL
clear();
428 inline bool SAL_CALL
set( interface_type * pInterface );
560 template <
typename T>
561 inline T * get_pointer( Reference<T>
const& r )
static XInterface * iquery_throw(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:66
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:340
This enum value can be used for implicit interface query.
Definition: Reference.h:139
bool set(const Reference< interface_type > &rRef)
Sets the given interface.
Definition: Reference.hxx:247
~Reference()
Destructor: Releases interface if set.
Definition: Reference.hxx:101
interface_type * operator->() const
Dereference operator: Used to call interface methods.
Definition: Reference.h:401
__sal_NoAcquire
Definition: types.h:368
static XInterface * iquery(XInterface *pInterface, const Type &rType)
Queries given interface for type rType.
Definition: Reference.hxx:37
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
bool operator!=(XInterface *pInterface) const
Unequality operator: compares two interfaces Checks if both references are null or refer to the same ...
Definition: Reference.hxx:395
bool is() const
Checks if reference is null.
Definition: Reference.h:92
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:309
UnoReference_QueryThrow
Enum defining UNO_QUERY_THROW for implicit interface query.
Definition: Reference.h:144
UnoReference_Query
Enum defining UNO_QUERY for implicit interface query.
Definition: Reference.h:135
bool operator<(const BaseReference &rRef) const
Needed by some STL containers.
Definition: Reference.hxx:376
void clear()
Clears reference, i.e.
Definition: Reference.hxx:204
XInterface * _pInterface
the interface pointer
Definition: Reference.h:62
C++ class representing an IDL meta type.
Definition: Type.h:54
C++ class representing an IDL any.
Definition: Any.h:49
UnoReference_SetThrow
Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null interface.
Definition: Reference.h:155
Reference()
Default Constructor: Sets null reference.
Definition: Reference.hxx:108
Definition: Reference.h:157
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:57
Reference< interface_type > & operator=(interface_type *pInterface)
Assignment operator: Acquires given interface pointer and sets reference.
Definition: Reference.hxx:323
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
This enum value can be used for creating a reference granting a given interface, i.e.
Definition: Reference.h:51
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:358
This enum value can be used for implicit interface query.
Definition: Reference.h:148
UnoReference_NoAcquire
Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
Definition: Reference.h:46
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32