Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:37

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 
0028 //! Interface to dynamic library loader.
0029 //! Provides tools to load a shared library
0030 //! and retrieve the address of an entry point.
0031 class OSD_SharedLibrary 
0032 {
0033 public:
0034 
0035   DEFINE_STANDARD_ALLOC
0036 
0037   
0038   //! Creates a SharedLibrary object with name NULL.
0039   Standard_EXPORT OSD_SharedLibrary();
0040   
0041   //! Creates a SharedLibrary object with name aFilename.
0042   Standard_EXPORT OSD_SharedLibrary(const Standard_CString aFilename);
0043   
0044   //! Sets a name associated to the shared object.
0045   Standard_EXPORT void SetName (const Standard_CString aName);
0046   
0047   //! Returns the name associated to the shared object.
0048   Standard_EXPORT Standard_CString Name() const;
0049   
0050   //! The DlOpen method provides an interface to the
0051   //! dynamic library loader to allow shared libraries
0052   //! to be loaded and called at runtime.  The DlOpen
0053   //! function attempts to load Filename, in the address
0054   //! space of the process, resolving symbols as appropriate.
0055   //! Any libraries that Filename depends upon are also loaded.
0056   //! If MODE is RTLD_LAZY, then the runtime loader
0057   //! does symbol resolution only as needed.
0058   //! Typically, this means that the first call to a function
0059   //! in the newly  loaded library will cause the resolution of
0060   //! the   address of that function to occur.
0061   //! If Mode is RTLD_NOW, then the runtime loader must do all
0062   //! symbol binding during the DlOpen call.
0063   //! The DlOpen method returns a   handle that is used by DlSym
0064   //! or DlClose.
0065   //! If there is an error, Standard_False is returned,
0066   //! Standard_True otherwise.
0067   //! If a NULL Filename is specified, DlOpen returns a handle
0068   //! for the main  executable, which allows access to dynamic
0069   //! symbols in the running program.
0070   Standard_EXPORT Standard_Boolean DlOpen (const OSD_LoadMode Mode);
0071   
0072   //! The dlsym function returns the address of the
0073   //! symbol name found in the shared library.
0074   //! If the symbol is not found, a NULL pointer is
0075   //! returned.
0076   Standard_EXPORT OSD_Function DlSymb (const Standard_CString Name) const;
0077   
0078   //! Deallocates the address space for the library
0079   //! corresponding to the shared object.
0080   //! If any user function continues to call a symbol
0081   //! resolved in the address space of a library
0082   //! that has been since been deallocated by DlClose,
0083   //! the results are undefined.
0084   Standard_EXPORT void DlClose() const;
0085   
0086   //! The dlerror function returns a string describing
0087   //! the last error that occurred from
0088   //! a call to DlOpen, DlClose or DlSym.
0089   Standard_EXPORT Standard_CString DlError() const;
0090   
0091   //! Frees memory allocated.
0092   Standard_EXPORT void Destroy();
0093 ~OSD_SharedLibrary()
0094 {
0095   Destroy();
0096 }
0097 
0098 
0099 
0100 
0101 protected:
0102 
0103 
0104 
0105 
0106 
0107 private:
0108 
0109 
0110 
0111   Standard_Address myHandle;
0112   Standard_PCharacter myName;
0113 
0114 
0115 };
0116 
0117 
0118 
0119 
0120 
0121 
0122 
0123 #endif // _OSD_SharedLibrary_HeaderFile