LibreOffice
LibreOffice 5.3 SDK 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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_UNO_DISPATCHER_HXX
21 #define INCLUDED_UNO_DISPATCHER_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cstddef>
26 
27 #include <uno/dispatcher.h>
28 
30 
31 namespace com
32 {
33 namespace sun
34 {
35 namespace star
36 {
37 namespace uno
38 {
39 
47 class UnoInterfaceReference
48 {
49 public:
50  uno_Interface * m_pUnoI;
51 
52  inline bool is() const
53  { return m_pUnoI != NULL; }
54 
55  inline ~UnoInterfaceReference();
56  inline UnoInterfaceReference();
57  inline UnoInterfaceReference( uno_Interface * pUnoI, __sal_NoAcquire );
58  inline UnoInterfaceReference( uno_Interface * pUnoI );
59  inline UnoInterfaceReference( UnoInterfaceReference const & ref );
60 
61 #if defined LIBO_INTERNAL_ONLY
62  UnoInterfaceReference(UnoInterfaceReference && other):
63  m_pUnoI(other.m_pUnoI)
64  { other.m_pUnoI = nullptr; }
65 #endif
66 
67  inline uno_Interface * get() const
68  { return m_pUnoI; }
69 
70  inline UnoInterfaceReference & set(
71  uno_Interface * pUnoI );
72  inline UnoInterfaceReference & set(
73  uno_Interface * pUnoI, __sal_NoAcquire );
74  inline void clear();
75 
76  inline UnoInterfaceReference & operator = (
77  UnoInterfaceReference const & ref )
78  { return set( ref.m_pUnoI ); }
79  inline UnoInterfaceReference & operator = (
80  uno_Interface * pUnoI )
81  { return set( pUnoI ); }
82 
83 #if defined LIBO_INTERNAL_ONLY
84  UnoInterfaceReference & operator =(UnoInterfaceReference && other) {
85  if (m_pUnoI != nullptr) {
86  (*m_pUnoI->release)(m_pUnoI);
87  }
88  m_pUnoI = other.m_pUnoI;
89  other.m_pUnoI = nullptr;
90  return *this;
91  }
92 #endif
93 
94  inline void dispatch(
95  struct _typelib_TypeDescription const * pMemberType,
96  void * pReturn, void * pArgs [], uno_Any ** ppException ) const;
97 };
98 
99 
100 inline UnoInterfaceReference::~UnoInterfaceReference()
101 {
102  if (m_pUnoI != NULL)
103  (*m_pUnoI->release)( m_pUnoI );
104 }
105 
106 
107 inline UnoInterfaceReference::UnoInterfaceReference()
108  : m_pUnoI( NULL )
109 {
110 }
111 
112 
113 inline UnoInterfaceReference::UnoInterfaceReference(
114  uno_Interface * pUnoI, __sal_NoAcquire )
115  : m_pUnoI( pUnoI )
116 {
117 }
118 
119 
120 inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI )
121  : m_pUnoI( pUnoI )
122 {
123  if (m_pUnoI != NULL)
124  (*m_pUnoI->acquire)( m_pUnoI );
125 }
126 
127 
128 inline UnoInterfaceReference::UnoInterfaceReference(
129  UnoInterfaceReference const & ref )
130  : m_pUnoI( ref.m_pUnoI )
131 {
132  if (m_pUnoI != NULL)
133  (*m_pUnoI->acquire)( m_pUnoI );
134 }
135 
136 
137 inline UnoInterfaceReference & UnoInterfaceReference::set(
138  uno_Interface * pUnoI )
139 {
140  if (pUnoI != NULL)
141  (*pUnoI->acquire)( pUnoI );
142  if (m_pUnoI != NULL)
143  (*m_pUnoI->release)( m_pUnoI );
144  m_pUnoI = pUnoI;
145  return *this;
146 }
147 
148 
149 inline UnoInterfaceReference & UnoInterfaceReference::set(
150  uno_Interface * pUnoI, __sal_NoAcquire )
151 {
152  if (m_pUnoI != NULL)
153  (*m_pUnoI->release)( m_pUnoI );
154  m_pUnoI = pUnoI;
155  return *this;
156 }
157 
158 
159 inline void UnoInterfaceReference::clear()
160 {
161  if (m_pUnoI != NULL)
162  {
163  (*m_pUnoI->release)( m_pUnoI );
164  m_pUnoI = NULL;
165  }
166 }
167 
168 
169 inline void UnoInterfaceReference::dispatch(
170  struct _typelib_TypeDescription const * pMemberType,
171  void * pReturn, void * pArgs [], uno_Any ** ppException ) const
172 {
173  (*m_pUnoI->pDispatcher)(
174  m_pUnoI, pMemberType, pReturn, pArgs, ppException );
175 }
176 
177 }
178 }
179 }
180 }
181 
183 
184 #endif
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of an UNO any.
Full type description of a type.
Definition: typedescription.h:71
__sal_NoAcquire
Definition: types.h:384
struct SAL_DLLPUBLIC_RTTI _uno_Interface uno_Interface
The binary C uno interface description.