|
UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * This file is part of the LibreOffice project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * This file incorporates work covered by the following license notice: 00010 * 00011 * Licensed to the Apache Software Foundation (ASF) under one or more 00012 * contributor license agreements. See the NOTICE file distributed 00013 * with this work for additional information regarding copyright 00014 * ownership. The ASF licenses this file to you under the Apache 00015 * License, Version 2.0 (the "License"); you may not use this file 00016 * except in compliance with the License. You may obtain a copy of 00017 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 00018 */ 00019 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ 00020 #define _COM_SUN_STAR_UNO_REFERENCE_H_ 00021 00022 #include <rtl/alloc.h> 00023 00024 00025 namespace com 00026 { 00027 namespace sun 00028 { 00029 namespace star 00030 { 00031 namespace uno 00032 { 00033 00034 class RuntimeException; 00035 class XInterface; 00036 class Type; 00037 class Any; 00038 00043 enum UnoReference_NoAcquire 00044 { 00048 UNO_REF_NO_ACQUIRE 00049 }; 00050 00054 class BaseReference 00055 { 00056 protected: 00059 XInterface * _pInterface; 00060 00067 inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType ) 00068 SAL_THROW( (RuntimeException) ); 00069 #ifndef EXCEPTIONS_OFF 00070 00077 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType ) 00078 SAL_THROW( (RuntimeException) ); 00079 #endif 00080 00081 public: 00086 inline XInterface * SAL_CALL get() const SAL_THROW(()) 00087 { return _pInterface; } 00088 00093 inline sal_Bool SAL_CALL is() const SAL_THROW(()) 00094 { return (0 != _pInterface); } 00095 00102 inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW(()); 00109 inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW(()); 00110 00117 inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW(()); 00124 inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW(()); 00125 00131 inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW(()); 00132 }; 00133 00136 enum UnoReference_Query 00137 { 00140 UNO_QUERY, 00141 }; 00142 #ifndef EXCEPTIONS_OFF 00143 00146 enum UnoReference_QueryThrow 00147 { 00150 UNO_QUERY_THROW, 00151 }; 00157 enum UnoReference_SetThrow 00158 { 00159 UNO_SET_THROW 00160 }; 00161 #endif 00162 00167 template< class interface_type > 00168 class Reference : public BaseReference 00169 { 00175 inline static XInterface * SAL_CALL iquery( XInterface * pInterface ) 00176 SAL_THROW( (RuntimeException) ); 00177 #ifndef EXCEPTIONS_OFF 00178 00184 inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface ) 00185 SAL_THROW( (RuntimeException) ); 00191 inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface ) 00192 SAL_THROW( (RuntimeException) ); 00193 #endif 00194 00206 static inline interface_type * castFromXInterface(XInterface * p) { 00207 return static_cast< interface_type * >(static_cast< void * >(p)); 00208 } 00209 00221 static inline XInterface * castToXInterface(interface_type * p) { 00222 return static_cast< XInterface * >(static_cast< void * >(p)); 00223 } 00224 00225 public: 00227 // these are here to force memory de/allocation to sal lib. 00228 inline static void * SAL_CALL operator new ( ::size_t nSize ) SAL_THROW(()) 00229 { return ::rtl_allocateMemory( nSize ); } 00230 inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(()) 00231 { ::rtl_freeMemory( pMem ); } 00232 inline static void * SAL_CALL operator new ( ::size_t, void * pMem ) SAL_THROW(()) 00233 { return pMem; } 00234 inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(()) 00235 {} 00237 00240 inline ~Reference() SAL_THROW(()); 00241 00244 inline Reference() SAL_THROW(()); 00245 00250 inline Reference( const Reference< interface_type > & rRef ) SAL_THROW(()); 00255 inline Reference( interface_type * pInterface ) SAL_THROW(()); 00256 00262 inline Reference( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(()); 00270 inline Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ) SAL_THROW(()); 00271 00277 inline Reference( const BaseReference & rRef, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) ); 00283 inline Reference( XInterface * pInterface, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00289 inline Reference( const Any & rAny, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00290 #ifndef EXCEPTIONS_OFF 00291 00298 inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00306 inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00314 inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00323 inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) ); 00332 inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) ); 00333 #endif 00334 00339 inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW(()) 00340 { return * reinterpret_cast< const Reference< XInterface > * >( this ); } 00341 00346 inline interface_type * SAL_CALL operator -> () const SAL_THROW(()) 00347 { return castFromXInterface(_pInterface); } 00348 00353 inline interface_type * SAL_CALL get() const SAL_THROW(()) 00354 { return castFromXInterface(_pInterface); } 00355 00358 inline void SAL_CALL clear() SAL_THROW(()); 00359 00365 inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW(()); 00371 inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW(()); 00372 00379 inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(()); 00388 inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy) SAL_THROW(()); 00389 00397 inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) ); 00405 inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy) SAL_THROW( (RuntimeException) ); 00406 00418 inline bool set( Any const & rAny, UnoReference_Query dummy ); 00419 00420 #ifndef EXCEPTIONS_OFF 00421 00429 inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00438 inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) ); 00439 00449 inline void set( Any const & rAny, UnoReference_QueryThrow dummy); 00459 inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) ); 00469 inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) ); 00470 00471 #endif 00472 00479 inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW(()); 00486 inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) SAL_THROW(()); 00487 00493 inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) ); 00499 inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) ); 00500 }; 00501 00503 00505 template <typename T> 00506 inline T * get_pointer( Reference<T> const& r ) 00507 { 00508 return r.get(); 00509 } 00511 00512 } 00513 } 00514 } 00515 } 00516 00517 #endif 00518 00519 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3