LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/osl - module.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 38 100.0 %
Date: 2012-08-25 Functions: 14 14 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 2 100.0 %

           Branch data     Line data    Source code
       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 _OSL_MODULE_HXX_
      30                 :            : #define _OSL_MODULE_HXX_
      31                 :            : 
      32                 :            : #include <rtl/ustring.hxx>
      33                 :            : #include <osl/module.h>
      34                 :            : 
      35                 :            : namespace osl
      36                 :            : {
      37                 :            : 
      38                 :            : class Module
      39                 :            : {
      40                 :            :     Module( const Module&);
      41                 :            :     Module& operator = ( const Module&);
      42                 :            : 
      43                 :            : public:
      44                 :         91 :     static sal_Bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
      45                 :         91 :         return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
      46                 :            :     }
      47                 :            : 
      48                 :            :     /** Get module URL from the specified function address in the module.
      49                 :            : 
      50                 :            :         Similar to getUrlFromAddress, but use a function address to get URL of the Module.
      51                 :            :         Use Function pointer as symbol address to conceal type conversion.
      52                 :            : 
      53                 :            :         @param addr
      54                 :            :         [in] function address in oslGenericFunction format.
      55                 :            : 
      56                 :            :         @param libraryUrl
      57                 :            :         [in|out] receives the URL of the module.
      58                 :            : 
      59                 :            :         @return
      60                 :            :         <dl>
      61                 :            :         <dt>sal_True</dt>
      62                 :            :         <dd>on success</dd>
      63                 :            :         <dt>sal_False</dt>
      64                 :            :         <dd>can not get the URL from the specified function address or the parameter is invalid.</dd>
      65                 :            :         </dl>
      66                 :            : 
      67                 :            :         @see getUrlFromAddress
      68                 :            :     */
      69                 :      40410 :     static sal_Bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
      70                 :      40410 :         return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
      71                 :            :     }
      72                 :            : 
      73                 :        528 :     Module(): m_Module(0){}
      74                 :            : 
      75                 :        506 :     Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
      76                 :            :     {
      77                 :        506 :         load( strModuleName, nRtldMode);
      78                 :        506 :     }
      79                 :            : 
      80                 :       1019 :     ~Module()
      81                 :            :     {
      82                 :       1019 :         osl_unloadModule(m_Module);
      83                 :       1019 :     }
      84                 :            : 
      85                 :        533 :     sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName,
      86                 :            :         sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
      87                 :            :     {
      88                 :        533 :         unload();
      89                 :        533 :         m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
      90                 :        533 :         return is();
      91                 :            :     }
      92                 :            : 
      93                 :            :     /// @since UDK 3.2.8
      94                 :        317 :     sal_Bool SAL_CALL loadRelative(
      95                 :            :         ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
      96                 :            :         ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
      97                 :            :     {
      98                 :        317 :         unload();
      99                 :        317 :         m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
     100                 :        317 :         return is();
     101                 :            :     }
     102                 :            : 
     103                 :            :     /// @since LibreOffice 3.5
     104                 :         94 :     sal_Bool SAL_CALL loadRelative(
     105                 :            :         oslGenericFunction baseModule, char const * relativePath,
     106                 :            :         sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
     107                 :            :     {
     108                 :         94 :         unload();
     109                 :         94 :         m_Module = osl_loadModuleRelativeAscii(baseModule, relativePath, mode);
     110                 :         94 :         return is();
     111                 :            :     }
     112                 :            : 
     113                 :        994 :     void SAL_CALL unload()
     114                 :            :     {
     115         [ +  + ]:        994 :         if (m_Module)
     116                 :            :         {
     117                 :         50 :             osl_unloadModule(m_Module);
     118                 :         50 :             m_Module = 0;
     119                 :            :         }
     120                 :        994 :     }
     121                 :            : 
     122                 :       1023 :     sal_Bool SAL_CALL is() const
     123                 :            :     {
     124                 :       1023 :            return m_Module != NULL;
     125                 :            :     }
     126                 :            : 
     127                 :         10 :     void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
     128                 :            :     {
     129                 :         10 :     return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
     130                 :            :     }
     131                 :            : 
     132                 :            :     /** Get function address by the function name in the module.
     133                 :            : 
     134                 :            :         getFunctionSymbol is an alternative function for getSymbol.
     135                 :            :         Use Function pointer as symbol address to conceal type conversion.
     136                 :            : 
     137                 :            :         @param ustrFunctionSymbolName
     138                 :            :         [in] Function name to be looked up.
     139                 :            : 
     140                 :            :         @return
     141                 :            :         <dl>
     142                 :            :         <dt>oslGenericFunction format function address</dt>
     143                 :            :         <dd>on success</dd>
     144                 :            :         <dt>NULL</dt>
     145                 :            :         <dd>lookup failed or parameter is somewhat invalid</dd>
     146                 :            :         </dl>
     147                 :            : 
     148                 :            :         @see getSymbol
     149                 :            :     */
     150                 :     527191 :     oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
     151                 :            :     {
     152                 :     527191 :         return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
     153                 :            :     }
     154                 :            : 
     155                 :            :     /// @since LibreOffice 3.5
     156                 :         97 :     oslGenericFunction SAL_CALL getFunctionSymbol(char const * name) const {
     157                 :         97 :         return osl_getAsciiFunctionSymbol(m_Module, name);
     158                 :            :     }
     159                 :            : 
     160                 :        240 :     operator oslModule() const
     161                 :            :     {
     162                 :        240 :         return m_Module;
     163                 :            :     }
     164                 :            : 
     165                 :            : private:
     166                 :            :     oslModule m_Module;
     167                 :            : 
     168                 :            : };
     169                 :            : 
     170                 :            : }
     171                 :            : 
     172                 :            : #endif
     173                 :            : 
     174                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10