LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
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 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_UNO_DISPATCHER_HXX
25 #define INCLUDED_UNO_DISPATCHER_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cstddef>
30 
31 #include "uno/dispatcher.h"
32 
34 
35 namespace com
36 {
37 namespace sun
38 {
39 namespace star
40 {
41 namespace uno
42 {
43 
51 class UnoInterfaceReference
52 {
53 public:
54  uno_Interface * m_pUnoI;
55 
56  bool is() const
57  { return m_pUnoI != NULL; }
58 
59  inline ~UnoInterfaceReference();
60  inline UnoInterfaceReference();
61  inline UnoInterfaceReference( uno_Interface * pUnoI, __sal_NoAcquire );
62  inline UnoInterfaceReference( uno_Interface * pUnoI );
63  inline UnoInterfaceReference( UnoInterfaceReference const & ref );
64 
65 #if defined LIBO_INTERNAL_ONLY
66  UnoInterfaceReference(UnoInterfaceReference && other) noexcept :
67  m_pUnoI(other.m_pUnoI)
68  { other.m_pUnoI = nullptr; }
69 #endif
70 
71  uno_Interface * get() const
72  { return m_pUnoI; }
73 
74  inline UnoInterfaceReference & set(
75  uno_Interface * pUnoI );
76  inline UnoInterfaceReference & set(
77  uno_Interface * pUnoI, __sal_NoAcquire );
78  inline void clear();
79 
80  UnoInterfaceReference & operator = (
81  UnoInterfaceReference const & ref )
82  { return set( ref.m_pUnoI ); }
83  UnoInterfaceReference & operator = (
84  uno_Interface * pUnoI )
85  { return set( pUnoI ); }
86 
87 #if defined LIBO_INTERNAL_ONLY
88  UnoInterfaceReference & operator =(UnoInterfaceReference && other) {
89  if (m_pUnoI != nullptr) {
90  (*m_pUnoI->release)(m_pUnoI);
91  }
92  m_pUnoI = other.m_pUnoI;
93  other.m_pUnoI = nullptr;
94  return *this;
95  }
96 #endif
97 
98  inline void dispatch(
99  struct _typelib_TypeDescription const * pMemberType,
100  void * pReturn, void * pArgs [], uno_Any ** ppException ) const;
101 };
102 
103 
104 inline UnoInterfaceReference::~UnoInterfaceReference()
105 {
106  if (m_pUnoI != NULL)
107  (*m_pUnoI->release)( m_pUnoI );
108 }
109 
110 
111 inline UnoInterfaceReference::UnoInterfaceReference()
112  : m_pUnoI( NULL )
113 {
114 }
115 
116 
117 inline UnoInterfaceReference::UnoInterfaceReference(
118  uno_Interface * pUnoI, __sal_NoAcquire )
119  : m_pUnoI( pUnoI )
120 {
121 }
122 
123 
124 inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI )
125  : m_pUnoI( pUnoI )
126 {
127  if (m_pUnoI != NULL)
128  (*m_pUnoI->acquire)( m_pUnoI );
129 }
130 
131 
132 inline UnoInterfaceReference::UnoInterfaceReference(
133  UnoInterfaceReference const & ref )
134  : m_pUnoI( ref.m_pUnoI )
135 {
136  if (m_pUnoI != NULL)
137  (*m_pUnoI->acquire)( m_pUnoI );
138 }
139 
140 
141 inline UnoInterfaceReference & UnoInterfaceReference::set(
142  uno_Interface * pUnoI )
143 {
144  if (pUnoI != NULL)
145  (*pUnoI->acquire)( pUnoI );
146  if (m_pUnoI != NULL)
147  (*m_pUnoI->release)( m_pUnoI );
148  m_pUnoI = pUnoI;
149  return *this;
150 }
151 
152 
153 inline UnoInterfaceReference & UnoInterfaceReference::set(
154  uno_Interface * pUnoI, __sal_NoAcquire )
155 {
156  if (m_pUnoI != NULL)
157  (*m_pUnoI->release)( m_pUnoI );
158  m_pUnoI = pUnoI;
159  return *this;
160 }
161 
162 
163 inline void UnoInterfaceReference::clear()
164 {
165  if (m_pUnoI != NULL)
166  {
167  (*m_pUnoI->release)( m_pUnoI );
168  m_pUnoI = NULL;
169  }
170 }
171 
172 
173 inline void UnoInterfaceReference::dispatch(
174  struct _typelib_TypeDescription const * pMemberType,
175  void * pReturn, void * pArgs [], uno_Any ** ppException ) const
176 {
177  (*m_pUnoI->pDispatcher)(
178  m_pUnoI, pMemberType, pReturn, pArgs, ppException );
179 }
180 
181 }
182 }
183 }
184 }
185 
187 
188 #endif
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: types.h:359
__sal_NoAcquire
Definition: types.h:352
struct SAL_DLLPUBLIC_RTTI _uno_Interface uno_Interface
The binary C uno interface description.
Full type description of a type.
Definition: typedescription.h:75
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of a UNO any.