UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ 00029 #define _COM_SUN_STAR_UNO_REFERENCE_H_ 00030 00031 #include <rtl/alloc.h> 00032 00033 00034 namespace com 00035 { 00036 namespace sun 00037 { 00038 namespace star 00039 { 00040 namespace uno 00041 { 00042 00043 class RuntimeException; 00044 class XInterface; 00045 class Type; 00046 class Any; 00047 00052 enum UnoReference_NoAcquire 00053 { 00057 UNO_REF_NO_ACQUIRE 00058 }; 00059 00063 class BaseReference 00064 { 00065 protected: 00068 XInterface * _pInterface; 00069 00076 inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType ) 00077 SAL_THROW( (RuntimeException) ); 00078 #ifndef EXCEPTIONS_OFF 00079 00086 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType ) 00087 SAL_THROW( (RuntimeException) ); 00088 #endif 00089 00090 public: 00095 inline XInterface * SAL_CALL get() const SAL_THROW(()) 00096 { return _pInterface; } 00097 00102 inline sal_Bool SAL_CALL is() const SAL_THROW(()) 00103 { return (0 != _pInterface); } 00104 00111 inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW(()); 00118 inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW(()); 00119 00126 inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW(()); 00133 inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW(()); 00134 00140 inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW(()); 00141 }; 00142 00145 enum UnoReference_Query 00146 { 00149 UNO_QUERY, 00150 }; 00151 #ifndef EXCEPTIONS_OFF 00152 00155 enum UnoReference_QueryThrow 00156 { 00159 UNO_QUERY_THROW, 00160 }; 00166 enum UnoReference_SetThrow 00167 { 00168 UNO_SET_THROW 00169 }; 00170 #endif 00171 00176 template< class interface_type > 00177 class Reference : public BaseReference 00178 { 00184 inline static XInterface * SAL_CALL iquery( XInterface * pInterface ) 00185 SAL_THROW( (RuntimeException) ); 00186 #ifndef EXCEPTIONS_OFF 00187 00193 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface ) 00194 SAL_THROW( (RuntimeException) ); 00200 inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface ) 00201 SAL_THROW( (RuntimeException) ); 00202 #endif 00203 00215 static inline interface_type * castFromXInterface(XInterface * p) { 00216 return static_cast< interface_type * >(static_cast< void * >(p)); 00217 } 00218 00230 static inline XInterface * castToXInterface(interface_type * p) { 00231 return static_cast< XInterface * >(static_cast< void * >(p)); 00232 } 00233 00234 public: 00236 // these are here to force memory de/allocation to sal lib. 00237 inline static void * SAL_CALL operator new ( ::size_t nSize ) SAL_THROW(()) 00238 { return ::rtl_allocateMemory( nSize ); } 00239 inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(()) 00240 { ::rtl_freeMemory( pMem ); } 00241 inline static void * SAL_CALL operator new ( ::size_t, void * pMem ) SAL_THROW(()) 00242 { return pMem; } 00243 inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(()) 00244 {} 00246 00249 inline ~Reference() SAL_THROW(()); 00250 00253 inline Reference() SAL_THROW(()); 00254 00259 inline Reference( const Reference< interface_type > & rRef ) SAL_THROW(()); 00264 inline Reference( interface_type * pInterface ) SAL_THROW(()); 00265 00271 inline Reference( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(()); 00279 inline Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ) SAL_THROW(()); 00280 00286 inline Reference( const BaseReference & rRef, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) ); 00292 inline Reference( XInterface * pInterface, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00298 inline Reference( const Any & rAny, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00299 #ifndef EXCEPTIONS_OFF 00300 00307 inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00315 inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00323 inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00332 inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) ); 00341 inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) ); 00342 #endif 00343 00348 inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW(()) 00349 { return * reinterpret_cast< const Reference< XInterface > * >( this ); } 00350 00355 inline interface_type * SAL_CALL operator -> () const SAL_THROW(()) 00356 { return castFromXInterface(_pInterface); } 00357 00362 inline interface_type * SAL_CALL get() const SAL_THROW(()) 00363 { return castFromXInterface(_pInterface); } 00364 00367 inline void SAL_CALL clear() SAL_THROW(()); 00368 00374 inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW(()); 00380 inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW(()); 00381 00388 inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(()); 00397 inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy) SAL_THROW(()); 00398 00406 inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) ); 00414 inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00415 00427 inline bool set( Any const & rAny, UnoReference_Query dummy ); 00428 00429 #ifndef EXCEPTIONS_OFF 00430 00438 inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00447 inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00448 00458 inline void set( Any const & rAny, UnoReference_QueryThrow dummy); 00468 inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) ); 00478 inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) ); 00479 00480 #endif 00481 00488 inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW(()); 00495 inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) SAL_THROW(()); 00496 00502 inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) ); 00508 inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) ); 00509 }; 00510 00512 00514 template <typename T> 00515 inline T * get_pointer( Reference<T> const& r ) 00516 { 00517 return r.get(); 00518 } 00520 00521 } 00522 } 00523 } 00524 } 00525 00526 #endif 00527 00528 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */