My Project
UDK 3.2.7 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  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef _SALHELPER_DYNLOAD_HXX_
30 #define _SALHELPER_DYNLOAD_HXX_
31 
32 #include <sal/types.h>
33 #include <rtl/ustring.hxx>
34 #include <osl/module.h>
35 #include "salhelperdllapi.h"
36 
37 namespace salhelper
38 {
39 
43 {
44 public:
52  static ORealDynamicLoader* SAL_CALL newInstance(
53  ORealDynamicLoader ** ppSetToZeroInDestructor,
54  const ::rtl::OUString& strModuleName,
55  const ::rtl::OUString& strInitFunction );
56 
58  sal_uInt32 SAL_CALL acquire();
60  sal_uInt32 SAL_CALL release();
61 
63  void* SAL_CALL getApi() const;
64 
65 protected:
75  ORealDynamicLoader( ORealDynamicLoader ** ppSetToZeroInDestructor,
76  const ::rtl::OUString& strModuleName,
77  const ::rtl::OUString& strInitFunction,
78  void* pApi,
79  oslModule pModule );
80 
82  virtual ~ORealDynamicLoader();
83 
85  void* m_pApi;
87  sal_uInt32 m_refCount;
98 };
99 
100 
113 template<class API>
115 {
116 public:
119  {
120  m_pLoader = 0;
121  }
122 
129  ODynamicLoader( const ::rtl::OUString& strModuleName,
130  const ::rtl::OUString& strInitFunction ) SAL_THROW(())
131  {
132  if (!m_pStaticLoader)
133  {
136  strModuleName,
137  strInitFunction);
138  }
139  else
140  {
142  }
143 
145  }
146 
149  {
150  m_pLoader = toCopy.m_pLoader;
151  if( m_pLoader )
152  m_pLoader->acquire();
153  }
154 
157  {
158  if( m_pLoader )
159  m_pLoader->release();
160  }
161 
164  {
165  if( m_pLoader != toAssign.m_pLoader )
166  {
167  if( toAssign.m_pLoader )
168  toAssign.m_pLoader->acquire();
169  if( m_pLoader )
170  m_pLoader->release();
171  m_pLoader = toAssign.m_pLoader;
172  }
173 
174  return (*this);
175  }
176 
178  API* SAL_CALL getApi() const SAL_THROW(())
179  {
180  return (API*)m_pLoader->getApi();
181  }
182 
184  API* SAL_CALL operator->() const SAL_THROW(())
185  {
186  return (API*)m_pLoader->getApi();
187  }
188 
190  sal_Bool SAL_CALL isLoaded() const SAL_THROW(())
191  {
192  return (m_pLoader != NULL);
193  }
194 
195 protected:
199 };
200 
201 
202 template<class API>
204 
205 }
206 
207 #endif
208 
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */