xref: /aoo42x/main/vos/source/module.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #include <vos/module.hxx>
30 #include <vos/diagnose.hxx>
31 
32 using namespace vos;
33 
34 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OModule, vos),
35                         VOS_NAMESPACE(OModule, vos),
36                         VOS_NAMESPACE(OObject, vos), 0);
37 
38 
39 OModule::OModule()
40 	:m_Module(0)
41 {
42 }
43 
44 OModule::OModule(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode) : m_Module(0)
45 {
46     if (ustrModuleName)
47         load(ustrModuleName, nRtldMode);
48 }
49 
50 OModule::~OModule()
51 {
52     if (m_Module)
53         osl_unloadModule(m_Module);
54 }
55 
56 sal_Bool OModule::load(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode)
57 {
58     VOS_ASSERT(ustrModuleName);
59 
60     unload();
61 
62     m_Module = osl_loadModule( ustrModuleName.pData, nRtldMode );
63 
64     return (m_Module != 0);
65 }
66 
67 void OModule::unload()
68 {
69     if (m_Module)
70     {
71         osl_unloadModule(m_Module);
72         m_Module = 0;
73     }
74 }
75 
76 sal_Bool OModule::isLoaded()
77 {
78 	return m_Module != NULL;
79 }
80 
81 void *OModule::getSymbol(const rtl::OUString& strSymbolName)
82 {
83     VOS_ASSERT(strSymbolName);
84     VOS_ASSERT(m_Module);
85 	return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
86 }
87 
88