LibreOffice: osl/module.hxx Source File

LibreOffice LibreOffice 5.2 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

module.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_OSL_MODULE_HXX
21 #define INCLUDED_OSL_MODULE_HXX
22
23 #include <sal/config.h>
24
25 #include <cstddef>
26
27 #include <rtl/ustring.hxx>
28 #include <osl/module.h>
29
30 namespace osl
31 {
32
33 class Module
34 {
35 Module( const Module&) SAL_DELETED_FUNCTION;
36 Module& operator = ( const Module&) SAL_DELETED_FUNCTION;
37
38 public:
39 static bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
40 return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
41 }
42
64 static bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
65 return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
66 }
67
68 Module(): m_Module(NULL){}
69
70 #ifndef DISABLE_DYNLOADING
71
72 Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(NULL)
73 {
74 load( strModuleName, nRtldMode);
75 }
76
77 #endif
78
79 ~Module()
80 {
81 #ifndef DISABLE_DYNLOADING
82 osl_unloadModule(m_Module);
83 #endif
84 }
85
86 #ifndef DISABLE_DYNLOADING
87
88 bool SAL_CALL load( const ::rtl::OUString& strModuleName,
89 sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
90 {
91 unload();
92 m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
93 return is();
94 }
95
97 bool SAL_CALL loadRelative(
98 ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
99 ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
100 {
101 unload();
102 m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
103 return is();
104 }
105
107 bool SAL_CALL loadRelative(
108 oslGenericFunction baseModule, char const * relativePath,
109 sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
110 {
111 unload();
112 m_Module = osl_loadModuleRelativeAscii(baseModule, relativePath, mode);
113 return is();
114 }
115
116 void SAL_CALL unload()
117 {
118 if (m_Module)
119 {
120 osl_unloadModule(m_Module);
121 m_Module = NULL;
122 }
123 }
124
125 #endif
126
127 bool SAL_CALL is() const
128 {
129 return m_Module != NULL;
130 }
131
132 void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
133 {
134 return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
135 }
136
155 oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
156 {
157 return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
158 }
159
161 oslGenericFunction SAL_CALL getFunctionSymbol(char const * name) const {
162 return osl_getAsciiFunctionSymbol(m_Module, name);
163 }
164
165 operator oslModule() const
166 {
167 return m_Module;
168 }
169
177 void release() { m_Module = NULL; }
178
179 private:
180 oslModule m_Module;
181
182 };
183
184 }
185
186 #endif
187
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Module::load
bool load(const ::rtl::OUString &strModuleName, sal_Int32 nRtldMode=SAL_LOADMODULE_DEFAULT)
Definition: module.hxx:88
osl::Module::Module
Module()
Definition: module.hxx:68
osl_getModuleURLFromFunctionAddress
SAL_DLLPUBLIC sal_Bool osl_getModuleURLFromFunctionAddress(oslGenericFunction pf, rtl_uString **pustrFunctionURL)
Lookup URL of module which is mapped at the specified function address.
osl::Module::loadRelative
bool loadRelative(oslGenericFunction baseModule, char const *relativePath, sal_Int32 mode=SAL_LOADMODULE_DEFAULT)
Definition: module.hxx:107
osl::Module::getFunctionSymbol
oslGenericFunction getFunctionSymbol(char const *name) const
Definition: module.hxx:161
config.h
osl_loadModuleRelativeAscii
SAL_DLLPUBLIC oslModule osl_loadModuleRelativeAscii(oslGenericFunction baseModule, char const *relativePath, sal_Int32 mode)
Load a module located relative to some other module.
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
osl_getAsciiFunctionSymbol
SAL_DLLPUBLIC oslGenericFunction osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol)
Lookup the specified function symbol name.
osl_loadModule
SAL_DLLPUBLIC oslModule osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode)
Load a shared library or module.
osl_getModuleURLFromAddress
SAL_DLLPUBLIC sal_Bool osl_getModuleURLFromAddress(void *pv, rtl_uString **pustrURL)
Lookup URL of module which is mapped at the specified address.
osl::Module::~Module
~Module()
Definition: module.hxx:79
osl::Module::Module
Module(const ::rtl::OUString &strModuleName, sal_Int32 nRtldMode=SAL_LOADMODULE_DEFAULT)
Definition: module.hxx:72
osl_getFunctionSymbol
SAL_DLLPUBLIC oslGenericFunction osl_getFunctionSymbol(oslModule Module, rtl_uString *ustrFunctionSymbolName)
Lookup the specified function symbol name.
osl::Module::getUrlFromAddress
static bool getUrlFromAddress(oslGenericFunction addr,::rtl::OUString &libraryUrl)
Get module URL from the specified function address in the module.
Definition: module.hxx:64
osl::Module::getFunctionSymbol
oslGenericFunction getFunctionSymbol(const ::rtl::OUString &ustrFunctionSymbolName) const
Get function address by the function name in the module.
Definition: module.hxx:155
osl::Module
Definition: module.hxx:33
osl::Module::loadRelative
bool loadRelative(::oslGenericFunction baseModule,::rtl::OUString const &relativePath,::sal_Int32 mode=SAL_LOADMODULE_DEFAULT)
Definition: module.hxx:97
SAL_LOADMODULE_DEFAULT
#define SAL_LOADMODULE_DEFAULT
Definition: module.h:51
osl::Module::unload
void unload()
Definition: module.hxx:116
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
osl_unloadModule
SAL_DLLPUBLIC void osl_unloadModule(oslModule Module)
Release the module.
ustring.hxx
osl::Module::getUrlFromAddress
static bool getUrlFromAddress(void *addr,::rtl::OUString &libraryUrl)
Definition: module.hxx:39
osl::Module::getSymbol
void * getSymbol(const ::rtl::OUString &strSymbolName)
Definition: module.hxx:132
module.h
osl_loadModuleRelative
SAL_DLLPUBLIC oslModule osl_loadModuleRelative(oslGenericFunction baseModule, rtl_uString *relativePath, sal_Int32 mode)
Load a module located relative to some other module.
osl::Module::release
void release()
Release the module so that it will not be unloaded from the destructor.
Definition: module.hxx:177
osl
Definition: conditn.hxx:32
osl_getSymbol
SAL_DLLPUBLIC void * osl_getSymbol(oslModule Module, rtl_uString *strSymbolName)
lookup the specified symbol name.
osl::Module::is
bool is() const
Definition: module.hxx:127
oslGenericFunction
void(* oslGenericFunction)(void)
Generic Function pointer type that will be used as symbol address.
Definition: module.h:62
oslModule
void * oslModule
Definition: module.h:56