xref: /aoo42x/main/cppu/inc/uno/dispatcher.hxx (revision c6ed87c9)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #if ! defined INCLUDED_UNO_DISPATCHER_HXX
25 #define INCLUDED_UNO_DISPATCHER_HXX
26 
27 #include "uno/dispatcher.h"
28 
29 
30 namespace com
31 {
32 namespace sun
33 {
34 namespace star
35 {
36 namespace uno
37 {
38 
39 /** C++ holder reference for binary C uno_Interface.  Not for public use, may be
40     subject to changes.
41 
42     @see uno_Interface
43     @internal
44               not for public use!
45 */
46 class UnoInterfaceReference
47 {
48 public:
49     uno_Interface * m_pUnoI;
50 
is() const51     inline bool is() const
52         { return m_pUnoI != 0; }
53 
54     inline ~UnoInterfaceReference();
55     inline UnoInterfaceReference();
56     inline UnoInterfaceReference( uno_Interface * pUnoI, __sal_NoAcquire );
57     inline UnoInterfaceReference( uno_Interface * pUnoI );
58     inline UnoInterfaceReference( UnoInterfaceReference const & ref );
59 
get() const60     inline uno_Interface * get() const
61         { return m_pUnoI; }
62 
63     inline UnoInterfaceReference & set(
64         uno_Interface * pUnoI );
65     inline UnoInterfaceReference & set(
66         uno_Interface * pUnoI, __sal_NoAcquire );
67     inline void clear();
68 
operator =(UnoInterfaceReference const & ref)69     inline UnoInterfaceReference & operator = (
70         UnoInterfaceReference const & ref )
71         { return set( ref.m_pUnoI ); }
operator =(uno_Interface * pUnoI)72     inline UnoInterfaceReference & operator = (
73         uno_Interface * pUnoI )
74         { return set( pUnoI ); }
75 
76     inline void dispatch(
77         struct _typelib_TypeDescription const * pMemberType,
78         void * pReturn, void * pArgs [], uno_Any ** ppException ) const;
79 
80 private:
81     inline bool operator == ( UnoInterfaceReference const & ); // not impl
82     inline bool operator != ( UnoInterfaceReference const & ); // not impl
83     inline bool operator == ( uno_Interface * ); // not impl
84     inline bool operator != ( uno_Interface * ); // not impl
85 };
86 
87 //______________________________________________________________________________
~UnoInterfaceReference()88 inline UnoInterfaceReference::~UnoInterfaceReference()
89 {
90     if (m_pUnoI != 0)
91         (*m_pUnoI->release)( m_pUnoI );
92 }
93 
94 //______________________________________________________________________________
UnoInterfaceReference()95 inline UnoInterfaceReference::UnoInterfaceReference()
96     : m_pUnoI( 0 )
97 {
98 }
99 
100 //______________________________________________________________________________
UnoInterfaceReference(uno_Interface * pUnoI,__sal_NoAcquire)101 inline UnoInterfaceReference::UnoInterfaceReference(
102     uno_Interface * pUnoI, __sal_NoAcquire )
103     : m_pUnoI( pUnoI )
104 {
105 }
106 
107 //______________________________________________________________________________
UnoInterfaceReference(uno_Interface * pUnoI)108 inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI )
109     : m_pUnoI( pUnoI )
110 {
111     if (m_pUnoI != 0)
112         (*m_pUnoI->acquire)( m_pUnoI );
113 }
114 
115 //______________________________________________________________________________
UnoInterfaceReference(UnoInterfaceReference const & ref)116 inline UnoInterfaceReference::UnoInterfaceReference(
117     UnoInterfaceReference const & ref )
118     : m_pUnoI( ref.m_pUnoI )
119 {
120     if (m_pUnoI != 0)
121         (*m_pUnoI->acquire)( m_pUnoI );
122 }
123 
124 //______________________________________________________________________________
set(uno_Interface * pUnoI)125 inline UnoInterfaceReference & UnoInterfaceReference::set(
126     uno_Interface * pUnoI )
127 {
128     if (pUnoI != 0)
129         (*pUnoI->acquire)( pUnoI );
130     if (m_pUnoI != 0)
131         (*m_pUnoI->release)( m_pUnoI );
132     m_pUnoI = pUnoI;
133     return *this;
134 }
135 
136 //______________________________________________________________________________
set(uno_Interface * pUnoI,__sal_NoAcquire)137 inline UnoInterfaceReference & UnoInterfaceReference::set(
138     uno_Interface * pUnoI, __sal_NoAcquire )
139 {
140     if (m_pUnoI != 0)
141         (*m_pUnoI->release)( m_pUnoI );
142     m_pUnoI = pUnoI;
143     return *this;
144 }
145 
146 //______________________________________________________________________________
clear()147 inline void UnoInterfaceReference::clear()
148 {
149     if (m_pUnoI != 0)
150     {
151         (*m_pUnoI->release)( m_pUnoI );
152         m_pUnoI = 0;
153     }
154 }
155 
156 //______________________________________________________________________________
dispatch(struct _typelib_TypeDescription const * pMemberType,void * pReturn,void * pArgs[],uno_Any ** ppException) const157 inline void UnoInterfaceReference::dispatch(
158     struct _typelib_TypeDescription const * pMemberType,
159     void * pReturn, void * pArgs [], uno_Any ** ppException ) const
160 {
161     (*m_pUnoI->pDispatcher)(
162         m_pUnoI, pMemberType, pReturn, pArgs, ppException );
163 }
164 
165 }
166 }
167 }
168 }
169 
170 #endif
171 
172