xref: /aoo42x/main/vos/source/module.cxx (revision 24c56ab9)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #include <vos/module.hxx>
26 #include <vos/diagnose.hxx>
27 
28 using namespace vos;
29 
30 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OModule, vos),
31                         VOS_NAMESPACE(OModule, vos),
32                         VOS_NAMESPACE(OObject, vos), 0);
33 
34 
OModule()35 OModule::OModule()
36 	:m_Module(0)
37 {
38 }
39 
OModule(const rtl::OUString & ustrModuleName,sal_Int32 nRtldMode)40 OModule::OModule(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode) : m_Module(0)
41 {
42     if( !ustrModuleName.isEmpty())
43         load(ustrModuleName, nRtldMode);
44 }
45 
~OModule()46 OModule::~OModule()
47 {
48     if (m_Module)
49         osl_unloadModule(m_Module);
50 }
51 
load(const rtl::OUString & ustrModuleName,sal_Int32 nRtldMode)52 sal_Bool OModule::load(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode)
53 {
54     VOS_ASSERT( !ustrModuleName.isEmpty());
55 
56     unload();
57 
58     m_Module = osl_loadModule( ustrModuleName.pData, nRtldMode );
59 
60     return (m_Module != 0);
61 }
62 
unload()63 void OModule::unload()
64 {
65     if (m_Module)
66     {
67         osl_unloadModule(m_Module);
68         m_Module = 0;
69     }
70 }
71 
isLoaded()72 sal_Bool OModule::isLoaded()
73 {
74 	return m_Module != NULL;
75 }
76 
getSymbol(const rtl::OUString & strSymbolName)77 void *OModule::getSymbol(const rtl::OUString& strSymbolName)
78 {
79     VOS_ASSERT( !strSymbolName.isEmpty());
80     VOS_ASSERT(m_Module);
81 	return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
82 }
83 
84