00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _OSL_MODULE_HXX_
00021 #define _OSL_MODULE_HXX_
00022
00023 #include <rtl/ustring.hxx>
00024 #include <osl/module.h>
00025
00026 namespace osl
00027 {
00028
00029 class Module
00030 {
00031 Module( const Module&);
00032 Module& operator = ( const Module&);
00033
00034 public:
00035 static sal_Bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
00036 return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
00037 }
00038
00060 static sal_Bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
00061 return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
00062 }
00063
00064 Module(): m_Module(0){}
00065
00066 #ifndef DISABLE_DYNLOADING
00067
00068 Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
00069 {
00070 load( strModuleName, nRtldMode);
00071 }
00072
00073 #endif
00074
00075 ~Module()
00076 {
00077 #ifndef DISABLE_DYNLOADING
00078 osl_unloadModule(m_Module);
00079 #endif
00080 }
00081
00082 #ifndef DISABLE_DYNLOADING
00083
00084 sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName,
00085 sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
00086 {
00087 unload();
00088 m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
00089 return is();
00090 }
00091
00093 sal_Bool SAL_CALL loadRelative(
00094 ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
00095 ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
00096 {
00097 unload();
00098 m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
00099 return is();
00100 }
00101
00103 sal_Bool SAL_CALL loadRelative(
00104 oslGenericFunction baseModule, char const * relativePath,
00105 sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
00106 {
00107 unload();
00108 m_Module = osl_loadModuleRelativeAscii(baseModule, relativePath, mode);
00109 return is();
00110 }
00111
00112 void SAL_CALL unload()
00113 {
00114 if (m_Module)
00115 {
00116 osl_unloadModule(m_Module);
00117 m_Module = 0;
00118 }
00119 }
00120
00121 #endif
00122
00123 sal_Bool SAL_CALL is() const
00124 {
00125 return m_Module != NULL;
00126 }
00127
00128 void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
00129 {
00130 return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
00131 }
00132
00151 oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
00152 {
00153 return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
00154 }
00155
00157 oslGenericFunction SAL_CALL getFunctionSymbol(char const * name) const {
00158 return osl_getAsciiFunctionSymbol(m_Module, name);
00159 }
00160
00161 operator oslModule() const
00162 {
00163 return m_Module;
00164 }
00165
00166 private:
00167 oslModule m_Module;
00168
00169 };
00170
00171 }
00172
00173 #endif
00174
00175