0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / OSD / OSD_SharedLibrary.hxx
CommitLineData
42cf5bc1 1// Created on: 1994-08-30
2// Created by: J.P. TIRAULT
3// Copyright (c) 1994-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _OSD_SharedLibrary_HeaderFile
18#define _OSD_SharedLibrary_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Address.hxx>
25#include <Standard_PCharacter.hxx>
26#include <Standard_CString.hxx>
27#include <Standard_Boolean.hxx>
28#include <OSD_LoadMode.hxx>
29#include <OSD_Function.hxx>
30
31
32//! Interface to dynamic library loader.
33//! Provides tools to load a shared library
34//! and retrieve the address of an entry point.
35class OSD_SharedLibrary
36{
37public:
38
39 DEFINE_STANDARD_ALLOC
40
41
42 //! Creates a SharedLibrary object with name NULL.
43 Standard_EXPORT OSD_SharedLibrary();
44
45 //! Creates a SharedLibrary object with name aFilename.
46 Standard_EXPORT OSD_SharedLibrary(const Standard_CString aFilename);
47
48 //! Sets a name associated to the shared object.
49 Standard_EXPORT void SetName (const Standard_CString aName);
50
51 //! Returns the name associated to the shared object.
52 Standard_EXPORT Standard_CString Name() const;
53
54 //! The DlOpen method provides an interface to the
55 //! dynamic library loader to allow shared libraries
56 //! to be loaded and called at runtime. The DlOpen
57 //! function attempts to load Filename, in the address
58 //! space of the process, resolving symbols as appropriate.
59 //! Any libraries that Filename depends upon are also loaded.
60 //! If MODE is RTLD_LAZY, then the runtime loader
61 //! does symbol resolution only as needed.
62 //! Typically, this means that the first call to a function
63 //! in the newly loaded library will cause the resolution of
64 //! the address of that function to occur.
65 //! If Mode is RTLD_NOW, then the runtime loader must do all
66 //! symbol binding during the DlOpen call.
67 //! The DlOpen method returns a handle that is used by DlSym
68 //! or DlClose.
69 //! If there is an error, Standard_False is returned,
70 //! Standard_True otherwise.
71 //! If a NULL Filename is specified, DlOpen returns a handle
72 //! for the main executable, which allows access to dynamic
73 //! symbols in the running program.
74 Standard_EXPORT Standard_Boolean DlOpen (const OSD_LoadMode Mode);
75
76 //! The dlsym function returns the address of the
77 //! symbol name found in the shared library.
78 //! If the symbol is not found, a NULL pointer is
79 //! returned.
80 Standard_EXPORT OSD_Function DlSymb (const Standard_CString Name) const;
81
82 //! Deallocates the address space for the library
83 //! corresponding to the shared object.
84 //! If any user function continues to call a symbol
85 //! resolved in the address space of a library
86 //! that has been since been deallocated by DlClose,
87 //! the results are undefined.
88 Standard_EXPORT void DlClose() const;
89
90 //! The dlerror function returns a string describing
91 //! the last error that occurred from
92 //! a call to DlOpen, DlClose or DlSym.
93 Standard_EXPORT Standard_CString DlError() const;
94
95 //! Frees memory allocated.
96 Standard_EXPORT void Destroy();
97~OSD_SharedLibrary()
98{
99 Destroy();
100}
101
102
103
104
105protected:
106
107
108
109
110
111private:
112
113
114
115 Standard_Address myHandle;
116 Standard_PCharacter myName;
117
118
119};
120
121
122
123
124
125
126
127#endif // _OSD_SharedLibrary_HeaderFile