added wxDynamicLibrary as suggested by Vadim
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,9 @@ loading of shared libraries and the resolving of symbols in them. There are no
|
|||||||
instances of this class, it simply serves as a namespace for its static member
|
instances of this class, it simply serves as a namespace for its static member
|
||||||
functions.
|
functions.
|
||||||
|
|
||||||
|
Please note that class \helpref{wxDynamicLibrary}{wxdynamiclibrary} provides
|
||||||
|
alternative, friendlier interface to wxDllLoader.
|
||||||
|
|
||||||
The terms {\it DLL} and {\it shared library/object} will both be used in the
|
The terms {\it DLL} and {\it shared library/object} will both be used in the
|
||||||
documentation to refer to the same thing: a {\tt .dll} file under Windows or
|
documentation to refer to the same thing: a {\tt .dll} file under Windows or
|
||||||
{\tt .so} or {\tt .sl} one under Unix.
|
{\tt .so} or {\tt .sl} one under Unix.
|
||||||
@@ -142,4 +145,47 @@ FALSE; may also be {\tt NULL}.}
|
|||||||
This function unloads the shared library. The handle {\it dllhandle} must have
|
This function unloads the shared library. The handle {\it dllhandle} must have
|
||||||
been returned by \helpref{LoadLibrary}{wxdllloaderloadlibrary} previously.
|
been returned by \helpref{LoadLibrary}{wxdllloaderloadlibrary} previously.
|
||||||
|
|
||||||
|
\section{\class{wxDynamicLibrary}}\label{wxdynamiclibrary}
|
||||||
|
|
||||||
|
wxDynamicLibrary is a class representing dynamically loadable library
|
||||||
|
(Windows DLL, shared library under Unix etc.). It is implemented as a wrapper
|
||||||
|
to \helpref{wxDllLoader}{wxdllloader}.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxDllLoader}{wxdllloader}
|
||||||
|
|
||||||
|
\membersection{wxDynamicLibrary::wxDynamicLibrary}\label{wxdynamiclibrarywxdynamiclibrary}
|
||||||
|
|
||||||
|
\func{}{wxDynamicLibrary}{\void}
|
||||||
|
|
||||||
|
\func{}{wxDynamicLibrary}{\param{const wxString\& }{name}}
|
||||||
|
|
||||||
|
Constructor. Second form calls \helpref{Load}{wxdynamiclibraryload}.
|
||||||
|
|
||||||
|
\membersection{wxDynamicLibrary::IsLoaded}\label{wxdynamiclibraryisloaded}
|
||||||
|
|
||||||
|
\constfunc{bool}{IsLoaded}{\void}
|
||||||
|
|
||||||
|
Returns TRUE if the library was successfully loaded, FALSE otherwise.
|
||||||
|
|
||||||
|
\membersection{wxDynamicLibrary::Load}\label{wxdynamiclibraryload}
|
||||||
|
|
||||||
|
\func{bool}{Load}{\param{const wxString\& }{name}}
|
||||||
|
|
||||||
|
Loads DLL into memory.
|
||||||
|
|
||||||
|
Returns TRUE if the library was successfully loaded, FALSE otherwise.
|
||||||
|
|
||||||
|
\membersection{wxDynamicLibrary::Unload}\label{wxdynamiclibraryunload}
|
||||||
|
|
||||||
|
\func{void}{Unload}{\void}
|
||||||
|
|
||||||
|
Unloads the library from memory.
|
||||||
|
|
||||||
|
\membersection{wxDynamicLibrary::GetSymbol}\label{wxdynamiclibrarygetsymbol}
|
||||||
|
|
||||||
|
\constfunc{void*}{GetSymbol}{\param{const wxString\& }{name}}
|
||||||
|
|
||||||
|
Returns pointer to symbol {\it name} in the library or NULL if the library
|
||||||
|
contains no such symbol.
|
||||||
|
@@ -104,6 +104,46 @@ private:
|
|||||||
wxDllLoader();
|
wxDllLoader();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDynamicLibrary - friendly interface to wxDllLoader
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxDynamicLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDynamicLibrary() { m_library = 0; }
|
||||||
|
wxDynamicLibrary(const wxString& name) { Load(name); }
|
||||||
|
|
||||||
|
bool IsLoaded() const { return m_library != 0; }
|
||||||
|
|
||||||
|
bool Load(const wxString& name)
|
||||||
|
{
|
||||||
|
m_library = wxDllLoader::LoadLibrary(name);
|
||||||
|
|
||||||
|
return IsLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unload()
|
||||||
|
{
|
||||||
|
if ( IsLoaded() )
|
||||||
|
wxDllLoader::UnloadLibrary(m_library)
|
||||||
|
}
|
||||||
|
|
||||||
|
void *GetSymbol(const wxString& name) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IsLoaded(), NULL,
|
||||||
|
_T("can't load symbol from unloaded library") );
|
||||||
|
|
||||||
|
return wxDllLoader::GetSymbol(m_library, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxDynamicLibrary() { Unload(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDllType m_library;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxLibrary
|
// wxLibrary
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user