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