LibreOffice
LibreOffice 5.1 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 #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  inline uno_Interface * get() const
62  { return m_pUnoI; }
63 
64  inline UnoInterfaceReference & set(
65  uno_Interface * pUnoI );
66  inline UnoInterfaceReference & set(
67  uno_Interface * pUnoI, __sal_NoAcquire );
68  inline void clear();
69 
70  inline UnoInterfaceReference & operator = (
71  UnoInterfaceReference const & ref )
72  { return set( ref.m_pUnoI ); }
73  inline UnoInterfaceReference & operator = (
74  uno_Interface * pUnoI )
75  { return set( pUnoI ); }
76 
77  inline void dispatch(
78  struct _typelib_TypeDescription const * pMemberType,
79  void * pReturn, void * pArgs [], uno_Any ** ppException ) const;
80 
81 private:
82  inline bool operator == ( UnoInterfaceReference const & ); // not impl
83  inline bool operator != ( UnoInterfaceReference const & ); // not impl
84  inline bool operator == ( uno_Interface * ); // not impl
85  inline bool operator != ( uno_Interface * ); // not impl
86 };
87 
88 
89 inline UnoInterfaceReference::~UnoInterfaceReference()
90 {
91  if (m_pUnoI != NULL)
92  (*m_pUnoI->release)( m_pUnoI );
93 }
94 
95 
96 inline UnoInterfaceReference::UnoInterfaceReference()
97  : m_pUnoI( NULL )
98 {
99 }
100 
101 
102 inline UnoInterfaceReference::UnoInterfaceReference(
103  uno_Interface * pUnoI, __sal_NoAcquire )
104  : m_pUnoI( pUnoI )
105 {
106 }
107 
108 
109 inline UnoInterfaceReference::UnoInterfaceReference( uno_Interface * pUnoI )
110  : m_pUnoI( pUnoI )
111 {
112  if (m_pUnoI != NULL)
113  (*m_pUnoI->acquire)( m_pUnoI );
114 }
115 
116 
117 inline UnoInterfaceReference::UnoInterfaceReference(
118  UnoInterfaceReference const & ref )
119  : m_pUnoI( ref.m_pUnoI )
120 {
121  if (m_pUnoI != NULL)
122  (*m_pUnoI->acquire)( m_pUnoI );
123 }
124 
125 
126 inline UnoInterfaceReference & UnoInterfaceReference::set(
127  uno_Interface * pUnoI )
128 {
129  if (pUnoI != NULL)
130  (*pUnoI->acquire)( pUnoI );
131  if (m_pUnoI != NULL)
132  (*m_pUnoI->release)( m_pUnoI );
133  m_pUnoI = pUnoI;
134  return *this;
135 }
136 
137 
138 inline UnoInterfaceReference & UnoInterfaceReference::set(
139  uno_Interface * pUnoI, __sal_NoAcquire )
140 {
141  if (m_pUnoI != NULL)
142  (*m_pUnoI->release)( m_pUnoI );
143  m_pUnoI = pUnoI;
144  return *this;
145 }
146 
147 
148 inline void UnoInterfaceReference::clear()
149 {
150  if (m_pUnoI != NULL)
151  {
152  (*m_pUnoI->release)( m_pUnoI );
153  m_pUnoI = NULL;
154  }
155 }
156 
157 
158 inline void UnoInterfaceReference::dispatch(
159  struct _typelib_TypeDescription const * pMemberType,
160  void * pReturn, void * pArgs [], uno_Any ** ppException ) const
161 {
162  (*m_pUnoI->pDispatcher)(
163  m_pUnoI, pMemberType, pReturn, pArgs, ppException );
164 }
165 
166 }
167 }
168 }
169 }
170 
172 
173 #endif
174 
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:573
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of an UNO any.
Definition: types.h:389
Full type description of a type.
Definition: typedescription.h:71
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:584
__sal_NoAcquire
Definition: types.h:382
struct SAL_DLLPUBLIC_RTTI _uno_Interface uno_Interface
The binary C uno interface description.