Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/OSD_SharedLibrary.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 1994-08-30
0002 // Created by: J.P. TIRAULT
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _OSD_SharedLibrary_HeaderFile
0018 #define _OSD_SharedLibrary_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <Standard_PCharacter.hxx>
0024 #include <OSD_LoadMode.hxx>
0025 #include <OSD_Function.hxx>
0026 
0027 //! Interface to dynamic library loader.
0028 //! Provides tools to load a shared library
0029 //! and retrieve the address of an entry point.
0030 class OSD_SharedLibrary
0031 {
0032 public:
0033   DEFINE_STANDARD_ALLOC
0034 
0035   //! Creates a SharedLibrary object with name NULL.
0036   Standard_EXPORT OSD_SharedLibrary();
0037 
0038   //! Creates a SharedLibrary object with name aFilename.
0039   Standard_EXPORT OSD_SharedLibrary(const Standard_CString aFilename);
0040 
0041   //! Sets a name associated to the shared object.
0042   Standard_EXPORT void SetName(const Standard_CString aName);
0043 
0044   //! Returns the name associated to the shared object.
0045   Standard_EXPORT Standard_CString Name() const;
0046 
0047   //! The DlOpen method provides an interface to the
0048   //! dynamic library loader to allow shared libraries
0049   //! to be loaded and called at runtime.  The DlOpen
0050   //! function attempts to load Filename, in the address
0051   //! space of the process, resolving symbols as appropriate.
0052   //! Any libraries that Filename depends upon are also loaded.
0053   //! If MODE is RTLD_LAZY, then the runtime loader
0054   //! does symbol resolution only as needed.
0055   //! Typically, this means that the first call to a function
0056   //! in the newly  loaded library will cause the resolution of
0057   //! the   address of that function to occur.
0058   //! If Mode is RTLD_NOW, then the runtime loader must do all
0059   //! symbol binding during the DlOpen call.
0060   //! The DlOpen method returns a   handle that is used by DlSym
0061   //! or DlClose.
0062   //! If there is an error, Standard_False is returned,
0063   //! Standard_True otherwise.
0064   //! If a NULL Filename is specified, DlOpen returns a handle
0065   //! for the main  executable, which allows access to dynamic
0066   //! symbols in the running program.
0067   Standard_EXPORT Standard_Boolean DlOpen(const OSD_LoadMode Mode);
0068 
0069   //! The dlsym function returns the address of the
0070   //! symbol name found in the shared library.
0071   //! If the symbol is not found, a NULL pointer is
0072   //! returned.
0073   Standard_EXPORT OSD_Function DlSymb(const Standard_CString Name) const;
0074 
0075   //! Deallocates the address space for the library
0076   //! corresponding to the shared object.
0077   //! If any user function continues to call a symbol
0078   //! resolved in the address space of a library
0079   //! that has been since been deallocated by DlClose,
0080   //! the results are undefined.
0081   Standard_EXPORT void DlClose() const;
0082 
0083   //! The dlerror function returns a string describing
0084   //! the last error that occurred from
0085   //! a call to DlOpen, DlClose or DlSym.
0086   Standard_EXPORT Standard_CString DlError() const;
0087 
0088   //! Frees memory allocated.
0089   Standard_EXPORT void Destroy();
0090 
0091   ~OSD_SharedLibrary() { Destroy(); }
0092 
0093 protected:
0094 private:
0095   Standard_Address    myHandle;
0096   Standard_PCharacter myName;
0097 };
0098 
0099 #endif // _OSD_SharedLibrary_HeaderFile