1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #if ! defined INCLUDED_UNO_DISPATCHER_HXX 29 #define INCLUDED_UNO_DISPATCHER_HXX 30 31 #include "uno/dispatcher.h" 32 33 34 namespace com 35 { 36 namespace sun 37 { 38 namespace star 39 { 40 namespace uno 41 { 42 43 /** C++ holder reference for binary C uno_Interface. Not for public use, may be 44 subject to changes. 45 46 @see uno_Interface 47 @internal 48 not for public use! 49 */ 50 class UnoInterfaceReference 51 { 52 public: 53 uno_Interface * m_pUnoI; 54 55 inline bool is() const 56 { return m_pUnoI != 0; } 57 58 inline ~UnoInterfaceReference(); 59 inline UnoInterfaceReference(); 60 inline UnoInterfaceReference( uno_Interface * pUnoI, __sal_NoAcquire ); 61 inline UnoInterfaceReference( uno_Interface * pUnoI ); 62 inline UnoInterfaceReference( UnoInterfaceReference const & ref ); 63 64 inline uno_Interface * get() const 65 { return m_pUnoI; } 66 67 inline UnoInterfaceReference & set( 68 uno_Interface * pUnoI ); 69 inline UnoInterfaceReference & set( 70 uno_Interface * pUnoI, __sal_NoAcquire ); 71 inline void clear(); 72 73 inline UnoInterfaceReference & operator = ( 74 UnoInterfaceReference const & ref ) 75 { return set( ref.m_pUnoI ); } 76 inline UnoInterfaceReference & operator = ( 77 uno_Interface * pUnoI ) 78 { return set( pUnoI ); } 79 80 inline void dispatch( 81 struct _typelib_TypeDescription const * pMemberType, 82 void * pReturn, void * pArgs [], uno_Any ** ppException ) const; 83 84 private: 85 inline bool operator == ( UnoInterfaceReference const & ); // not impl 86 inline bool operator != ( UnoInterfaceReference const & ); // not impl 87 inline bool operator == ( uno_Interface * ); // not impl 88 inline bool operator != ( uno_Interface * ); // not impl 89 }; 90 91 //______________________________________________________________________________ 92 inline UnoInterfaceReference::~UnoInterfaceReference() 93 { 94 if (m_pUnoI != 0) 95 (*m_pUnoI->release)( m_pUnoI ); 96 } 97 98 //______________________________________________________________________________ 99 inline UnoInterfaceReference::UnoInterfaceReference() 100 : m_pUnoI( 0 ) 101 { 102 } 103 104 //______________________________________________________________________________ 105 inline UnoInterfaceReference::UnoInterfaceReference( 106 uno_Interface * pUnoI, __sal_NoAcquire ) 107 : m_pUnoI( pUnoI ) 108 { 109 } 110 111 //______________________________________________________________________________ 112 inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI ) 113 : m_pUnoI( pUnoI ) 114 { 115 if (m_pUnoI != 0) 116 (*m_pUnoI->acquire)( m_pUnoI ); 117 } 118 119 //______________________________________________________________________________ 120 inline UnoInterfaceReference::UnoInterfaceReference( 121 UnoInterfaceReference const & ref ) 122 : m_pUnoI( ref.m_pUnoI ) 123 { 124 if (m_pUnoI != 0) 125 (*m_pUnoI->acquire)( m_pUnoI ); 126 } 127 128 //______________________________________________________________________________ 129 inline UnoInterfaceReference & UnoInterfaceReference::set( 130 uno_Interface * pUnoI ) 131 { 132 if (pUnoI != 0) 133 (*pUnoI->acquire)( pUnoI ); 134 if (m_pUnoI != 0) 135 (*m_pUnoI->release)( m_pUnoI ); 136 m_pUnoI = pUnoI; 137 return *this; 138 } 139 140 //______________________________________________________________________________ 141 inline UnoInterfaceReference & UnoInterfaceReference::set( 142 uno_Interface * pUnoI, __sal_NoAcquire ) 143 { 144 if (m_pUnoI != 0) 145 (*m_pUnoI->release)( m_pUnoI ); 146 m_pUnoI = pUnoI; 147 return *this; 148 } 149 150 //______________________________________________________________________________ 151 inline void UnoInterfaceReference::clear() 152 { 153 if (m_pUnoI != 0) 154 { 155 (*m_pUnoI->release)( m_pUnoI ); 156 m_pUnoI = 0; 157 } 158 } 159 160 //______________________________________________________________________________ 161 inline void UnoInterfaceReference::dispatch( 162 struct _typelib_TypeDescription const * pMemberType, 163 void * pReturn, void * pArgs [], uno_Any ** ppException ) const 164 { 165 (*m_pUnoI->pDispatcher)( 166 m_pUnoI, pMemberType, pReturn, pArgs, ppException ); 167 } 168 169 } 170 } 171 } 172 } 173 174 #endif 175 176