LibreOffice
LibreOffice 4.1 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dynload.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 _SALHELPER_DYNLOAD_HXX_
21 #define _SALHELPER_DYNLOAD_HXX_
22 
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
25 #include <osl/module.h>
26 #include "salhelperdllapi.h"
27 
28 namespace salhelper
29 {
30 
34 {
35 public:
43  static ORealDynamicLoader* SAL_CALL newInstance(
44  ORealDynamicLoader ** ppSetToZeroInDestructor,
45  const ::rtl::OUString& strModuleName,
46  const ::rtl::OUString& strInitFunction );
47 
49  sal_uInt32 SAL_CALL acquire();
51  sal_uInt32 SAL_CALL release();
52 
54  void* SAL_CALL getApi() const;
55 
56 protected:
66  ORealDynamicLoader( ORealDynamicLoader ** ppSetToZeroInDestructor,
67  const ::rtl::OUString& strModuleName,
68  const ::rtl::OUString& strInitFunction,
69  void* pApi,
70  oslModule pModule );
71 
73  virtual ~ORealDynamicLoader();
74 
76  void* m_pApi;
78  sal_uInt32 m_refCount;
89 };
90 
91 
104 template<class API>
106 {
107 public:
110  {
111  m_pLoader = 0;
112  }
113 
120  ODynamicLoader( const ::rtl::OUString& strModuleName,
121  const ::rtl::OUString& strInitFunction ) SAL_THROW(())
122  {
123  if (!m_pStaticLoader)
124  {
127  strModuleName,
128  strInitFunction);
129  }
130  else
131  {
133  }
134 
136  }
137 
140  {
141  m_pLoader = toCopy.m_pLoader;
142  if( m_pLoader )
143  m_pLoader->acquire();
144  }
145 
148  {
149  if( m_pLoader )
150  m_pLoader->release();
151  }
152 
155  {
156  if( m_pLoader != toAssign.m_pLoader )
157  {
158  if( toAssign.m_pLoader )
159  {
160  toAssign.m_pLoader->acquire();
161  }
162  if( m_pLoader )
163  {
164  m_pLoader->release();
165  }
166  m_pLoader = toAssign.m_pLoader;
167  }
168 
169  return (*this);
170  }
171 
173  API* SAL_CALL getApi() const SAL_THROW(())
174  {
175  return (API*)m_pLoader->getApi();
176  }
177 
179  API* SAL_CALL operator->() const SAL_THROW(())
180  {
181  return (API*)m_pLoader->getApi();
182  }
183 
185  sal_Bool SAL_CALL isLoaded() const SAL_THROW(())
186  {
187  return (m_pLoader != NULL);
188  }
189 
190 protected:
194 };
195 
196 
197 template<class API>
199 
200 }
201 
202 #endif
203 
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */